This is the mail archive of the
mailing list for the GDB project.
Re: Watchpoints with condition
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Jim Blandy <jimb at codesourcery dot com>
- Cc: gdb at sourceware dot org
- Date: Mon, 03 Dec 2007 22:59:37 +0200
- Subject: Re: Watchpoints with condition
- References: <email@example.com> <firstname.lastname@example.org> <email@example.com> <20071130234853.GA27583@caradoc.them.org> <firstname.lastname@example.org>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> From: Jim Blandy <email@example.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
> 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.)