This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Watchpoints with condition


> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Fri, 30 Nov 2007 19:25:19 +0300
> 
> 
> GDB presently allow a watchpoint to have a condition, and I wonder
> what are the use-cases for that.
> 
> If anybody has used watchpoint in condition in practice when debugging
> real problem (as opposed to just playing with gdb, or making up
> possible uses), can he share why it was needed?

I use it quite a lot.  The simplest use case is like this:

  (gdb) watch foo if foo == 1

This stops at the watchpoint only if the value written to the variable
is 1.  Imagine that you need to find who writes a specific value into
a variable that is otherwise written into a lot by legitimate code.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]