From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35079 invoked by alias); 23 Jul 2019 14:06:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 35058 invoked by uid 89); 23 Jul 2019 14:06:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=locate, H*F:D*ru X-HELO: mail.ispras.ru Received: from mail.ispras.ru (HELO mail.ispras.ru) (83.149.199.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Jul 2019 14:06:53 +0000 Received: from vlad-optiplex (pluton2.ispras.ru [83.149.199.44]) by mail.ispras.ru (Postfix) with ESMTPSA id C05BA54006A; Tue, 23 Jul 2019 17:06:50 +0300 (MSK) From: Vladislav Ivanishin To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed] Re: [PATCH] make gdbhooks.py idempotent with respect to reloading References: <87h88ac4fl.fsf@ispras.ru> <87ftnodpt0.fsf@ispras.ru> Date: Tue, 23 Jul 2019 14:23:00 -0000 In-Reply-To: <87ftnodpt0.fsf@ispras.ru> (Vladislav Ivanishin's message of "Wed, 03 Jul 2019 01:39:23 +0300") Message-ID: <87d0i0kfph.fsf_-_@ispras.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2019-07/txt/msg01520.txt.bz2 Vladislav Ivanishin writes: > 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? > > [PATCH] gdbinit.in: add reload-gdbhooks (rh) command > > gcc/ > * gdbinit.in (reload-gdbhooks): New command with an attached doc string. > (rh): New alias for it. > --- > gcc/gdbinit.in | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in > index cec55f86749..2454441f859 100644 > --- a/gcc/gdbinit.in > +++ b/gcc/gdbinit.in > @@ -216,6 +216,16 @@ is emitted (as opposed to those warnings that are suppressed by > command-line options). > end > > +define reload-gdbhooks > +python import imp; imp.reload(gdbhooks) > +end > + > +document reload-gdbhooks > +Load the gdbhooks.py module again in order to pick up any changes made to it. > +end > + > +alias rh = reload-gdbhooks > + > # Define some macros helpful to gdb when it is expanding macros. > macro define __FILE__ "gdb" > macro define __LINE__ 1 Committed both patches as obvious, revisions 273737 and 273738 respectively. -- Vlad