From: "Elmenthaler, Jens" <jens.elmenthaler@verigy.com>
To: <tromey@redhat.com>
Cc: <gdb@sourceware.org>
Subject: RE: Python pretty printers and dynamic cast
Date: Tue, 22 Dec 2009 08:15:00 -0000 [thread overview]
Message-ID: <58596C4646708B4BB990C44839973330017EFAE8@usplmvpbe001.ent.rt.verigy.net> (raw)
In-Reply-To: <m3skd0pzeh.fsf@fleche.redhat.com>
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 happy (and this applies to the python pretty printing facility in general!): http://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 out 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 value 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 current 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 printers like the one described above clean.
To those of you who celebrate Christmas - merry Christmas and enjoy your holidays. Jens.
-----Original Message-----
From: Tom Tromey [mailto:tromey@redhat.com]
Sent: Freitag, 30. Oktober 2009 18:25
To: Elmenthaler, Jens
Cc: gdb@sourceware.org
Subject: Re: Python pretty printers and dynamic cast
>>>>> "Jens" == Elmenthaler, Jens <jens.elmenthaler@verigy.com> 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
next prev parent reply other threads:[~2009-12-22 8:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-15 14:50 simulator for sparc64? Joel Sherrill
2009-10-28 10:20 ` Doug Evans
2009-10-28 12:58 ` Joel Sherrill
2009-10-28 13:59 ` Jakob Engblom
2009-10-29 0:28 ` Joel Sherrill
2009-10-30 17:25 ` Python pretty printers and dynamic cast Elmenthaler, Jens
2009-10-30 17:51 ` Tom Tromey
2009-12-22 8:15 ` Elmenthaler, Jens [this message]
2010-01-05 15:34 ` Tom Tromey
2010-01-07 8:55 ` Elmenthaler, Jens
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=58596C4646708B4BB990C44839973330017EFAE8@usplmvpbe001.ent.rt.verigy.net \
--to=jens.elmenthaler@verigy.com \
--cc=gdb@sourceware.org \
--cc=tromey@redhat.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