当前位置: 技术问答>linux和unix
为什么我的程序设置断点之后不能单步执行?
来源: 互联网 发布时间:2015-11-05
本文导语: 调试代码如下 ------------------ (gdb)break 24 Breakpoint 1 at 0x8048460:file greeting.c,line 24. (gdb)run ........ Breakpoint 1, my_print2(string=0xbfd97bc3 "hello there.") at greeting.c:24 24 string2[size-i]=string[i]; (gdb) watch...
调试代码如下
------------------
(gdb)break 24
Breakpoint 1 at 0x8048460:file greeting.c,line 24.
(gdb)run
........
Breakpoint 1, my_print2(string=0xbfd97bc3 "hello there.") at greeting.c:24
24 string2[size-i]=string[i];
(gdb) watch string2[size-i]
Hardware watchpoint 2: string2[size-i]
(gdb) next
warning: Could not remove hardware watchpoint 2.
Warning:
Could not insert hardware watchpoint 2.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoint.
------------------------
初次接触调试,谢谢拉。
------------------
(gdb)break 24
Breakpoint 1 at 0x8048460:file greeting.c,line 24.
(gdb)run
........
Breakpoint 1, my_print2(string=0xbfd97bc3 "hello there.") at greeting.c:24
24 string2[size-i]=string[i];
(gdb) watch string2[size-i]
Hardware watchpoint 2: string2[size-i]
(gdb) next
warning: Could not remove hardware watchpoint 2.
Warning:
Could not insert hardware watchpoint 2.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoint.
------------------------
初次接触调试,谢谢拉。
|
来自文档:
This message is printed when you attempt to resume the program, since only then gdb knows exactly how many hardware breakpoints and watchpoints it needs to insert.
When this message is printed, you need to disable or remove some of the hardware-assisted breakpoints and watchpoints, and then continue.
把你的代码贴出来看看
This message is printed when you attempt to resume the program, since only then gdb knows exactly how many hardware breakpoints and watchpoints it needs to insert.
When this message is printed, you need to disable or remove some of the hardware-assisted breakpoints and watchpoints, and then continue.
把你的代码贴出来看看
|
没搞清楚.
你把一开始设置的断点去掉(disable break 1)似乎可以继续调试,但是我这里出了Segmentation fault
你可以不用watch直接在每次到断点时print变量:
p string2[size2-i]
你把一开始设置的断点去掉(disable break 1)似乎可以继续调试,但是我这里出了Segmentation fault
你可以不用watch直接在每次到断点时print变量:
p string2[size2-i]