Modify address of a gdb.Value
Tom Tromey
tromey@redhat.com
Mon Jun 15 16:43:00 GMT 2009
>>>>> "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
More information about the Gdb
mailing list