This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Checking if addess is on stack?

> From: Vladimir Prus <>
> Date: Thu, 20 Apr 2006 14:26:58 +0400
> Cc:
> I'm not sure that's exactly what I need. This way, watchpoint will be 
> automatically inserted when I enter 'do_that', but as soon as I leave 
> 'do_that', gdb will remove wathchpoint because 'ptr' has gone out of scope. 
> This will prevent me from catching accesses to ptr->i made outside of the 
> function where 'ptr' is valid. Am I missing something?

Perhaps _I_ am missing something.  Isn't `ptr' a variable that is
local to the function `do_that'?  I thought it was; if so, then it
couldn't possibly be accessed after `do_that' returns, because all
locals are popped off the stack when `do_that' returns.  These locals
will get entirely new values when `do_that' is entered the next time.

(If you want to catch accesses to the address where `ptr' _was_ on the
stack, then you really need to set the wathchpoint on an absolute
address.  But watching addresses on the stack beyond the stack top is
a very unusual thing to do, so I don't think this is what your users
would need.)

OTOH, if by ``leave `do_that''' you mean that `do_that' calls some
other function, then `ptr' does not go off the scope, and GDB should
not delete the watchpoint.

Does this make sense?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]