Vladislav Ivanishin writes: > Hi! > > It is nice to be able to reload the pretty printers and convenience > functions from gdbhooks.py without exiting GDB: reloading cc1 takes > several seconds (plus, the debugging session is lost). > > Previously: > > (gdb) python import imp; imp.reload(gdbhooks); > RuntimeError: pretty-printer already registered: gcc > > Fixing this turned out easier than I expected. > (gdb) py help (gdb.printing) > revealed, that we can pass replace parameter to register_pretty_printer > (which is False by default). > > With the patch: > > (gdb) python import imp; imp.reload(gdbhooks); > Successfully loaded GDB hooks for GCC > > gcc/ > > * gdbhooks.py: Pass replace=True to > gdb.printing.register_pretty_printer. > --- > gcc/gdbhooks.py | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py > index 15a5ceaa56f..26a09749aa3 100644 > --- a/gcc/gdbhooks.py > +++ b/gcc/gdbhooks.py > @@ -602,7 +602,8 @@ def build_pretty_printer(): > > gdb.printing.register_pretty_printer( > gdb.current_objfile(), > - build_pretty_printer()) > + build_pretty_printer(), > + replace=True) > > def find_gcc_source_dir(): > # Use location of global "g" to locate the source tree > -- > 2.22.0 > > > OK? I actually think, that change is obvious. It has proven useful and I've not run into any issues with it. > BTW, perhaps I should also add a convenience function for 'import imp; > imp.reload(gdbhooks)' or something to that effect? I added a user-defined gdb command and a short alias for it. I think, this is obvious too, but would feel more comfortable if someone OKs it. Dave?