From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26625 invoked by alias); 15 Jun 2009 16:43:48 -0000 Received: (qmail 26615 invoked by uid 22791); 15 Jun 2009 16:43:47 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_54,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Jun 2009 16:43:36 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5FGhY2P025091; Mon, 15 Jun 2009 12:43:34 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5FGhWcj010726; Mon, 15 Jun 2009 12:43:33 -0400 Received: from opsy.redhat.com (vpn-13-64.rdu.redhat.com [10.11.13.64]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5FGhWkh003105; Mon, 15 Jun 2009 12:43:32 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 7C4CD3784BE; Mon, 15 Jun 2009 10:43:31 -0600 (MDT) To: Niko Sams Cc: gdb@sourceware.org Subject: Re: Modify address of a gdb.Value References: <629542d40906142322h733ad7ffr3d6daeb7b306ff7a@mail.gmail.com> From: Tom Tromey Reply-To: tromey@redhat.com Date: Mon, 15 Jun 2009 16:43:00 -0000 In-Reply-To: <629542d40906142322h733ad7ffr3d6daeb7b306ff7a@mail.gmail.com> (Niko Sams's message of "Mon\, 15 Jun 2009 08\:22\:25 +0200") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-06/txt/msg00147.txt.bz2 >>>>> "Niko" == Niko Sams 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(reinterpret_cast(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