From: Vladislav Ivanishin <vlad@ispras.ru>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] make gdbhooks.py idempotent with respect to reloading
Date: Fri, 28 Jun 2019 11:52:00 -0000 [thread overview]
Message-ID: <87h88ac4fl.fsf@ispras.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 610 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-make-gdbhooks.py-idempotent-with-respect-to-reloadin.patch --]
[-- Type: text/x-patch, Size: 599 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
OK?
BTW, perhaps I should also add a convenience function for 'import imp;
imp.reload(gdbhooks)' or something to that effect?
--
Vlad
next reply other threads:[~2019-06-28 11:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 11:52 Vladislav Ivanishin [this message]
2019-07-02 22:39 ` Vladislav Ivanishin
2019-07-23 14:23 ` [committed] " Vladislav Ivanishin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h88ac4fl.fsf@ispras.ru \
--to=vlad@ispras.ru \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).