I have a function that is called some large number of times, and eventually segfaults.
However, I don't want to set a breakpoint at this function and stop after every time it's called, because I will be here for years.
I've heard that I can set a counter
in GDB for a breakpoint, and each time the breakpoint is hit, the counter is decremented, and only gets triggered when the counter
= 0.
Is this accurate, and if so how do I do it? Please give the gdb code for setting such a breakpoint.
Best Answer
Read section 5.1.6 of the GDB manual. What you have to do is first set a breakpoint, then set an 'ignore count' for that breakpoint number, e.g.
ignore 23 1000
.If you don't know how many times to ignore the breakpoint, and don't want to count manually, the following may help: