This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Modify address of a gdb.Value
- From: Tom Tromey <tromey at redhat dot com>
- To: Niko Sams <niko dot sams at gmail dot com>
- Cc: gdb at sourceware dot org
- Date: Mon, 15 Jun 2009 10:43:31 -0600
- Subject: Re: Modify address of a gdb.Value
- References: <629542d40906142322h733ad7ffr3d6daeb7b306ff7a@mail.gmail.com>
- Reply-to: tromey at redhat dot com
>>>>> "Niko" == Niko Sams <niko.sams@gmail.com> writes:
Niko> I'm trying to write a pretty-printer for Qt QMap using python.
Niko> QMap uses the following code:
Niko> static inline Node *concrete(QMapData::Node *node) {
Niko> return reinterpret_cast<Node *>(reinterpret_cast<char *>(node) - payload());
Niko> }
Niko> How can I do such an operation with gdb.Value?
Nobody has implemented inferior function calls using Value yet.
So the payload() part is not implementable.
If you know what it returns, or you can compute it in Python, then
this is no big deal. You can use Value.cast to cast to some other
type, then do pointer math.
newval = (val.cast(Type('char').pointer()) - payload).cast(val.type)
libstdc++ uses a similar implementation trick in some places, those
printers already do this kind of thing.
Tom