Right now I've been using GDB to disassemble a binary file and check out different registers and whatnot. Is there an easy command to e开发者_如何学JAVAxamine everything on the stack? Can this be limited to everything in a function?
You can view the contents of the stack with x/10x $sp
This will print the top 10 elements of the stack.
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
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.
- 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.
精彩评论