当变量等于我设置的某个值时,我想让GDB设置一个断点,我尝试了以下示例:
#include <stdio.h>
main()
{
int i = 0;
for(i=0;i<7;++i)
printf("%d\n", i);
return 0;
}
GDB的输出:
(gdb) break if ((int)i == 5)
No default breakpoint address now.
(gdb) run
Starting program: /home/SIFE/run
0
1
2
3
4
5
6
Program exited normally.
(gdb)
如您所见,GDB没有任何断点,GDB是否可以做到这一点?
(gdb) watch i No symbol "i" in current context.