This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: breakpoint for accessing memory location
> Date: Sat, 21 Oct 2006 13:07:01 -0500
> From: "Rodney M. Bates" <rodney.bates@wichita.edu>
> CC: gdb@sourceware.org
>
> Well, an expression in a program is always interpreted by looking up
> any unqualified identifiers according to the scope rules, at the place in the
> code where the expression appears. But with a watchpoint, that place keeps
> changing. p can go out of scope, come back in, or a different p could become
> visible.
The manual says:
GDB automatically deletes watchpoints that watch local (automatic)
variables, or expressions that involve such variables, when they go out
of scope, that is, when the execution leaves the block in which these
variables were defined.
> So more example questions (same expression, different contexts):
Given the above text, are the answers to any of your questions still
unclear? If so, please tell what is still unclear, and why.
> If the expression is illegal at the place where the program is stopped
> when the watch is typed, is it rejected then and there, or kept around
> in case, e.g., a p comes into scope.
The expression is rejected right there and then. GDB needs to find
the address of each variable that is part of the expression, and if it
cannot, it refuses to set the watchpoint.