Re: breakpoint for accessing memory location

Eli Zaretskii
2006-10-21T15:29:13Z

> Date: Sat, 21 Oct 2006 10:06:00 -0500
> From: "Rodney M. Bates" <rodney.bates@wichita.edu>
> CC: gdb@sourceware.org
>
> But while this subject is open, I would like to see more explanation on just
> what the semantics of evaluating a watchpoint expression are. An expression
> always is evaluated in a particular context that can affect the legality/result,
> but in the case of a watchpoint, execution is proceeding and changing the
> context. I have never been sure what the rules are.
> For example, I sometimes want to watch p->f, where p is local variable that
> I know perfectly well will soon cease to exist, but I also know *p will
> remain. I've long since learned that watching p->f doesn't work. Instead,
> I print the address of p->f and then watch the contents of that address.

Does "watch *(<type-of-p->f> *)&p->f" work as well?

> But more information on the general rules would be helpful in the manual.

Are there any more examples beyond p->f? That is, what other
situations are there where the context can matter? Are we talking
only about portions of expression going out of context (and thus
becoming invalid), or are there other problems?

(You see, I don't think I understand what you mean by ``the semantics
of evaluating a watchpoint expression'', and a single example you gave
is not enough for me to figure that out.)