User`s manual

Dynamic C Users Manual digi.com 21
3.4.1 Trace Macros
Trace macros provide more fine-grained control than the menu options.
_TRACE
The _TRACE macro creates one entry in the trace buffer containing the program state information at the
time the macro executes. It is useful if you want to monitor one statement closely rather than follow the
flow of part of a program. In Demo4.c, _TRACE is executed at lines 45 and 77, as you can see in the
screenshot in Figure 3.3.
Figure 3.3 Trace window contents after running Demo4.c
The _TRACE macro does not affect the _TRACEON and _TRACEOFF macros, and likewise is not
affected by them. It will execute regardless of whether tracing is turned on or off. An interesting thing to
note about _TRACE is that it generate a trace statement even when it appears in a nodebug function.
_TRACEON
The _TRACEON macro turns on tracing. This does not cause any information to be recorded by itself like
the _TRACE macro, but rather causes a change of state within the debug kernel so that program state infor-
mation is recorded for program and library statements executed thereafter, until the _TRACEOFF macro is
executed or by menu command. Dynamic C captures the information you specified in the Project Options
dialog and displays it in the Trace window.
In Demo4.c, _TRACEON is executed in the function foo(). Note that tracing is turned on in the second
call to foo1() in main(), but that except for the _TRACE statement there are no trace statements for
foo1(). This is because statements in nodebug functions are not traceable.
_TRACEOFF
The _TRACEOFF macro turns off tracing, starting with the next statement after it executes. Instances of
the _TRACE macro will still execute, but tracing remains off until it is turned on by the _TRACEON macro
or by menu command.