User`s manual

102 digi.com Debugging with Dynamic C
6.3.8 Execution Trace
Execution tracing was introduced in Dynamic C 9. The program Samples\demo4.c demonstrates its
use. Go to Section 3.4 for a full description of demo4.c.
There are basically three ways to toggle tracing during program execution. Two of them are similar: they
require that tracing be enabled in the Debugger tab of the Project Options dialog and they do not trace in
nodebug functions.
GUI options: Opening the Inspect menu, you will see the “Stop Execution Tracing” and the “Start Exe-
cution Tracing” commands, along with their keyboard shortcuts and toolbar buttons. Use any of these
methods to start and stop execution tracing while the program is running or while stopped at a break-
point.
_TRACEON and _TRACEOFF: Macros that are the equal to the GUI options
The third way does not require tracing to be enabled and it can be done in nodebug functions.
_TRACE: A macro that causes itself, and only itself, to be traced.
Note that execution tracing is intrusive, slightly more so when the Trace window is open.
Pros The large amount of tracing information that may be saved on the host PC is
available even if the program crashes. Tracing information fields can be turned
on and off by the user on the Debugger tab of the Project Options dialog. The
size of the trace buffer, which determines the number of trace entries, and wheth-
er to save the buffer to a file on program termination are also decided on the De-
bugger tab.
Cons Execution tracing alters the timing of a program because tracing information is
inserted between every source statement that is executed. Therefore, execution
tracing may not be useful in tracking down a timing related problem... it might
even cause one.
Uses A good data gathering tool to use when you are not sure what is happening.
Example Say you have an application in which program flow deviates at some unknown
point that is too tedious to detect by stepping. With execution tracing enabled,
compile the program and click “Trace On” in the Inspect menu. Run the program
and stop when the deviation is known or suspected to have occurred. Open the
Trace window. You can now follow the execution at any point in the trace by
double-clicking to source, or save to a file and grep for pertinent function calls
or lines executed.