1. 观察一个队列
(gdb) p &que
$1 = (Que *) 0x7fffffffce10
(gdb) watch *(Que*)0x7FFFFFFFCE10
Watchpoint 2: *(Que*)0x7FFFFFFFCE10
(gdb) n
Begin
(gdb)
Test queue Begin
(gdb)
(gdb)
Watchpoint 2: *(Que*)0x7FFFFFFFCE10
Old value = {front = 0, rear = 0, node = {0 }}
New value = {front = 0, rear = 0, node = {3, 0 }}
QueAddRear (p=0x7fffffffce10, n=3) at que.c:39
(gdb)
2. 自定义函数打印链表所有元素
-
(gdb) define dumph0 =>函数名,可以任意定
-
Type commands for definition of "dumph0".
-
End with a line saying just "end".
-
>set $_node0=(node0*)$arg0 => arg0:命令行参数 node0* 程序里的结构名
-
>while $_node0 => 变量名,可以任意定
-
>printf "%d %d %d\n", $_node0->x, $_node0->y, $_node0->maxr
-
>set $_node0=$_node0->nt
-
>end
-
>end
-
-
(gdb) dumph0 h0
-
2 4 2
-
3 3 2
-
(gdb)
3. GDB中编译程序
-
(gdb) compile =>进入编译命令行
-
>gcc -ggdb -Wall 20170419adv.c -o 20170419adv =>编译
-
>^D =>退出编译状态
4. 查看全局变量(当局部变量把全局变量隐藏时)
-
(gdb) watch '0503.c'::board
-
Watchpoint 8: '0503.c'::board
-
(gdb) p '0503.c'::board
-
$44 = {{0, -1, -1, -1, 0}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {0, -1, -1, -1, 1}}
-
(gdb)
5. 进入一个函数执行后
1.如果想要立即
中断当前函数运行并返回,用
return,当前函数的剩余语句将
不被执行。(return可带参数,可以此随意设定当前函数的返回值)
2.如果想让程序
执行到当前函数返回之后停止,用
finish,当前函数的剩余语句将
会正常运行。
http://blog.csdn.net/njujmj/article/details/4384010
阅读(1478) | 评论(0) | 转发(0) |