This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Checking if addess is on stack?
On Thu, Apr 20, 2006 at 03:21:03PM +0300, Eli Zaretskii wrote:
> Well, I thought the trick with tb does the equivalent of what you
> wanted. It automatically inserts the watchpoint when the scope is
> entered, while its deletion is handled by GDB itself. Next time the
> function is entered, GDB will insert the watchpoint again. Isn't that
> what you want, as far as the variable-out-of-scope issue is
> considered? (Whether to watch the address or the expression is a
> different matter, as mentioned above.)
What he wants is not to stop the watchpoint when ptr goes out of scope,
but when ptr->i goes out of scope - if ptr points to a stack allocated
variable, in this function or another one.
Sorry, Vladimir, there's no way to do this. You'd have to keep an eye
on the value of $sp manually, and know whether the stack grew up or
down. Even that wouldn't help enough, since you might miss a stack pop
and push. There's no way to keep track of register values in the way
we can watchpoint memory.
--
Daniel Jacobowitz
CodeSourcery