container_of equivalent in gdb-python script
Tom Tromey
tromey@redhat.com
Wed Jun 10 18:57:00 GMT 2009
>>>>> "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
More information about the Gdb
mailing list