public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* MI: variable objects: children naming
@ 2006-03-17 14:56 Vladimir Prus
  2006-03-17 17:23 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Prus @ 2006-03-17 14:56 UTC (permalink / raw)
  To: gdb


Hello!

I've trying to figure out if I should use variable objects in KDevelop, and
run into some issue.

Assume that 'm' is a variable of type array of something. Here's a sample
session:

    (gdb)
    -var-create TMP * m
    ^done,name="TMP",numchild="3",type="int [3]"
    (gdb)
    -var-list-children TMP
    ^done,numchild="3",children=[
        child={name="TMP.0",exp="0",numchild="0",type="int"},
        child={name="TMP.1",exp="1",numchild="0",type="int"},
        child={name="TMP.2",exp="2",numchild="0",type="int"}]


Suppose I display this to the user as a tree. If user selects first child of
"m" and wants to set watchpoint on it,  I need to know the full name of
first child of "m". In C++, that would be m[0]. 

However, the information gdb prints does not allow me to compute m[0]:

  - that name is not present anywhere in the output
  - I can't do it myself, because I don't know that 'm' is an
    array, at least without manually parsing the 'type' field.
  - Calling '-var-info-expression TMP.0' returns:
        ^done,lang="C++",exp="0"

It seems like Apple version has new command -var-info-path-expression, which
is not present in FSF version, and which supposedly will produce "m[0]".

Would it be good to port it? Any other suggestiions?

- Volodya














^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MI: variable objects: children naming
  2006-03-17 14:56 MI: variable objects: children naming Vladimir Prus
@ 2006-03-17 17:23 ` Daniel Jacobowitz
  2006-03-17 19:42   ` Jim Ingham
  2006-03-20 23:11   ` Vladimir Prus
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-03-17 17:23 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb

On Fri, Mar 17, 2006 at 04:20:07PM +0300, Vladimir Prus wrote:
>     (gdb)
>     -var-create TMP * m
>     ^done,name="TMP",numchild="3",type="int [3]"
>     (gdb)
>     -var-list-children TMP
>     ^done,numchild="3",children=[
>         child={name="TMP.0",exp="0",numchild="0",type="int"},
>         child={name="TMP.1",exp="1",numchild="0",type="int"},
>         child={name="TMP.2",exp="2",numchild="0",type="int"}]
> 
> 
> Suppose I display this to the user as a tree. If user selects first child of
> "m" and wants to set watchpoint on it,  I need to know the full name of
> first child of "m". In C++, that would be m[0]. 
> 
> However, the information gdb prints does not allow me to compute m[0]:

Is this the only thing you need the name for, or is it useful for other
purposes in the user interface too?  (Honest question - I have no
idea.)

If watchpoints are the only reason, then you could have a variant of a
watchpoint command which took a varobj.

>   - Calling '-var-info-expression TMP.0' returns:
>         ^done,lang="C++",exp="0"
> 
> It seems like Apple version has new command -var-info-path-expression, which
> is not present in FSF version, and which supposedly will produce "m[0]".

We'd have to ask Jim for the history, but why should we do this instead
of fixing -var-info-expression?  That behavior looks pretty wrong!

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MI: variable objects: children naming
  2006-03-17 17:23 ` Daniel Jacobowitz
@ 2006-03-17 19:42   ` Jim Ingham
  2006-03-20 23:11   ` Vladimir Prus
  1 sibling, 0 replies; 4+ messages in thread
From: Jim Ingham @ 2006-03-17 19:42 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Vladimir Prus, gdb

You need to two different things.

If you are displaying a variable tree, then you need just the name of  
the child in it's parent.  That's what the "exp" element is for.  I  
guess for the array, you could argue that the exp should be "[0]",  
not "0".  That might help you print it without the UI having to do  
any work.  I'm not sure why we didn't change this as well.  But in  
our version of gdb we also return the typecode, and the UI can use  
that to hint on how to print it.  So from Apple's gdb you would get  
(for int foo[3]):

-var-create - * foo
^done,name="var1",numchild="3",type="int  
[3]",typecode="ARRAY",dynamic_type="",in_scope="true",block_start_addr=" 
0x00002a80",block_end_addr="0x00002afc"
(gdb)
-var-list-children var1
^done,numchild="3",children={child= 
{name="var1.0",exp="0",numchild="0",type="int",typecode="INT",dynamic_ty 
pe=""},child= 
{name="var1.1",exp="1",numchild="0",type="int",typecode="INT",dynamic_ty 
pe=""},child= 
{name="var1.2",exp="2",numchild="0",type="int",typecode="INT",dynamic_ty 
pe=""}}

At other times, you need to take a child varobj and figure out what  
the full expression for it should be.  Note this can be non-trivial  
to cons up from just the names.  For instance, if you have a class  
that inherits from two other classes, each of which has the same  
named member, you have to cons up a moderately complex expression  
involving casts to get back from one of these child varobj's to an  
expression you can give gdb, and have it print the right value...

That's what the -var-info-path-expression is for.  We use it, for  
example, in the right-click menu on the variables view, where you can  
choose "Add to Expressions Window" or "View Memory", etc...

Jim


On Mar 17, 2006, at 9:07 AM, Daniel Jacobowitz wrote:

> On Fri, Mar 17, 2006 at 04:20:07PM +0300, Vladimir Prus wrote:
>>     (gdb)
>>     -var-create TMP * m
>>     ^done,name="TMP",numchild="3",type="int [3]"
>>     (gdb)
>>     -var-list-children TMP
>>     ^done,numchild="3",children=[
>>         child={name="TMP.0",exp="0",numchild="0",type="int"},
>>         child={name="TMP.1",exp="1",numchild="0",type="int"},
>>         child={name="TMP.2",exp="2",numchild="0",type="int"}]
>>
>>
>> Suppose I display this to the user as a tree. If user selects  
>> first child of
>> "m" and wants to set watchpoint on it,  I need to know the full  
>> name of
>> first child of "m". In C++, that would be m[0].
>>
>> However, the information gdb prints does not allow me to compute m 
>> [0]:
>
> Is this the only thing you need the name for, or is it useful for  
> other
> purposes in the user interface too?  (Honest question - I have no
> idea.)
>
> If watchpoints are the only reason, then you could have a variant of a
> watchpoint command which took a varobj.
>
>>   - Calling '-var-info-expression TMP.0' returns:
>>         ^done,lang="C++",exp="0"
>>
>> It seems like Apple version has new command -var-info-path- 
>> expression, which
>> is not present in FSF version, and which supposedly will produce "m 
>> [0]".
>
> We'd have to ask Jim for the history, but why should we do this  
> instead
> of fixing -var-info-expression?  That behavior looks pretty wrong!
>
> -- 
> Daniel Jacobowitz
> CodeSourcery

Jim Ingham
Apple Developer Tools



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MI: variable objects: children naming
  2006-03-17 17:23 ` Daniel Jacobowitz
  2006-03-17 19:42   ` Jim Ingham
@ 2006-03-20 23:11   ` Vladimir Prus
  1 sibling, 0 replies; 4+ messages in thread
From: Vladimir Prus @ 2006-03-20 23:11 UTC (permalink / raw)
  To: gdb

Daniel Jacobowitz wrote:

>> However, the information gdb prints does not allow me to compute m[0]:
> 
> Is this the only thing you need the name for, or is it useful for other
> purposes in the user interface too?  (Honest question - I have no
> idea.)
> 

Yes, there are other purposes. Say, if you right-click an item in variables
tree and select, in the popup menu, the "Remember" command, the current
value of the item will be shown in a separate area for future reference.
But we need to show the full name of the item there. It's only for user, and
we need full name there.

> If watchpoints are the only reason, then you could have a variant of a
> watchpoint command which took a varobj.
> 
>>   - Calling '-var-info-expression TMP.0' returns:
>>         ^done,lang="C++",exp="0"
>> 
>> It seems like Apple version has new command -var-info-path-expression,
>> which is not present in FSF version, and which supposedly will produce
>> "m[0]".
> 
> We'd have to ask Jim for the history, but why should we do this instead
> of fixing -var-info-expression?  That behavior looks pretty wrong!

Jim has explained this -- 'info-expression' is local name of an item
relative to the parent, while 'info-path-expression' is full name.

- Volodya

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-03-20  6:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-17 14:56 MI: variable objects: children naming Vladimir Prus
2006-03-17 17:23 ` Daniel Jacobowitz
2006-03-17 19:42   ` Jim Ingham
2006-03-20 23:11   ` Vladimir Prus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).