Is there a way to reset breakpoint statistics in GDB?

Assume the following .gdbinit :

 break foobar ignore 1 1 run 

The program starts using gdb --args ./myprogram --argument1 --argument2 , etc.

Now, when I start this, the first time around everything is fine and dandy. However, if I issue run at the prompt (gdb) to restart the program with the last known command line, the ignore line simply does not take effect.

The reason, of course, is clear. The first time I finish

 (gdb) info break Num Type Disp Enb Address What 1 breakpoint keep y 0x000000000061ea6a in foobar at ../foobar.c:1173 breakpoint already hit 1 time 

And any subsequent start starts with what value is displayed for X in breakpoint already hit X time . Naturally, this value will already exceed the limit set on ignore .

How can I reset the statistics on breakpoints or better yet, how can I get run to do this automatically for me?

+5
source share
1 answer

How can I reset the statistics on breakpoints or better yet, how can I get the launch to do this automatically for me?

One way to do this:

 # ~/.gdbinit break foobar break main commands 2 silent ignore 1 1 continue end 

Now, every time you start, you hit a quiet breakpoint on main , which resets the ignore counter to the foobar breakpoint and continues.

+3
source

Source: https://habr.com/ru/post/1215574/


All Articles