Call Stack

Debug ›› Debug Windows ›› Variables Window ››
Parent Previous Next

During a debug session, the Call Stack displays the stack of function calls that are currently active. When a function is called, it is pushed onto the stack. When the function returns, it is popped off the stack.

The Call Stack window displays the currently executing function at the top of the stack and older function calls below that. The window also displays parameter types for each function call.

You can navigate to a function's source code or disassembled object code from the Call Stack. If source code for the selected function is not available, it displays the function's object code in the Disassembly window.

Navigating to a function's code changes the view of the program shown in the Variables window and other debugger windows (i.e. displays local variables and register values for the selected function context), but does not change the next line of execution or the value stored in the program counter.

The Variables window displaying the call stack


When a context other than the active is selected, the program execution point is indicated with a triangular indicator.

In the above figure, the function 'Factorial' was just called itself recursively. Current execution point is indicated with the cyan arrow indicator and the green triangle indicator shows the position of the program counter for the selected context – in this case the position from where the 'Factorial' called itself recursively.


Note: the call stack is reconstructed by analyzing the function prologue. For the analysis to succeed, the function prologue must consist of sequential instructions only.
Some compilers for 8 bit CPUs optimize code size by putting stack frame setup code in separate subroutines, to which they branch immediately upon function entry. In such cases the call stack analysis will fail.
In rare occasions, intensive optimization of code can prevent call stack reconstruction. In such case, reduce the level of optimization during development stage.