User`s manual

Dynamic C Users Manual digi.com 103
6.3.9 Symbolic Stack Trace
Dynamic C has always had the Stack window, but the Stack Trace window is new in Dynamic C 9. The old
Stack window is still available to any compiled program, and being able to view the top 32 bytes of the
stack could still be useful.
The Stack Trace window lets you see where you are and how you got there. It keeps a running depth value,
telling you how many bytes have been pushed on the stack in the current program instance, or since the
depth value reset button was clicked. The Stack Trace window only tracks stack-based variables, i.e., auto
variables. The storage class for local variables can be either auto or static, specified through a modifier
when the variable is declared or globally via the #class directive. Whatever the means, if a local variable is
marked static it will not appear in the Stack Trace window.
Pros Provides a concise history of the call sequence and values of local variables and
function arguments that led to the current breakpoint, all for a very small cost in
execution time and BIOS memory.
Cons Currently, the Stack Trace window can not trace the parameters and local vari-
ables in cofunctions. Also the contents of the window can not be saved after a
program crash.
Uses Use stack tracing to capture the call sequence leading to a breakpoint and to see
the values of functions arguments and local variables.
Example Say you have a function that is behaving badly. You can set a breakpoint in the
function and use the Stack Trace window to examine the function call sequence.
Examining the call sequence and the parameters being passed might give enough
information to solve the problem.
The following screenshot shows an instance of qsortdemo.c and the Stack
Trace window. Note that the call to memcpy() is not represented on the stack.
The reason? Its stack activity had completed and program execution had re-
turned to main() when the stack was traced at the breakpoint in the function
mycmp().
Figure 6.2 Using Stack Trace