个人工具
登录
查看“用GDB调试程序”的源代码 - Ubuntu中文
页面
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“用GDB调试程序”的源代码
来自Ubuntu中文
←
用GDB调试程序
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
==GDB的命令概貌== 启动gdb后,你就被带入gdb的调试环境中,就可以使用gdb的命令开始调试程序了,gdb的命令可以使用help命令来查看,如下所示: $ gdb GNU gdb 6.7.1-debian Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu". (gdb) help List of classes of commands: aliases -- Aliases of other commands breakpoints -- Making program stop at certain points data -- Examining data files -- Specifying and examining files internals -- Maintenance commands obscure -- Obscure features running -- Running the program stack -- Examining the stack status -- Status inquiries support -- Support facilities tracepoints -- Tracing of program execution without stopping the program user-defined -- User-defined commands Type "help" followed by a class name for a list of commands in that class. Type "help all" for the list of all commands. Type "help" followed by command name for full documentation. Type "apropos word" to search for commands related to "word". Command name abbreviations are allowed if unambiguous. (gdb) gdb 的命令很多,gdb把之分成许多个种类。help命令只是例出gdb的命令种类,如果要看种类中的命令,可以使用help <class> 命令,如:help breakpoints,查看设置断点的所有命令。也可以直接help <command>来查看命令的帮助。 gdb中,输入命令时,可以不用打全命令,只用打命令的前几个字符就可以了,当然,命令的前几个字符应该要标志着一个唯一的命令,在Linux下,你可以敲击两次TAB键来补齐命令的全称,如果有重复的,那么gdb会把其列出来。 示例一:在进入函数func时,设置一个断点。可以敲入break func,或是直接就是b func (gdb) b func Breakpoint 1 at 0x804837a: file tst.c, line 5. 示例二:敲入b按两次TAB键,你会看到所有b打头的命令: (gdb) b backtrace break bt (gdb) 示例三:只记得函数的前缀,可以这样: (gdb) b make_ <按TAB键> (再按下一次TAB键,你会看到:) make_a_section_from_file make_environ make_abs_section make_function_type make_blockvector make_pointer_type make_cleanup make_reference_type make_command make_symbol_completion_list (gdb) b make_ GDB把所有make开头的函数全部列出来给你查看。 示例四:调试C++的程序时,有可以函数名一样。如: (gdb) b 'bubble( M-? bubble(double,double) bubble(int,int) (gdb) b 'bubble( 你可以查看到C++中的所有的重载函数及参数。(注:M-?和“按两次TAB键”是一个意思) 要退出gdb时,只用发quit或命令简称q就行了。
返回至
用GDB调试程序
。