This is the mail archive of the
mailing list for the GDB project.
Re: Watchpoints with condition
> Cc: Eli Zaretskii <firstname.lastname@example.org>, email@example.com
> From: Jim Blandy <firstname.lastname@example.org>
> Date: Tue, 04 Dec 2007 09:23:52 -0800
> I guess I don't see why 'GDB stops your program whenever the value of
> this expression changes' is hard to understand.
Two reasons: (1) most people think watchpoints watch variables, not
expressions; and (2) the notion of "foo == 1" being an expression
whose value is either 1 or zero is natural only to C hackers.
> Explaining conditional watchpoints is a superset of explaining
> watchpoints, so I don't see how it could be simpler.
It is simpler because you still watch a simple variable, and the
condition is kept separately. It is similar to
x = y + (foo == 1);
if (foo == 1)
x = y + 1;
x = y;
The latter shows what the code does more clearly (and in fact some
coding standards advise against the former style).