Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Niko Sams <niko.sams@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: Modify address of a gdb.Value
Date: Mon, 15 Jun 2009 16:43:00 -0000	[thread overview]
Message-ID: <m3prd55txo.fsf@fleche.redhat.com> (raw)
In-Reply-To: <629542d40906142322h733ad7ffr3d6daeb7b306ff7a@mail.gmail.com> (Niko Sams's message of "Mon\, 15 Jun 2009 08\:22\:25 +0200")

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


  reply	other threads:[~2009-06-15 16:43 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 [this message]
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
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=m3prd55txo.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=niko.sams@gmail.com \
    /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