How can I examine the stack frame with GDB?

2019-01-21 02:39发布

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 examine everything on the stack? Can this be limited to everything in a function?

标签: gdb stack
3条回答
劫难
2楼-- · 2019-01-21 03:03

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
查看更多
Viruses.
3楼-- · 2019-01-21 03:05
  • bt (or backtrace) will give you a call stack.

  • frame <args> will give you information about a specific frame from the stack.

  • info locals can give you information about any local variables on the stack.

查看更多
萌系小妹纸
4楼-- · 2019-01-21 03:23

You can view the contents of the stack with x/10x $sp

This will print the top 10 elements of the stack.

查看更多
登录 后发表回答