例如,我的程序中有一个函数 NamespaceA::ClassB::FunctionC() 。我知道我可以通过“break NamespaceA::ClassB::FunctionC”要求 GDB 在那里中断。但是,如果我只想让 GDB 在调用此函数(例如 100 次)后在那里中断,该怎么办?
我认为一种解决方案是在程序中添加一个变量,然后我可以使用 GDB 中的“break ... if cond”命令。但是我可以在不向程序添加变量的情况下实现同样的目标吗?
谢谢。
最佳答案
(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).
关于gdb - 如何要求 GDB 仅在调用某个函数一定次数后才在该函数处中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7732503/