This is the mail archive of the gdb@sourceware.org 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: GDB/MI - var-update/create BUG


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


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