Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: gdb@sourceware.org
Subject: Re: Checking if addess is on stack?
Date: Thu, 20 Apr 2006 19:12:00 -0000	[thread overview]
Message-ID: <20060420184153.GA21153@nevyn.them.org> (raw)
In-Reply-To: <uzmigumrn.fsf@gnu.org>

On Thu, Apr 20, 2006 at 09:26:04PM +0300, Eli Zaretskii wrote:
> > We're at HERE.  I believe that what Vladimir wants is:
> >   (A) a watchpoint on the value referenced by ptr->i, at the moment,
> >       regardless of future changes to ptr.  I do this all the time
> >       and wouldn't mind an easier way, but it's just:
> >          print &ptr->i
> >          watch *$31
> >       (Where $31 is the right number.
> 
> But "watch ptr->i" already does that for you.  Except that it _also_
> watches &ptr, and that latter address is what goes out of scope when
> we leave func2.

These two are not at all the same.  Suppose ptr is being walked along a
linked list.  The user might be interested in the expression "ptr->i",
but in my experience that's almost never what I want if ptr is moving;
instead, I am interested in (for example) something scribbling over
this particular element of the linked list.  I don't care when ptr goes
out of scope, or when ptr is changed.  I'm interested in the memory.

> >   (B) For that watchpoint to go out of scope when kin.i, the underlying
> >       object, dies.
> 
> So perhaps we need to modify the watchpoint machinery so that when
> func2 returns, we stop watching the parts of the expression that are
> popped from the stack, but continue watching those which are still
> valid and in scope.  Would that make sense?

I don't understand.  How could we continue watching anything, if we can
no longer evaluate the expression?  None of the expression is still in
scope.

> >       Put this way, it's apparent that there is really no way to do
> >       this.
> 
> I think it can be achieved with setting 2 watchpoints: one on
> "ptr->i", the other on the address it points to.

That will catch when ptr goes out of scope, but we don't care about
that.  In my example, ptr goes out of scope in one function, but the
thing it points to doesn't go "out of scope" until much later.

> >       -> Would that actually be neat and useful for the CLI?
> > 
> > (gdb) print $31
> > $32 = (int *) 0x44444444 <kin.i in frame #3>
> 
> Doesn't "info symbol $31" do this already?

I believe only for global variables, not for locals on the stack.

-- 
Daniel Jacobowitz
CodeSourcery


  reply	other threads:[~2006-04-20 18:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-20 10:27 Vladimir Prus
2006-04-20 11:42 ` Eli Zaretskii
2006-04-20 11:48   ` Vladimir Prus
2006-04-20 12:21     ` Eli Zaretskii
2006-04-20 12:49       ` Vladimir Prus
2006-04-20 14:27         ` Eli Zaretskii
2006-04-20 14:39           ` Daniel Jacobowitz
2006-04-20 15:24             ` Eli Zaretskii
2006-04-20 15:32               ` Daniel Jacobowitz
2006-04-20 18:41                 ` Eli Zaretskii
2006-04-20 19:12                   ` Daniel Jacobowitz [this message]
2006-04-21 11:45                     ` Eli Zaretskii
2006-04-22  8:06                       ` Daniel Jacobowitz
2006-04-20 16:29           ` Vladimir Prus
2006-04-20 19:03             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060420184153.GA21153@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox