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: container_of equivalent in gdb-python script


Tom Tromey wrote:
>>>>>> "Jan" == Jan Kiszka <jan.kiszka@web.de> writes:
> 
> Daniel> It's typical to do this the same way folks do in C: Create a null
> Daniel> pointer of the right type.
> 
> Jan> You can't do that with the current upstream python interface, but the
> Jan> parse_and_eval solves this nicely.
> 
> Actually, for constants you can:
> 
> (gdb) python print gdb.Value(0)
> 0
> (gdb) python print type(gdb.Value(0))
> <type 'gdb.Value'>
> (gdb) python print gdb.Value(0).cast(gdb.lookup_type('char').pointer())
> 0x0

Yeah, seen this (in the testsuite). But such objects neither have
addresses, nor do they help with non-constant objects I'm interested in.

> 
> Whoops, this seems to be undocumented.

Not the only piece... :)

Jan

Attachment: signature.asc
Description: OpenPGP digital signature


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