MI command -stack-list-locals
Jason Molenda
jmolenda@apple.com
Fri Nov 14 00:19:00 GMT 2003
Hi Nick, sorry for the late reply.
On Nov 6, 2003, at 2:04 PM, Nick Roberts wrote:
> This can be a nuisance
> with large arrays or structures and I would like to extend
> -stack-list-locals
> to do the following:
>
> 1) Display the name and value for simple data types.
> 2) Display the name and type for complex data types.
>
> e.g with the local variables:
>
> int i, m[10];
> struct {
> int j;
> int k;
> } values;
>
> the output for "-stack-list-locals 2", say, would be:
>
> ^done,locals=[{name="i",value="5"},
> {name="m",type="int [10]"}
> {name="values",type="struct {...}"}]
We've been handling many of the same issues here at Apple for the past
few years. Jim's the real expert in regard to our varobj
modifications, but here's a quick example that might be helpful for
your problem.
We've added a "2" version of -stack-list-locals which prints out a lot
more information, as well as automatically creates varobj's for all of
the local variables. On the above example, we output
-stack-list-locals 2
^done,locals=[
varobj={exp="i",value="5",name="var1",numchild="0",type="int",typecode="
INT",dynamic_type="",in_scope="true",block_start_addr="0x00001dd0",block
_end_addr="0x00001e04"},
varobj={exp="m",value="[-1]",name="var2",numchild="10",type="int
[10]",typecode="ARRAY",dynamic_type="",in_scope="true",block_start_addr=
"0x00001dd0",block_end_addr="0x00001e04"},
varobj={exp="values",value="{...}",name="var3",numchild="2",type="struct
{...}",typecode="STRUCT",dynamic_type="",in_scope="true",block_start_add
r="0x00001dd0",block_end_addr="0x00001e04"}
],time={wallclock="0.00179",user="0.01000",system="0.00000",start="10687
68005.990265",end="1068768005.992059"}
I inserted some newlines to make it more readable; of course it's all
on one line in the real output.
The type of the variable is in the TYPE field; the TYPECODE field is a
general description for the IDE -- it is the string representation of
the TYPE_CODE of the varobj (e.g. PTR, ARRAY, STRUCT, ENUM, INT, FLT,
etc.) which gives the UI an easy way to tell how it should be
represented to the user.
IN_SCOPE works correctly with our gdb.
DYNAMIC_TYPE is to represent when a varobj is pointer to a C++ class
that may point to classes higher up the inheritance tree so the UI can
keep its display up to date as the type changes.
Oh, and the TIME thing at the end is just a little performance monitor
deal we use internally when we're hunting for slow-downs between the UI
and gdb; that doesn't have anything to do with the varobj's.
Jason
More information about the Gdb
mailing list