Re: Watchpoints with condition

Eli Zaretskii
2007-12-03T20:59:53Z

> From: Jim Blandy <jimb@codesourcery.com>
> Date: Mon, 03 Dec 2007 09:54:41 -0800
>
> Okay, so 'watch foo if foo == 1' has some interesting behavior:
> - if foo is 1 when the watchpoint is set, then the watchpoint doesn't
> trigger until foo becomes != 1, and then becomes 1 again.
> - If foo is != 1 when the watchpoint is set, then the command is
> equivalent to watch foo == 1.
>
> The first case seems really obscure; I assumed that wasn't what Eli
> was using conditional watchpoints for "quite a lot".

Right. You can "set foo = something that is not 1", before starting
to watch like that. But that's normally not a problem in real life,
because this use case is for catching writes of _rare_ values, not
frequent ones.

> I think the only valuable use case for conditional watchpoints is the
> one you mentioned, where Y is something expensive, and X is some
> cheaper conservative approximation to the condition we really want.

Well, you are wrong (and Daniel explained one reason why). Believe
me, this use case is very useful and important. (Actually, it was one
of the main reasons I got involved with fixing x86 hardware
watchpoints at the time: I needed to set several watchpoints on the
same variable, each one watching a different value being written.)