开发者

How can I examine the stack frame with GDB?

开发者 https://www.devze.com 2022-12-29 18:59 出处:网络
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 lim

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 (or backtrace) will give you a call stack.

  • frame <args> will select a frame on the call stack for inspection

  • info frame <args> will give you information about a specific frame from the stack. When called without arguments it will display the currently selected frame

  • info 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号