Topics
Prev Next

Trace Statements

A Trace Statement is a message that is output during execution of a debug session. Trace statements can be defined in Enterprise Architect without requiring any changes to your application source code.

Tracepoint Markers are set in the code editor. Like breakpoints, they are placed on a line of code. When that line of code executes, the debugger evaluates the statement, the result of which is logged to the Debug window. (or to file if overridden by the Analyzer script)

Access

Any existing Trace statements can be viewed and managed in the Breakpoints & Markers window. The Breakpoints & Markers window can be displayed using either of the methods outlined here.

Ribbon

Execute > Windows > Breakpoints

Add a Tracepoint Marker

Step

Action

See also

1

Open the source code to debug in the source code editor.

Editing Source Code

2

Find the appropriate code line, right-click in the left margin and select the 'Add Tracepoint Marker' option.

If a marker is already there, press Ctrl+click to show the Breakpoint Properties window.

Breakpoint Properties

3

Ensure the 'Trace statement' checkbox is selected.

4

In the text field under the 'Trace statement' checkbox, type the required Trace statement.

Specifying a Trace Statement

5

Click on the OK button. A Tracepoint Marker is shown in the left margin of the code editor.

Specifying a Trace Statement

A trace statement can be any freeform text. The value of any variables currently in scope can also be included in a trace statement by prefixing the variable name with a special token.

The available tokens are:

  • $ - when the variable is to be interpreted as a string
  • @ - when the variable is a primitive type (int, double, char)

Using the example in the image above, we could output the number of people getting off a train by using this statement:

There were @Passengers before @PeopleOFF got off the train at $Arriving.Name Station

In addition to tracing the values of variables from your code, you can use the $stack and $frame keywords in your Trace statement to print the current stack trace; use:

  • $stack - to print all frames, or
  • $frame[start](count) - print a specific number of frames from the stack starting at a given frame; for example, $frame[0](5) will print the current frame and 4 ancestors

Learn more

Notes

  • Trace statements can be included on any type of breakpoint or marker.