From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id C37313858D28 for ; Sun, 27 Feb 2022 00:01:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C37313858D28 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-635-_Onf593TMdmsDyAqHF9NQA-1; Sat, 26 Feb 2022 19:01:44 -0500 X-MC-Unique: _Onf593TMdmsDyAqHF9NQA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48C1E1006AA5; Sun, 27 Feb 2022 00:01:43 +0000 (UTC) Received: from f35-1.lan (unknown [10.2.16.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E37A5E26C; Sun, 27 Feb 2022 00:01:42 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH v3 5/7] Guile QUIT processing updates Date: Sat, 26 Feb 2022 17:00:49 -0700 Message-Id: <20220227000051.3336149-6-kevinb@redhat.com> In-Reply-To: <20220227000051.3336149-1-kevinb@redhat.com> References: <20220227000051.3336149-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FROM_FMBLA_NEWDOM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Feb 2022 00:01:50 -0000 This commit contains QUIT processing updates for GDB's Guile support. As with the Python updates, we don't want to permit this code to swallow the exception, gdb_exception_forced_quit, which is associated with GDB receiving a SIGTERM. I've adopted the same solution that I used for Python; whereever a gdb_exception is caught in try/catch code in the Guile extension language support, a catch for gdb_exception_forced_quit has been added; this catch block will simply call quit_force(), which will cause the necessary cleanups to occur followed by GDB exiting. --- gdb/guile/guile-internal.h | 5 +++++ gdb/guile/scm-pretty-print.c | 5 +++++ gdb/guile/scm-type.c | 5 +++++ gdb/guile/scm-value.c | 5 +++++ gdb/top.h | 2 +- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h index 28e4889bfa9..965a965b1a7 100644 --- a/gdb/guile/guile-internal.h +++ b/gdb/guile/guile-internal.h @@ -28,6 +28,7 @@ #include "extension-priv.h" #include "symtab.h" #include "libguile.h" +#include "top.h" /* For quit_force(). */ struct block; struct frame_info; @@ -712,6 +713,10 @@ gdbscm_wrap (Function &&func, Args &&... args) { result = func (std::forward (args)...); } + catch (const gdb_exception_forced_quit &e) + { + quit_force (NULL, 0); + } catch (const gdb_exception &except) { exc = unpack (except); diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index c64e8346938..8eded5b6176 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -21,6 +21,7 @@ conventions, et.al. */ #include "defs.h" +#include "top.h" /* For quit_force(). */ #include "charset.h" #include "symtab.h" /* Needed by language.h. */ #include "language.h" @@ -558,6 +559,10 @@ ppscm_pretty_print_one_value (SCM printer, struct value **out_value, (_("invalid result from pretty-printer to-string"), result); } } + catch (const gdb_exception_forced_quit &except) + { + quit_force (NULL, 0); + } catch (const gdb_exception &except) { } diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 27d00f12a95..3e6a36cf6cd 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -21,6 +21,7 @@ conventions, et.al. */ #include "defs.h" +#include "top.h" /* For quit_force(). */ #include "arch-utils.h" #include "value.h" #include "gdbtypes.h" @@ -112,6 +113,10 @@ tyscm_type_name (struct type *type) &type_print_raw_options); return stb.release (); } + catch (const gdb_exception_forced_quit &except) + { + quit_force (NULL, 0); + } catch (const gdb_exception &except) { excp = gdbscm_scm_from_gdb_exception (unpack (except)); diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 1c88a3add34..6c42a3dc967 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -21,6 +21,7 @@ conventions, et.al. */ #include "defs.h" +#include "top.h" /* For quit_force(). */ #include "arch-utils.h" #include "charset.h" #include "cp-abi.h" @@ -416,6 +417,10 @@ gdbscm_value_address (SCM self) { address = vlscm_scm_from_value (value_addr (value)); } + catch (const gdb_exception_forced_quit &except) + { + quit_force (NULL, 0); + } catch (const gdb_exception &except) { } diff --git a/gdb/top.h b/gdb/top.h index b26209e8c8d..3ea31a3858a 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -234,7 +234,7 @@ extern void read_command_file (FILE *); extern void init_history (void); extern void command_loop (void); extern int quit_confirm (void); -extern void quit_force (int *, int); +extern void quit_force (int *, int) ATTRIBUTE_NORETURN; extern void quit_command (const char *, int); extern void quit_cover (void); extern void execute_command (const char *, int); -- 2.35.1