Examining The Stack

Posted by Beetle B. on Tue 14 January 2020

Stack Frames

GDB labels each existing stack frame with a “level”, a number that is zero for the innermost frame, one for the frame that called it, and so on upward.

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. Backtraces bt N tells it to show only the innermost \(N\) frames.

bt -N tells it to show only the outermost \(N\) frames.

bt full tells it to print the values of local variables as well. 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.

There are commands to select a particular frame. You can select by number, address, function name, go up/down the stack. Information About a Frame

Typing f will give you brief information. info frame will give you more detailed information.

You can see the arguments of a frame, the local variables, etc. Applying a Command to Several Frames You can apply a command to multiple frames. Management of Frame Filters

Frame filters are Python based utilities to manage and decorate the output of frames.

tags : gdb