LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 647|回复: 1

More useful GDB usage

[复制链接]
发表于 2006-8-19 22:59:22 | 显示全部楼层 |阅读模式
This report is used to show the power of gdb
As we know, gdb is a powerful tool used to debug programs under linux.
The commands of gdb listed below is used to show its power:

(gdb) b 528
Breakpoint 1 at 0x804b124: file 4n-xfig-nxm-9.c, line 528.
(gdb) commands 1
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>p *d
>p *dd
>end

_______________the commands above are used to run print command on the breakpoint 1

(gdb) set $l=0
(gdb) while $l<10
>p $l
>set $l=$l+1
>end
$1 = 0
$2 = 1
$3 = 2
$4 = 3
$5 = 4
$6 = 5
$7 = 6
$8 = 7
$9 = 8
$10 = 9
(gdb)
_____________________These commands above are a piece of loop program running in gdb which
can be applied for purpose of printing a linked list. The following are to run through a linked list:

(gdb) set $l=0
(gdb) set $p=&dt[0][0]
(gdb) while $l<20
>p *$p
>set $p=$p->next
>set $l=$l+1
>end
... ...
发表于 2006-8-22 21:39:55 | 显示全部楼层
good!
Learn a lot from it!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表