From: Niko Sams <niko.sams@gmail.com>
To: gdb <gdb@sourceware.org>
Subject: Re: Modify address of a gdb.Value
Date: Wed, 17 Jun 2009 15:52:00 -0000 [thread overview]
Message-ID: <629542d40906170852x60559910ud1f9b90a5069191b@mail.gmail.com> (raw)
In-Reply-To: <629542d40906162251v4a4723f3l9423eec5998d0ee6@mail.gmail.com>
On Wed, Jun 17, 2009 at 07:51, Niko Sams<niko.sams@gmail.com> wrote:
>> 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?
Ok, here comes my hacky workaround. Tested on amd64 only.
def payload (self):
#we can't use QMapPayloadNode as it's never instanciated and so gcc
#doesn't include it in debug information.
#as a workaround take the sum of sizeof(members)
ret = self.ktype.sizeof
ret += self.vtype.sizeof
ret += gdb.lookup_type('void').pointer().sizeof
#but because of data alignment the value can be higher
#so guess it's aliged by sizeof(void*)
#TODO: find a real solution for this problem
ret += ret % gdb.lookup_type('void').pointer().sizeof
ret -= gdb.lookup_type('void').pointer().sizeof
return ret
Any better idea?
next prev parent reply other threads:[~2009-06-17 15:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-15 6:22 Niko Sams
2009-06-15 16:43 ` Tom Tromey
2009-06-15 17:05 ` Vladimir Prus
2009-06-15 17:33 ` Paul Pluzhnikov
2009-06-15 19:27 ` Tom Tromey
2009-06-17 5:51 ` Niko Sams
2009-06-17 15:52 ` Niko Sams [this message]
2009-06-17 16:21 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=629542d40906170852x60559910ud1f9b90a5069191b@mail.gmail.com \
--to=niko.sams@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox