6.2 Stacks Without frames

Some compilers provide a way to compile functions so that they operate without stack frames. (For example, the gcc option

'-fomit-frame-pointer'

generates functions without a frame.) This is occasionally done with heavily used library 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-framecommand allows you to move from one stack

 

frame to another 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

backtrace n, bt n backtrace -n,bt -nbacktrace-other-thread

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 character, normally C-c.

Similar, but print only the innermost n frames.

Similar, but print only the outermost n frames.

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.

72 Examining the Stack

Page 72
Image 72
HP gnu source-level debugger 5992-4701 manual Stacks Without frames, Commands for Examining the Stack, Backtraces