Examining execution flow
Information on the call stack, stack frames, and navigating the stack.
The call stack and stack frames
Each time your program performs a function call, information about the call is saved in a block of data called a stack frame. Each frame contains the data associated with one call to one function.
The stack frames are allocated in a region of memory called the call stack. When
your program is started, the stack has only one frame, that of the function MAIN
.
This is the initial frame, also known as the outermost frame. As the debugger executes your program,
a new frame is made each time a function is called. When the function returns, the frame for that
function call is eliminated.
The Debugger assigns numbers to all existing stack frames, starting with zero for the innermost frame, one for the frame that called it, and so on upward. These numbers do not really exist in your program; they are assigned by the Debugger to allow you to designate stack frames in commands.
Each time your program stops, the Debugger automatically selects the currently executing frame and describes it briefly. You can use the frame command to select a different frame from the current call stack.
Navigate the stack
Use the Up/Down options to track function calls. Up displays the calling function. The Up command advances toward the outermost frame each time it is processed. The Data view display is based on the new context.
Down is the opposite of Up: it comes back to the inner frame down to the last executed line.