gdb学习12:设置断点的方法进一步学习

版权声明:欢迎转发,转发请标明出处 https://blog.csdn.net/weixin_39465823/article/details/88927077
在源代码37行处设置断点
(gdb) break 37
Breakpoint 1 at 0x829: file strcopy.c, line 37.
在源代码34行处设置断点
(gdb) break 34
Breakpoint 2 at 0x810: file strcopy.c, line 34.
在strcopy.c文件的第10行设置断点
(gdb) break strcopy.c:10
Breakpoint 3 at 0x75c: file strcopy.c, line 10.
显示断点信息
(gdb) info b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000000829 in main at strcopy.c:37
2       breakpoint     keep y   0x0000000000000810 in main at strcopy.c:34
3       breakpoint     keep y   0x000000000000075c in MyStrCopy1 
                                                   at strcopy.c:10
在strcopy.c的MyStrCopy2处设置断点
(gdb) break strcopy.c:MyStrCopy2 
Breakpoint 4 at 0x7c7: file strcopy.c, line 27.
在内存地址0x0000000000000830处设置断点
(gdb) break *0x0000000000000830
Breakpoint 5 at 0x830: file strcopy.c, line 37.
显示断点1的信息
(gdb) info breakpoints 1
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000000829 in main at strcopy.c:37
(gdb) info break 1
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000000829 in main at strcopy.c:37
在46行设置条件判断,一个=就好
(gdb) break 46 if i=10
Breakpoint 1 at 0x8dc: file strcopy.c, line 46.
在47设置条件判断,两个==也可以
(gdb) break 47 if i==10
Note: breakpoint 1 also set at pc 0x8dc.
Breakpoint 2 at 0x8dc: file strcopy.c, line 47.
在30行设置字符串判断
(gdb) break 30 if p=="string copy"
Breakpoint 3 at 0x7f9: file strcopy.c, line 30.
在MyStrCopy2函数里这是条件判断
(gdb) break MyStrCopy2 if s2=="string copy"
Breakpoint 4 at 0x7ce: file strcopy.c, line 28.

猜你喜欢

转载自blog.csdn.net/weixin_39465823/article/details/88927077