From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20441 invoked by alias); 22 Dec 2009 08:15:09 -0000 Received: (qmail 20422 invoked by uid 22791); 22 Dec 2009 08:15:07 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_05,SPF_PASS X-Spam-Check-By: sourceware.org Received: from ahmler8.mail.eds.com (HELO ahmler8.mail.eds.com) (192.85.154.82) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Dec 2009 08:14:56 +0000 Received: from ahmlir1.mail.eds.com (ahmlir1-2.mail.eds.com [192.85.154.152]) by ahmler8.mail.eds.com (8.14.2/8.13.8) with ESMTP id nBM8EeB7020602; Tue, 22 Dec 2009 03:14:40 -0500 Received: from ahmlir1.mail.eds.com (localhost.localdomain [127.0.0.1]) by ahmlir1.mail.eds.com (8.14.2/8.12.10) with ESMTP id nBM8ESV3006048; Tue, 22 Dec 2009 03:14:28 -0500 Received: from usplmvpfe001.ent.rt.verigy.net ([192.100.40.4]) by ahmlir1.mail.eds.com (8.14.2/8.12.10) with ESMTP id nBM8ERBX006033; Tue, 22 Dec 2009 03:14:28 -0500 X-EDSINT-Source-Ip: 192.100.40.4 Received: from usplmvpbe001.ent.rt.verigy.net ([10.16.58.34]) by usplmvpfe001.ent.rt.verigy.net with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 02:14:27 -0600 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Python pretty printers and dynamic cast Date: Tue, 22 Dec 2009 08:15:00 -0000 Message-ID: <58596C4646708B4BB990C44839973330017EFAE8@usplmvpbe001.ent.rt.verigy.net> In-Reply-To: From: "Elmenthaler, Jens" To: Cc: X-IsSubscribed: yes 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-12/txt/msg00139.txt.bz2 Tom> There is nothing built-in yet. We've had a few requests for this, Tom> though, and there was a patch posted to the archer list. If you give = it Tom> a try, let us know how it turns out. I gave it a try. Unfortunately, the patch only provided the C++ style casts= on the gdb command line, not the python API. I got stuck figuring out how = to get the gdb command line called from within python. Nevertheless, another patch from the Archer mailing list made me really hap= py (and this applies to the python pretty printing facility in general!): h= ttp://sourceware.org/ml/archer/2009-q4/msg00013.html. This patch adds a rtti_type method to gdb.Value. In my case, I have a smart-pointer like class, i.e. it has just one member,= which is a pointer to some base interface. We have many derived interfaces= of that base interface, and we have at least one implementation of each of= those derived interfaces. I realized to find out the real implementation type of this pointer member = is the real value for debugging our code. The "set print object on" has no = effect on the MI interface, and thus out Eclipse CDT frontend does not show= the implementation type members when expanding this pointer member. I ended up having just one pretty printer with a children method figuring o= ut the implementation type of the pointer member via the rtti_type method. = I then use the normal cast method of the python API to (static) cast the va= lue to its implementation type and return this value. This isn't clean, but= didn't fail so far. So, my vote as a user looks something like this: Prio 1: commit this patch for the rtti_type method (I applied it to the cur= rent gdb 7.0 sources and was happy with it). ] Prio 2: also add the C++ style casts to improve gdb command line experience= for C++. Prio 3: provide the C++ style casts in the Python API to make pretty printe= rs like the one described above clean. To those of you who celebrate Christmas - merry Christmas and enjoy your ho= lidays. Jens. =20 -----Original Message----- From: Tom Tromey [mailto:tromey@redhat.com]=20 Sent: Freitag, 30. Oktober 2009 18:25 To: Elmenthaler, Jens Cc: gdb@sourceware.org Subject: Re: Python pretty printers and dynamic cast >>>>> "Jens" =3D=3D Elmenthaler, Jens writes: Jens> Is there any way for a python pretty printer to do (or 'mimic') a Jens> dynamic cast, such that I can show the members of the Jens> implementation type where ever I have the interface type? There is nothing built-in yet. We've had a few requests for this, though, and there was a patch posted to the archer list. If you give it a try, let us know how it turns out. Tom