public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Reloading pretty-printers
@ 2019-05-19 19:23 🐝
  2019-05-20 14:57 ` Jean-Marc Saffroy
  0 siblings, 1 reply; 2+ messages in thread
From: 🐝 @ 2019-05-19 19:23 UTC (permalink / raw)
  To: gdb

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?

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

* Re: Reloading pretty-printers
  2019-05-19 19:23 Reloading pretty-printers 🐝
@ 2019-05-20 14:57 ` Jean-Marc Saffroy
  0 siblings, 0 replies; 2+ messages in thread
From: Jean-Marc Saffroy @ 2019-05-20 14:57 UTC (permalink / raw)
  To: 🐝; +Cc: gdb

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

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

end of thread, other threads:[~2019-05-19 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-19 19:23 Reloading pretty-printers 🐝
2019-05-20 14:57 ` Jean-Marc Saffroy

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