4

I have an application that basically creates a thread many times. I would like to watch changes to a local variable on these threads. I can install a watchpoint dynamically by setting a breakpoint after the variable was initialized, which then automatically installs a watch point whenever such a thread is run:

break somefile.c:123
commands
watch myvar
continue
end

This seems to work great, except that every time one of these threads terminates, gdb breaks with the following message:

Watchpoint 3 deleted because the program has left the block in which its expression is valid.

Which makes sense, because the local variable is going out of scope. But is there any way to make gdb not break when this happens, so that the application keeps running without me having to hit continue countless of times?

Tom
  • 653
  • 1
  • 8
  • 15
  • If you do `maint info breakpoints`, you'll see a hidden breakpoint, something like `-26`, whose purpose is to remove the watchpoint when your current function finishes. I think the sane thing for gdb to do is to warn you about the watchpoint going out of scope and continue the program, not remain stopped. If there isn't already a setting to do this, someone can put in a feature request to the developers. – Mark Plotnick Oct 26 '16 at 17:45

0 Answers0