From patchwork Thu Jan 12 01:56:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 62996 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0DF438493F6 for ; Thu, 12 Jan 2023 01:58:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0DF438493F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673488735; bh=17hoIFvqTcH8F8PW5XAaAP0vAcOUtLAekcBTXkDVTwE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ujoTCkFTU9r9LAhyt/R9jRABsp5EJBLZSvhk0+0vw4j8RkOGDmr7f4+b+kmkC9nNf /kBoovu8tkDyyEAmcqkBToYUOVsbwUSQifIR7Q/x0sqhl4TOdO6JBvJTSN5g7ELpbn mOuqgxGY+ISiwu2W+U/PABhGuMx8CU0dSS11IjCQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 7D4E5385B51F for ; Thu, 12 Jan 2023 01:57:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D4E5385B51F Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-145-ppm30v4IMqiP1iFavExzXg-1; Wed, 11 Jan 2023 20:57:11 -0500 X-MC-Unique: ppm30v4IMqiP1iFavExzXg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6BFEA3C0252E; Thu, 12 Jan 2023 01:57:11 +0000 (UTC) Received: from f34-1.lan (unknown [10.2.17.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id B94D1492C14; Thu, 12 Jan 2023 01:57:10 +0000 (UTC) To: gdb-patches@sourceware.org Cc: pedro@palves.net, simark@simark.ca, tdevries@suse.de, Kevin Buettner Subject: [PATCH v4 5/8] Guile QUIT processing updates Date: Wed, 11 Jan 2023 18:56:27 -0700 Message-Id: <20230112015630.32999-6-kevinb@redhat.com> In-Reply-To: <20230112015630.32999-1-kevinb@redhat.com> References: <20230112015630.32999-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, URIBL_ABUSE_SURBL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Kevin Buettner via Gdb-patches From: Kevin Buettner Reply-To: Kevin Buettner Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26761 --- 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 42ecb3c24f9..b04ef17a5ad 100644 --- a/gdb/guile/guile-internal.h +++ b/gdb/guile/guile-internal.h @@ -29,6 +29,7 @@ #include "symtab.h" #include "libguile.h" #include "objfiles.h" +#include "top.h" /* For quit_force(). */ struct block; struct frame_info; @@ -704,6 +705,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 cb6677c8831..c618101bad8 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 da16d22990c..008e792cc34 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" @@ -132,6 +133,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 b9948303bc1..0b92b211df7 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 9f9a0281be4..5a1352ef81c 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -236,7 +236,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);