6.3. Selecting a Frame

Most commands for examining the stack and other data in your program work on whichever stack frame is selected at the moment. Here are the commands for selecting a stack frame; all of them finish by printing a brief description of the stack frame just selected.

frame n, f n

Select frame number n. Recall that frame zero is the innermost (currently executing) frame, frame one is the frame that called the innermost one, and so on. The highest-numbered frame is the one for main.

frame addr, f addr

Select the frame at address addr. This is useful mainly if the chaining of stack frames has been damaged by a bug, making it impossible for the debugger to assign numbers properly to all frames. In addition, this can be useful when your program has multiple stacks and switches between them.

up n

Move n frames up the stack. For positive numbers n, this advances toward the outermost frame, to higher frame numbers, to frames that have existed longer. n defaults to one.

down n

Move n frames down the stack. For positive numbers n, this advances toward the innermost frame, to lower frame numbers, to frames that were created more recently. n defaults to one. You may abbreviate down as do.

All of these commands end by printing two lines of output describing the frame. The first line shows the frame number, the function name, the arguments, and the source file and line number of execution in that frame. The second line shows the text of that source line.

For example:

(gdb) up
#1  0xd24 in whetstone.log (x=0.75) at whetstone.adb:218
218         return 2.302585093 * LOG10 ( X ) ;
(gdb)

After such a printout, the list command with no arguments prints ten lines centered on the point of execution in the frame. See Section 7.1.

up-silently n, down-silently n

These two commands are variants of up and down, respectively; they differ in that they do their work silently, without causing display of the new frame. They are intended primarily for use in the debugger command scripts, where the output might be unnecessary and distracting.