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


>  newval = (val.cast(Type('char').pointer()) - payload).cast(val.type)
that is working, thanks.


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

I tried to implement this payload method in python, the c++ code is
the following:
template <class Key, class T>
struct QMapPayloadNode
{
    Key key;
    T value;
    QMapData::Node *backward;
};
static inline int payload() {
    return sizeof(PayloadNode) - sizeof(QMapData::Node *);
}

the obvious solution would be gdb.lookup_type('QMapPayloadNode<%s,
%s>' % (self.ktype, self.vtype)).sizeof
but that doesn't work, i get this error:
RuntimeError: No type named QMapPayloadNode<int, QString *>
This is because that QMapPayloadNode is not instanciated, it's only
used for this sizeof.

So any idea how i can compute the payload?

Niko


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