This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: struct/class members using mi interface
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Alistair Leslie-Hughes <leslie_alistair at hotmail dot com>
- Cc: gdb at sourceware dot org
- Date: Thu, 21 Jul 2011 06:35:32 +0200
- Subject: Re: struct/class members using mi interface
- References: <SNT105-DS1110B4AACA27BE5D418168934C0@phx.gbl>
On Wed, 20 Jul 2011 08:24:45 +0200, Alistair Leslie-Hughes wrote:
> Using the mi interface, is there a way to retrieve all the member
> variables of a class/struct?
yes, for samples one can check/run gdb/testsuite/gdb.mi/*.exp (first part
below) or I also sniffed Eclipse CDT communication by setting its gdb command
to a script (second part below).
Regards,
Jan
-var-create var1 * a
^done,name="var1",numchild="3",value="{...}",type="A",thread-id="1",has_more="0"
-var-list-children var1
^done,numchild="3",children=[child={name="var1.public",exp="public",numchild="2",thread-id="1"},child={name="var1.private",exp="private",numchild="2",thread-id="1"},child={name="var1.protected",exp="protected",numchild="2",thread-id="1"}],has_more="0"
-var-list-children var1.public
^done,numchild="2",children=[child={name="var1.public.x",exp="x",numchild="0",type="int",thread-id="1"},child={name="var1.public.buffer",exp="buffer",numchild="10",type="char
[10]",thread-id="1"}],has_more="0"
-var-list-children var1.private
^done,numchild="2",children=[child={name="var1.private.u",exp="u",numchild="0",type="int",thread-id="1"},child={name="var1.private.z",exp="z",numchild="0",type="float",thread-id="1"}],has_more="0"
-var-list-children var1.protected
^done,numchild="2",children=[child={name="var1.protected.y",exp="y",numchild="0",type="int",thread-id="1"},child={name="var1.protected.b",exp="b",numchild="2",type="B",thread-id="1"}],has_more="0"
-var-list-children var1.protected.b
^done,numchild="2",children=[child={name="var1.protected.b.public",exp="public",numchild="2",thread-id="1"},child={name="var1.protected.b.private",exp="private",numchild="1",thread-id="1"}],has_more="0"
------------------------------------------------------------------------------
#! /bin/sh
TMP=/tmp
if [ -d $TMP/server ];then
TMP=$TMP/server
fi
DIR=$TMP/gdb.d
mkdir -p $DIR
i=0
while true;do
FILE=$DIR/`printf %02d $i`
if ! test -f $FILE;then
break
fi
i=$[$i+1]
done
tee $FILE.in | "$0"-orig "$@" | tee $FILE.out