Problem redefining python pretty printers
Robert Lupton the Good
rhl@astro.princeton.edu
Sun May 22 01:41:00 GMT 2011
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
More information about the Gdb
mailing list