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

On Wed, Oct 27, 2010 at 7:03 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> 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,

As you can see from the my signature I am coming from the IDE point-of-view.

> normally you want to track that
> _variable_, not that _name_. Anywhere you are.
>
Not really, thats depends on what you are trying to achieve - since
variable object were designed to ease the task of the IDE, then I say
this is incorrect (at least to me).
In my case, I actually never want to track 'variable object' I want to
track 'expressions' in the code.

In codelite IDE, there are 3 main views which use the 'Variable Objects':
- The Locals view
- Watches (user adds expressions)
- The debugger tooltip (codelite uses a tree form tree which suits
perfectly with the variable object concept)

As for the 'Locals' view, I would expect the variable-object to
present the values based on the expression used during the creation of
the variable object, otherwise it does not make any sense of putting
it in the Locals view in the first place.

For the 'watches' view (which are more of a 'persistent' entries) it
make sense to use the scope of creation - but this is also debatable.
I am currently using floating variable object in the watches view and
it seems "natural" to me

The tooltip - well its nature is a transient window, so it does not
really matter - since the variable object is destroyed as soon as the
tool tip is dismissed.

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

Already did and it is working as expected

>
> 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 \""
>



-- 
Eran Ifrah
Cross platform, open source C++ IDE: http://www.codelite.org


  reply	other threads:[~2010-10-27 17:18 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
2010-10-27 17:18   ` Eran Ifrah [this message]
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='AANLkTikcYt5WRD-Nz+K5OfuaviT31VVWFofzQV=yRsuf@mail.gmail.com' \
    --to=eran.ifrah@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=jan.kratochvil@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