1

Normally if you set a gdb breakpoint and the the program hits that point, gdb stops execution entirely and lets the user examine and poke around before continuing.

I want the option to be notified of the breakpoint traversal, but not halt execution.

I know I could simply go to the code and add a print statement, but this is annoying especially debugging libraries outside my code which I am not building myself.

Again, I'm already using GDB and want to use 'breakpoints' but just get some sort of notification of when and how many times a line is traversed without halting the whole program's execution. Is this possible?

adowdy
  • 329
  • 2
  • 16

1 Answers1

2

I want the option to be notified of the breakpoint traversal, but not halt execution.

(gdb) break foo.c:123
(gdb) commands $bpnum
continue
end

This attaches a command to the breakpoint. GDB will print that a breakpoint is hit, then run the attached command, which will continue execution.

You could also print some variables before continuing, or even continue only if some condition is true, and stop otherwise. E.g. "continue if x > 100, but stop if it's not".

Employed Russian
  • 199,314
  • 34
  • 295
  • 362