From: Doug Evans <dje@google.com>
To: Graham Labdon <Graham.Labdon@avalonsciences.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Pretty Printing
Date: Fri, 01 Feb 2013 17:48:00 -0000 [thread overview]
Message-ID: <CADPb22SMxhN_XcxqooWpq37A20uvOKehhED48PZmaxZCFEW8vQ@mail.gmail.com> (raw)
In-Reply-To: <DA78E044FB673F438F102FC52CA4A62C05574F9D@ASLUKEXSVR.avalonsciences.local>
On Fri, Feb 1, 2013 at 1:22 AM, Graham Labdon
<Graham.Labdon@avalonsciences.com> wrote:
> Hi
> I don't know if there is anyone on this forum who can help
>
> I am developing a set of gdb pretty printers for Qt
> A dictionary is built of the functions to call when a variable of a given type is detected
> Code:
> def build_dictionary ():
> pretty_printers_dict[re.compile ('^QFile$')] = lambda val:QFilePrinter(val,"false")
> pretty_printers_dict[re.compile ('^QFile \*$')] = lambda val: QFilePointerPrinter(val)
>
>
> Here I have declared handlers for the QFile and QFile * types
>
> In the QFile handler I have this code
> Code:
> exp = "((class QFile *)%s)->%s()" % (value.address, "exists")
>
>
> The problem is that this causes the handler for QFile * to be called which causes great problems
>
> If any Python guru knows how to overcome this I would appreciate it
Have you tried beginning with an existing pretty-printer that works?
Here are the pretty-printers for libstdc++:
http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/python/libstdcxx/v6/printers.py?revision=193573&view=markup
It's not clear what you're trying to do with "exp".
Secondly, it's bad practice for pretty-printers to run code on the
inferior (which appears to be what exp is for).
- won't work with core files
- the inferior (gdb parlance for the program you're debugging) may not
be in a good enough state to run the code
- if you're debugging a problem, that last thing you want is to
perturb inferior state
next prev parent reply other threads:[~2013-02-01 17:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-01 9:22 Graham Labdon
2013-02-01 17:48 ` Doug Evans [this message]
2013-02-01 20:11 ` Pedro Alves
2013-02-04 12:25 ` Joachim Protze
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=CADPb22SMxhN_XcxqooWpq37A20uvOKehhED48PZmaxZCFEW8vQ@mail.gmail.com \
--to=dje@google.com \
--cc=Graham.Labdon@avalonsciences.com \
--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