现在的位置: 首页 > 综合 > 正文

GDB 调试的常用命令

2013年02月22日 ⁄ 综合 ⁄ 共 2288字 ⁄ 字号 评论关闭

 

<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1073750139 0 0 159 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-font-family:宋体;
mso-bidi-font-family:"Times New Roman";
mso-font-kerning:1.0pt;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
font-size:10.0pt;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
mso-ascii-font-family:Calibri;
mso-fareast-font-family:宋体;
mso-hansi-font-family:Calibri;
mso-font-kerning:0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;
layout-grid:15.6pt;}
div.Section1
{page:Section1;}
-->

gdb
基本命令

命令 描述


backtrace
(或bt

查看各级函数调用及参数

finish

连续运行到当前函数返回为止,然后停下来等待命令

frame
(或f
) 帧编号

选择栈帧

info
(或i
locals

查看当前栈帧局部变量的值

list
(或l

列出源代码,接着上次的位置往下列,每次列10

list
行号

列出从第几行开始的源代码

list
函数名

列出某个函数的源代码

next
(或n

执行下一行语句

print
(或p

打印表达式的值,通过表达式可以修改变量的值或者调用函数

quit
(或q

退出gdb
调试环境

set
var

修改变量的值

start

开始执行程序,停在main
函数第一行语句前面等待命令

step
(或s

执行下一行语句,如果有函数调用则进入到函数中

break
(或b
)行号

在某一行设置断点

break
函数名

在某个函数开头设置断点

break...
if...

设置条件断点

continue
(或c

从当前位置开始连续而非单步执行程序

delete
breakpoints

删除断点

display
变量名

跟踪查看某个变量,每次停下来都显示它的值

disable
breakpoints

禁用断点

 

enable
 
breakpoints

启用断点

info
(或i
breakpoints

查看当前设置了哪些断点

run
(或r

从头开始连续而非单步执行程序

undisplay

取消对先前设置的那些变量的跟踪

watch

设置观察点

info
(或i
watchpoints

查看当前设置了哪些观察点

x

从某个位置开始打印存储单元的内容,全部当成字节来看,而不区分哪个字节属于哪个变量

 

抱歉!评论已关闭.