container_of equivalent in gdb-python script

Tom Tromey tromey@redhat.com
Wed Jun 10 20:37:00 GMT 2009


>>>>> "Jan" == Jan Kiszka <jan.kiszka@web.de> writes:

Jan> I meanwhile discovered (reading testcases and python-*.c)
Jan> gdb.lookup_type() and Value.cast() to make this real. But you see, I
Jan> still need an ugly synthetic Value object which must have a non-'None'
Jan> address to do this calculation. Is there a cleaner, more generic way?

Yeah, I think the missing piece is "gdb.parse_and_eval", which is on
the archer python branch, but which we haven't pushed upstream into
gdb CVS yet.  This takes an expression (a string), parses it,
evaluates it, and returns a Value.  It is very convenient when
implementing your own gdb commands.

I don't think there's any particular problem with submitting this,
just somebody finding the time.

Tom



More information about the Gdb mailing list