Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <ghost@cs.msu.su>
To: gdb@sources.redhat.com
Subject: -var-update and address changes
Date: Wed, 12 Apr 2006 16:02:00 -0000	[thread overview]
Message-ID: <e1iqcl$2k4$1@sea.gmane.org> (raw)


Hi,
I'm running into what looks like a bug in -var-update. Basically, I create a
varobj with "&variable", then I enter a function that has a variable with
the same name, and -var-update does not report anything.

Here's the code, and the gdb session. 

    int foo()
    {
        int i = 10;
        ++i;
        return i;
    }
    
    int main()
    {
        int i = 10;
        i = foo();
        return i;
    }

And here's the session

    -break-insert a.cpp:12
    ^done,....
    (gdb)
    -break-insert a.cpp:5
    ^done,....
    (gdb)
    -exec-run
    ^running
    (gdb)
    *stopped,reason="breakpoint-hit",.....
    (gdb)
    -var-create TEST * &i
    ^done,name="TEST",numchild="1",type="int *"
    (gdb)
    -exec-continue
    ^running
    (gdb)
    *stopped,reason="breakpoint-hit",.......
    (gdb)
    -var-update *
    ^done,changelist=[]
    (gdb)

The value of "&i" changes, but -var-update does not report this. This can be
explained by the fact that varobjs are "bound" to the stack frame where
they were created, but that "binding" is not mentioned in documentation.

The problem I'm trying to solve is this:
1. In some frame, I create varobj for 'i'.
2. After continue, I see that there's local variable 'i', and I want to find
out if previously-created varobj can be used to show this local 'i', or if
I should create new 'i'.

   - I can't use frame ids because gdb only prints code address, and two    
     different stack frames can have the same code address.
   - I can't use -var-update, because it does not seem to report anything
   - I can't use -var-update on variable addresses, because of the above
     report

So, the only solution is to remove all varobjs, and create them afresh,
which is contrary to the very purpose of varobjs.

Can somebody suggest the right fix? So far, I think that the simplest
approach is to make gdb print stack address of current frame, like is done
on the Apple branch:

     553^done,stack=[frame= 
     {level="0",addr="0x00003db0",fp="0xbffff2c0",......

That way, frontend can deal with the issue of frame stacks themself, and
-var-update will be only used when single-stepping inside a given frame.
Will patches to implement this be welcome?

And I still don't know what to do about variable shadowing inside a single
function.

- Volodya



             reply	other threads:[~2006-04-12 12:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-12 16:02 Vladimir Prus [this message]
2006-04-12 18:25 ` Jim Ingham
2006-04-13  9:25   ` Vladimir Prus
2006-04-13 17:31     ` Jim Ingham
2006-04-14 13:25   ` Daniel Jacobowitz
2006-04-14 20:03     ` Jim Ingham
2006-04-14 20:09       ` Daniel Jacobowitz
2006-04-14 20:27         ` Jim Ingham
2006-04-14 21:37           ` Daniel Jacobowitz
2006-04-17  6:18             ` Vladimir Prus
2006-04-17  9:02               ` Mark Kettenis
2006-04-17 10:54                 ` Vladimir Prus
2006-05-02 12:50       ` Vladimir Prus
2006-05-02 13:14         ` Nick Roberts
2006-05-02 13:41           ` Vladimir Prus
2006-05-02 17:23             ` Jim Ingham
2006-05-03  6:03               ` Vladimir Prus
     [not found]                 ` <20060504145046.GA32605@nevyn.them.org>
2006-05-04 15:12                   ` Vladimir Prus
2006-05-04 15:13                     ` Daniel Jacobowitz
2006-05-05  6:25                   ` Vladimir Prus
2006-05-05 15:02                     ` Daniel Jacobowitz
2006-04-16 15:52     ` Nick Roberts

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='e1iqcl$2k4$1@sea.gmane.org' \
    --to=ghost@cs.msu.su \
    --cc=gdb@sources.redhat.com \
    /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