* Pretty Printing
@ 2013-02-01 9:22 Graham Labdon
2013-02-01 17:48 ` Doug Evans
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Graham Labdon @ 2013-02-01 9:22 UTC (permalink / raw)
To: gdb
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
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Pretty Printing
2013-02-01 9:22 Pretty Printing Graham Labdon
@ 2013-02-01 17:48 ` Doug Evans
2013-02-01 20:11 ` Pedro Alves
2013-02-04 12:25 ` Joachim Protze
2 siblings, 0 replies; 4+ messages in thread
From: Doug Evans @ 2013-02-01 17:48 UTC (permalink / raw)
To: Graham Labdon; +Cc: gdb
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Pretty Printing
2013-02-01 9:22 Pretty Printing Graham Labdon
2013-02-01 17:48 ` Doug Evans
@ 2013-02-01 20:11 ` Pedro Alves
2013-02-04 12:25 ` Joachim Protze
2 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2013-02-01 20:11 UTC (permalink / raw)
To: Graham Labdon; +Cc: gdb
On 02/01/2013 09:22 AM, Graham Labdon 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)
>
I was pretty sure I heard people had pretty printers for Qt already.
Were they in kdevelop? Ah, yes:
http://nikosams.blogspot.pt/2010/01/gdb-qt-pretty-printers-updated.html
Did you look there?
--
Pedro Alves
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Pretty Printing
2013-02-01 9:22 Pretty Printing Graham Labdon
2013-02-01 17:48 ` Doug Evans
2013-02-01 20:11 ` Pedro Alves
@ 2013-02-04 12:25 ` Joachim Protze
2 siblings, 0 replies; 4+ messages in thread
From: Joachim Protze @ 2013-02-04 12:25 UTC (permalink / raw)
To: Graham Labdon; +Cc: gdb
[-- Attachment #1: Type: text/plain, Size: 360 bytes --]
Hi,
On 01.02.2013 10:22, Graham Labdon wrote:
> Code:
> exp = "((class QFile *)%s)->%s()" % (value.address, "exists")
>
try
exp = "((class QFile *)%i)->%s()" % (long(value.address), "exists")
or
exp = "((class QFile *)0x%x)->%s()" % (long(value.address), "exists")
To print the address and not trigger the pretty printer
- Joachim
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5319 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-04 12:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-01 9:22 Pretty Printing Graham Labdon
2013-02-01 17:48 ` Doug Evans
2013-02-01 20:11 ` Pedro Alves
2013-02-04 12:25 ` Joachim Protze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox