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


>>>>> "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

Whoops, this seems to be undocumented.

Tom


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