This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: container_of equivalent in gdb-python script
- From: Tom Tromey <tromey at redhat dot com>
- To: Jan Kiszka <jan dot kiszka at siemens dot com>
- Cc: gdb at sourceware dot org
- Date: Wed, 10 Jun 2009 12:57:11 -0600
- Subject: Re: container_of equivalent in gdb-python script
- References: <4A2FE5AB.4060707@siemens.com>
- Reply-to: tromey at redhat dot com
>>>>> "Jan" == Jan Kiszka <jan.kiszka@siemens.com> writes:
Jan> I'm at the point where I would apply a standard container_of()
Jan> macro in C: convert the list entry into a gdb.Value that
Jan> describes the containing object.
Jan> Of course, I can implement container_of as a gdb expression, print the
Jan> result and drag it in via gdb.history(). Done that already, basically
Jan> works. But it is fairly ugly as the print output will flood the screen.
I would say that the usual approach would be to reimplement the macro
in Python. The Python Value API is reasonably robust and can usually
be used for this. If you post the macro definition maybe I could help
with that. More details wouldn't hurt, either... are you writing a
pretty-printer? A new command? A convenience function?
Tom