Chinaunix首页 | 论坛 | 博客
  • 博客访问: 465275
  • 博文数量: 115
  • 博客积分: 3777
  • 博客等级: 中校
  • 技术积分: 1070
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-07 09:20
文章分类

全部博文(115)

文章存档

2015年(1)

2013年(3)

2012年(26)

2011年(30)

2010年(34)

2009年(21)

我的朋友

分类: LINUX

2009-12-12 10:16:08

首先,你的程序在经由gcc/g++编译的时候,要带上-g选项。比如:g++ test.cpp -g -o test
然后,执行:gdb test
进入gdb界面之后,输入start并回车,则调试开始。(如果被调试的程序需要参数,则在start后面带参数)
以下是常用命令:

help:     display help. you can use 'help data', 'help running' for more help
start:     start running and suspend
run:        start running
n:           next
s:           step into
c:           continue
b:           set breakpoint
cl:          clear breakpoint
info breakpoints:   list all breakpoints
p:           print value
disp:     keep watch on value
undisp: no longer keep watch on value
where:   show stach trace
thread:   switch thread
ctrl+c:     suspend debug running
list:         display source code

ctrl+x再ctrl+a: 在classic和layout两种方式之间切换gdb的显示方式。(layout方式的gdb很有用,但是layout方式的gdb有bug,你会用到这种快速切换的)
阅读(720) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~