From: Klaus Rudolph <lts-rudolph@gmx.de>
To: gdb@sourceware.org
Subject: Re: automated cast to different data type possible?
Date: Sun, 15 May 2011 14:17:00 -0000 [thread overview]
Message-ID: <4DCFE110.4000703@gmx.de> (raw)
In-Reply-To: <201105121913.12475.andre.poenitz@nokia.com>
André Pönitz wrote:
>
> Assuming that I understood the task correctly it can be done with
> gdb python scripting nevertheless.
>
> Given
>
> struct KRBase
> {
> enum Type { TYPE_A, TYPE_B } type;
> KRBase(Type _type) : type(_type) {}
> };
>
> struct KRA : KRBase { int x, y; KRA() : KRBase(TYPE_A), x(1), y(32) {} };
> struct KRB : KRBase { KRB() : KRBase(TYPE_B) {} };
>
> void testKR()
> {
> KRBase *ptr1 = new KRA;
> KRBase *ptr2 = new KRB;
> break_here();
> }
>
> creating a display of
>
> ptr1 @0x809a9d0 KRA
> KRBase KRA
> x 1 int
> y 32 int
> ptr2 @0x809a9e0 KRB
> KRBase KRB
>
> takes three lines of python code:
>
> def qdump__KRBase(d, item):
> base = ["KRA", "KRB"][int(item.value["type"])]
> d.putItem(Item(item.value.cast(lookupType(base)), item.iname))
>
> [using, admittedly, the *cough* "other" approach to pretty printing]
Sorry,
please give me an idea who is calling qdump_KRBase and what is parameter
d? I actually have no idea how to add that to the printer script... or
maybe any other python script to gdb.
Thanks
Klaus
next prev parent reply other threads:[~2011-05-15 14:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-11 9:09 Klaus Rudolph
2011-05-11 21:00 ` Tom Tromey
2011-05-12 6:17 ` Klaus Rudolph
2011-05-12 16:06 ` Tom Tromey
2011-05-12 17:13 ` André Pönitz
2011-05-15 14:17 ` Klaus Rudolph [this message]
2011-05-16 11:43 ` André Pönitz
2011-05-16 17:15 ` Klaus Rudolph
2011-05-24 13:48 ` André Pönitz
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=4DCFE110.4000703@gmx.de \
--to=lts-rudolph@gmx.de \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).