This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Reloading pretty-printers
- From: Jean-Marc Saffroy <saffroy at gmail dot com>
- To: 🐝 <epilys at nessuent dot xyz>
- Cc: gdb at sourceware dot org
- Date: Sun, 19 May 2019 21:23:37 +0200
- Subject: Re: Reloading pretty-printers
- References: <rr5fv.n5kdjc343gd@nessuent.xyz>
Hi,
On Sun, May 19, 2019 at 3:00 PM 🐝 <epilys@nessuent.xyz> wrote:
> Hello,
>
> I'm writing some pretty-printers for a codebase, and when I modify the
> python files with gdb running, I can't seem to use the new version.
> giving `source $GDBINIT` or `source $PRETTYPRINTERDOTPY` gives
> `pretty-printer already registered`
>
> Is there a solution to this other than restarting gdb?
>
When I faced the same problem, I found it useful to simply generate a
random name when registering the pretty printer:
def _build_pretty_printer():
> # hack: random name allows reloading in the same gdb session!
> pp = gdb.printing.RegexpCollectionPrettyPrinter(
> "xxx.%d"%(random.randint(0, 1000000)))
> pp.add_printer('BIGNUM', '^bignum_st$', BNPrinter)
> return pp
>
> gdb.printing.register_pretty_printer(
> gdb.current_objfile(),
> _build_pretty_printer())
>
>
Cheers,
JM
--
Jean-Marc Saffroy - saffroy@gmail.com