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: MI: variable objects: children naming


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




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