public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Problem redefining python pretty printers
@ 2011-05-22  1:41 Robert Lupton the Good
  2011-05-23 15:06 ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Lupton the Good @ 2011-05-22  1:41 UTC (permalink / raw)
  To: gdb

Using the 7.2.90.20110521-cvs (i.e. 7.3-branch) version, the docs say:
> Help on function register_pretty_printer in module gdb.printing:
> 
> register_pretty_printer(obj, printer)
>     Register pretty-printer PRINTER with OBJ.
>     
>     The printer is added to the front of the search list, thus one can override
>     an existing printer if one needs to.

which makes sense if one's working on a new printer.  Unfortunately:

> (gdb) python import sourcePrinter; sourcePrinter.register(); sourcePrinter.register()
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "/home/rhl/Bugs/gdb-pp/sourcePrinter.py", line 35, in register
>     gdb.printing.register_pretty_printer(gdb, printer)
>   File "/home/astro/hsc/products/Linux64/external/gdb/7.3-1/share/gdb/python/gdb/printing.py", line 131, in register_pretty_printer
>     printer.name)
> RuntimeError: pretty-printer already registered: afw
> Error while executing Python code.

The routine register is:
> def register():
>     printer = gdb.printing.RegexpCollectionPrettyPrinter("afw")
>     gdb.printing.register_pretty_printer(gdb, printer)

Any advice on what I'm doing wrong?  I suppose I could come up with a new name each time, but that seems a little clumsy.

						R

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problem redefining python pretty printers
  2011-05-22  1:41 Problem redefining python pretty printers Robert Lupton the Good
@ 2011-05-23 15:06 ` Doug Evans
  2011-05-23 15:24   ` Phil Muldoon
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2011-05-23 15:06 UTC (permalink / raw)
  To: Robert Lupton the Good; +Cc: gdb

On Sat, May 21, 2011 at 6:41 PM, Robert Lupton the Good
<rhl@astro.princeton.edu> wrote:
> Using the 7.2.90.20110521-cvs (i.e. 7.3-branch) version, the docs say:
>> Help on function register_pretty_printer in module gdb.printing:
>>
>> register_pretty_printer(obj, printer)
>>     Register pretty-printer PRINTER with OBJ.
>>
>>     The printer is added to the front of the search list, thus one can override
>>     an existing printer if one needs to.
>
> which makes sense if one's working on a new printer.  Unfortunately:
>
>> (gdb) python import sourcePrinter; sourcePrinter.register(); sourcePrinter.register()
>> Traceback (most recent call last):
>>   File "<string>", line 1, in <module>
>>   File "/home/rhl/Bugs/gdb-pp/sourcePrinter.py", line 35, in register
>>     gdb.printing.register_pretty_printer(gdb, printer)
>>   File "/home/astro/hsc/products/Linux64/external/gdb/7.3-1/share/gdb/python/gdb/printing.py", line 131, in register_pretty_printer
>>     printer.name)
>> RuntimeError: pretty-printer already registered: afw
>> Error while executing Python code.
>
> The routine register is:
>> def register():
>>     printer = gdb.printing.RegexpCollectionPrettyPrinter("afw")
>>     gdb.printing.register_pretty_printer(gdb, printer)
>
> Any advice on what I'm doing wrong?  I suppose I could come up with a new name each time, but that seems a little clumsy.

You're not doing anything wrong, per se.
I think we need to handle this use-case though.
gdb could either provide a way to replace an existing pretty-printer
or delete it so that it can be re-added.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problem redefining python pretty printers
  2011-05-23 15:06 ` Doug Evans
@ 2011-05-23 15:24   ` Phil Muldoon
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Muldoon @ 2011-05-23 15:24 UTC (permalink / raw)
  To: Doug Evans; +Cc: Robert Lupton the Good, gdb

Doug Evans <dje@google.com> writes:

> On Sat, May 21, 2011 at 6:41 PM, Robert Lupton the Good
> <rhl@astro.princeton.edu> wrote:

>> The routine register is:
>>> def register():
>>>     printer = gdb.printing.RegexpCollectionPrettyPrinter("afw")
>>>     gdb.printing.register_pretty_printer(gdb, printer)
>>
>> Any advice on what I'm doing wrong?  I suppose I could come up with a new name each time, but that seems a little clumsy.
>
> You're not doing anything wrong, per se.
> I think we need to handle this use-case though.
> gdb could either provide a way to replace an existing pretty-printer
> or delete it so that it can be re-added.

I guess you could delete it from the (gdb) list directly by using the
Python list functions.  But that is hacky.  I agree on the specific
API. I can't remember seeing a bug for this. Is there one?

Cheers,

Phil

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-23 15:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-22  1:41 Problem redefining python pretty printers Robert Lupton the Good
2011-05-23 15:06 ` Doug Evans
2011-05-23 15:24   ` Phil Muldoon

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).