public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* struct/class members using mi interface
@ 2011-07-20 10:13 Alistair Leslie-Hughes
  2011-07-21  4:36 ` Jan Kratochvil
  2011-07-21 13:55 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Alistair Leslie-Hughes @ 2011-07-20 10:13 UTC (permalink / raw)
  To: gdb

Hi,

Using the mi interface, is there a way to retrieve all the member variables 
of a class/struct?

Best Regards
 Alistair Leslie-Hughes
 

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

* Re: struct/class members using mi interface
  2011-07-20 10:13 struct/class members using mi interface Alistair Leslie-Hughes
@ 2011-07-21  4:36 ` Jan Kratochvil
  2011-07-21 13:55 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2011-07-21  4:36 UTC (permalink / raw)
  To: Alistair Leslie-Hughes; +Cc: gdb

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

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

* Re: struct/class members using mi interface
  2011-07-20 10:13 struct/class members using mi interface Alistair Leslie-Hughes
  2011-07-21  4:36 ` Jan Kratochvil
@ 2011-07-21 13:55 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2011-07-21 13:55 UTC (permalink / raw)
  To: Alistair Leslie-Hughes; +Cc: gdb

>>>>> "Alistair" == Alistair Leslie-Hughes <leslie_alistair@hotmail.com> writes:

Alistair> Using the mi interface, is there a way to retrieve all the member
Alistair> variables of a class/struct?

You can see all the members of an instance using varobj.

I don't think there is a way to query types and get a structured result.
I think it would be a good addition.

Tom

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

end of thread, other threads:[~2011-07-21 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-20 10:13 struct/class members using mi interface Alistair Leslie-Hughes
2011-07-21  4:36 ` Jan Kratochvil
2011-07-21 13:55 ` Tom Tromey

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).