Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jim Ingham <jingham@apple.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: Vladimir Prus <ghost@cs.msu.su>, gdb@sources.redhat.com
Subject: Re: MI: variable objects: children naming
Date: Fri, 17 Mar 2006 19:42:00 -0000	[thread overview]
Message-ID: <599D7E80-BDC1-4F68-92C8-544EDFB65F7E@apple.com> (raw)
In-Reply-To: <20060317170701.GA15128@nevyn.them.org>

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




  reply	other threads:[~2006-03-17 18:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-17 14:56 Vladimir Prus
2006-03-17 17:23 ` Daniel Jacobowitz
2006-03-17 19:42   ` Jim Ingham [this message]
2006-03-20 23:11   ` Vladimir Prus

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=599D7E80-BDC1-4F68-92C8-544EDFB65F7E@apple.com \
    --to=jingham@apple.com \
    --cc=drow@false.org \
    --cc=gdb@sources.redhat.com \
    --cc=ghost@cs.msu.su \
    /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