Debugging with GDB (February 2008)

Table Of Contents
52 Debugging with GDB
‘-fomit-frame-pointer’
generates functions without a frame.) This is occasionally done with heavily used li-
brary functions to save the frame setup time. GDB has limited facilities for dealing with
these function invocations. If the innermost function invocation has no stack frame, GDB
nevertheless regards it as though it had a separate frame, which is numbered zero as usual,
allowing correct tracing of the function call chain. However, GDB has no provision for
frameless functions elsewhere in the stack.
6.3 Commands for Examining the Stack
The following commands are used for examining the stack:
frame args
Select and print a stack frame. With no argument, prints the selected stack
frame. An argument specifies the frame to select. It can be a stack frame
number or the address of the frame. With argument, nothing is printed if input
is coming from a command file or a user-defined command.
select-frame
The select-frame command allows you to move from one stack frame to an-
other without printing the frame. This is the silent version of frame.
6.4 Backtraces
A backtrace is a report of the active stack frames instantiated by the execution of a
program. It shows one line per frame, for all the active frames, starting with the currently
executing frame (frame zero), followed by its caller (frame one), and on up the stack.
The following commands are used for backtrace:
backtrace
bt Print a backtrace of the entire stack: one line per frame for all frames in the
stack.
You can stop the backtrace at any time by typing the system interrupt charac-
ter, normally C-c.
backtrace n
bt n Similar, but print only the innermost n frames.
backtrace -n
bt -n Similar, but print only the outermost n frames.
backtrace-other-thread
Print backtrace of all stack frames for a thread with stack pointer SP and
program counter PC. This command is useful in cases where the debugger does
not support a user thread package fully.
The names where and info stack (abbreviated info s) are additional aliases for
backtrace.