Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Eran Ifrah <eran.ifrah@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: GDB/MI - var-update/create BUG
Date: Wed, 27 Oct 2010 17:28:00 -0000	[thread overview]
Message-ID: <20101027170327.GA11455@host1.dyn.jankratochvil.net> (raw)
In-Reply-To: <AANLkTinUo3LMBBmDWPm_jp2md3Xzi=06NBf2qJ2S6NF2@mail.gmail.com>

On Tue, 26 Oct 2010 18:01:30 -0400, Eran Ifrah wrote:
> If I have a local variable with the same name in different scopes,
> when switching between the scopes the content of the variable object
> does not reflect the new variable.

This is correct from the GDB's point of view, normally you want to track that
_variable_, not that _name_. Anywhere you are.

You should use '@' instead of '*' for frame if you want to track it by name,
see "floating" in: info '(gdb)GDB/MI Variable Objects'


Thanks,
Jan


g++ -o 2 2.C -Wall -g
gdb -nx -i=mi <2.cmd ./2

==> 2.C <==
#include <string>
void foo() {
        std::string mystr = " second value ";
        mystr += " appended content";
}
int main(int argc, char **argv) {
       	std::string mystr = " first value ";
       	foo();
        mystr += " appended content";
        return 0;
}

==> 2.cmd <==
-break-insert -t 8
-exec-run
-var-create - * mystr._M_dataplus._M_p
-break-insert -t 4
-exec-continue
-var-update *
-var-evaluate-expression "var1"

->
^done,value="0x601028 \" first value \""

==> 2-floating.cmd <==
-break-insert -t 8
-exec-run
-var-create - @ mystr._M_dataplus._M_p
-break-insert -t 4
-exec-continue
-var-update *
-var-evaluate-expression "var1"

->
^done,value="0x601058 \" second value \""


  parent reply	other threads:[~2010-10-27 17:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-26 22:02 Eran Ifrah
2010-10-27  7:50 ` Andrew Burgess
2010-10-27  8:09   ` Eran Ifrah
2010-10-27 17:28 ` Jan Kratochvil [this message]
2010-10-27 17:18   ` Eran Ifrah
2010-10-27 17:31     ` Robert Dewar

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=20101027170327.GA11455@host1.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=eran.ifrah@gmail.com \
    --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