如何让GDB只在被调用一定时间之后才能破解它?

时间:2011-10-11 21:06:07

标签: gdb

例如,我的程序中有一个函数NamespaceA :: ClassB :: FunctionC()。我知道我可以通过“break NamespaceA :: ClassB :: FunctionC”让GDB打破它。但是,如果我只想让GDB在那里打破,在调用这个函数后,怎么办呢,比如100次?

我认为解决方案是在程序中再添加一个变量,然后我可以使用GDB中的“break ... if cond”命令。但是,如果不在我的程序中添加变量,我能实现同样的目标吗?

谢谢。

1 个答案:

答案 0 :(得分:22)

(gdb) continue 100

应该做的伎俩

(gdb) help continue
Continue program being debugged, after signal or breakpoint.
 If proceeding from breakpoint, a number N may be used as an argument,
 which means to set the ignore count of that breakpoint to N – 1 (so that
 the breakpoint won’t break until the Nth time it is reached).