佳为好友

笔记:Examining the Stack - Debugging with GDB

10-3-25

笔记:http://developer.apple.com/Mac/library/documentation/DeveloperTools/gdb/gdb/gdb_7.html#SEC44


Examining the Stack

 

Stack frames

 

frame args

[选择指定的frame.如果没有参数的话,则显示当前的frame.]The frame command allows you to move from one stack frame to another, and to print the stack frame you select. args may be either the address of the frame or the stack frame number. Without an argument, frame prints the current stack frame.

select-frame

[frame的作用相同,只是没有提示信息.]The select-frame command allows you to move from one stack frame to another without printing the frame. This is the silent version of frame.

 

 

 

Backtraces

 

backtrace

bt

[最通用的bt功能.Ctrl-C可以中断该命令.]Print a backtrace of the entire stack: one line per frame for all frames in the stack. You can stop the backtrace at any time by typing the system interrupt character, normally C-c.

backtrace n

bt n

[bt前n个frame.]Similar, but print only the innermost n frames.

backtrace -n

bt -n

[bt后n个frame.]Similar, but print only the outermost n frames.

backtrace full

bt full

[bt的同时,显示所有有效的局部变量.]Print the values of the local variables also.

 

[where 和 info stack(简写为info s)都可以到达bt的作用.]The names where and info stack (abbreviated info s) are additional aliases for backtrace.

 

 

 

Selecting a frame

 

frame n

n

[选择一个frame.]Select frame number n. Recall that frame zero is the innermost (currently executing) frame, frame one is the frame that called the innermost one, and so on. The highest-numbered frame is the one for main.

frame addr

addr

[这个没看懂.]Select the frame at address addr. This is useful mainly if the chaining of stack frames has been damaged by a bug, making it impossible for GDB to assign numbers properly to all frames. In addition, this can be useful when your program has multiple stacks and switches between them. On the SPARC architecture, frame needs two addresses to select an arbitrary frame: a frame pointer and a stack pointer. On the MIPS and Alpha architecture, it needs two addresses: a stack pointer and a program counter. On the 29k architecture, it needs three addresses: a register stack pointer, a program counter, and a memory stack pointer.

up n

[向上移动n个frame.如果没有参数,则向上移动一个frame.]Move n frames up the stack. For positive numbers n, this advances toward the outermost frame, to higher frame numbers, to frames that have existed longer. n defaults to one.

down n

[向下移动n个frame.如果没有参数,则向下移动一个frame.]Move n frames down the stack. For positive numbers n, this advances toward the innermost frame, to lower frame numbers, to frames that were created more recently. n defaults to one. You may abbreviatedown as do.

up-silently n

down-silently n

[up和down基本相同,只是没有提示信息.它们通常用于写脚本时使用.]These two commands are variants of up and down, respectively; they differ in that they do their work silently, without causing display of the new frame. They are intended primarily for use in GDB command scripts, where the output might be unnecessary and distracting.

 

 

Information about a frame

 

frame

f

[显示当前的frame值.]When used without any argument, this command does not change which frame is selected, but prints a brief description of the currently selected stack frame. It can be abbreviated f. With an argument, this command is used to select a stack frame. See section Selecting a frame.

info frame

info f

[显示当前的frame的详细信息.很有用噢.]This command prints a verbose description of the selected stack frame, including:

·       the address of the frame

·       the address of the next frame down (called by this frame)

·       the address of the next frame up (caller of this frame)

·       the language in which the source code corresponding to this frame is written

·       the address of the frame's arguments

·       the address of the frame's local variables

·       the program counter saved in it (the address of execution in the caller frame)

·       which registers were saved in the frame

The verbose description is useful when something has gone wrong that has made the stack format fail to fit the usual conventions.

info frame addr

info f addr

[不太懂.]Print a verbose description of the frame at address addr, without selecting that frame. The selected frame remains unchanged by this command. This requires the same kind of address (more than one for some architectures) that you specify in the framecommand. See section Selecting a frame.

info args

[打印本frame的参数.]Print the arguments of the selected frame, each on a separate line.

info locals

[打印本frame的局部变量.]Print the local variables of the selected frame, each on a separate line. These are all variables (declared either static or automatic) accessible at the point of execution of the selected frame.

info catch

[打印本frame的异常列表.不太懂.]Print a list of all the exception handlers that are active in the current stack frame at the current point of execution. To see other exception handlers, visit the associated frame (using the updown, or frame commands); then typeinfo catch. See section Setting catchpoints.


+++++

posted on 2012-12-23 10:16 佳为好友 阅读(270) 评论(0)  编辑 收藏 引用 所属分类: Debug-GDB


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2012年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

留言簿(1)

随笔分类

搜索

最新评论

评论排行榜