This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reloading pretty-printers


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]