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: gdb python and 'complete'


Hi,

You could used the lookup_type method.
Something like:

type = gdb.lookup_type("MyClass")

and then iterate over the type.field() collection.
Take a look at section 23.2.2.5 of the GDB doc to see what is available in the Field object.


Regards,

Michel Metzger.


Jeroen Dobbelaere wrote:
Hi,

I am trying to create some helper commands using python with gdb-7.1.

One of the things I want to do, is to retrieve the members of a c++
class, do some filtering and
present the result in a nice way.

I tried doing this, by delegating part of the request to the
'complete' command, like in :

class ShowNiceRepresentation(gdb.Command):
...

   def retrieveFunctionSummary(self):
      member_list=gdb.execute("complete b 'MyClass::").split("\n")
      ....

Now, the 'complete' command is indeed retrieving all the member
functions, but it will output them in the terminal in stead of feeding
it back to 'member_list'.

Is there a way to redirect the output, so that the python program can
investigate it ?
Or is there a more appropriate way to access the members of a c++
class form within python ?

Greetings,

Jeroen Dobbelaere



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