How can I examine the stack frame with GDB?
For the current stack frame:
- info frame lists general info about the frame (where things start in memory, etc.)
- info args lists arguments to the function
- info locals lists local variables stored in the frame
- just try
bt full
, and you will get all frames and locals - input
frame x
, to enter the x frame
by the way, you should know about process address space and what it is composed: linux virtual address space, this will help you understand how the frame is used.
You can view the contents of the stack with x/10x $sp
This will print the top 10 elements of the stack.
bt
(orbacktrace
) will give you a call stack.frame <args>
will select a frame on the call stack for inspectioninfo frame <args>
will give you information about a specific frame from the stack. When called without arguments it will display the currently selected frameinfo locals
can give you information about any local variables on the stack.