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: Modify address of a gdb.Value


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


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