Message ID | 20230112015630.32999-7-kevinb@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> 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 7D974385B51B for <patchwork@sourceware.org>; Thu, 12 Jan 2023 01:58:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D974385B51B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673488697; bh=LGuB103ZCdO9RzI59ThJRC5h+jdj0L0asmCG6GkWEiQ=; 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=CnjHj+2CMeAbM3J3wSdoIuf1U8gMtyllXhNCAxtdS1+s5NMmaQhly2bs8sjZaJCuy 8hWUemZup1Cly2oUiC4GfbLxFTaDULPl+tMtB3EaDV17XQ6ZF0EEc9KIadF9aKSb2B aicE5Q1hA9VhA1DfwtUChTIqZzXn6z6XcX46IY6M= 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 BBFB7385559A for <gdb-patches@sourceware.org>; Thu, 12 Jan 2023 01:57:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBFB7385559A Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-323-B8ChzFgmP--a68W4HbGI2g-1; Wed, 11 Jan 2023 20:57:13 -0500 X-MC-Unique: B8ChzFgmP--a68W4HbGI2g-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 713B4882824; Thu, 12 Jan 2023 01:57:13 +0000 (UTC) Received: from f34-1.lan (unknown [10.2.17.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF513492C14; Thu, 12 Jan 2023 01:57:12 +0000 (UTC) To: gdb-patches@sourceware.org Cc: pedro@palves.net, simark@simark.ca, tdevries@suse.de, Kevin Buettner <kevinb@redhat.com> Subject: [PATCH v4 6/8] Call quit_force for gdb_exception_forced_quit in safe_execute_command Date: Wed, 11 Jan 2023 18:56:28 -0700 Message-Id: <20230112015630.32999-7-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.6 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 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 <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Kevin Buettner via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Kevin Buettner <kevinb@redhat.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Fix gdb.base/gdb-sigterm.exp failure/error
|
|
Commit Message
Kevin Buettner
Jan. 12, 2023, 1:56 a.m. UTC
In gdb/cli/cli-interp.c, safe_execute_command catches gdb_exception. In the previous series, I had changed it to instead catch gdb_exception_error, which would allow gdb_exception_quit and gdb_exception_forced_quit to not be caught, thus propagating as normal. Pedro found some problems with doing this for safe_execute_command. See: https://sourceware.org/pipermail/gdb-patches/2022-March/186320.html Pedro suggested: "Maybe we can just eliminate safe_execute_command and let exceptions propagate normally." I'm not doing that here, though I think it might be worth trying. Instead, what I've done is to catch gdb_exception_forced_quit and, when caught, call quit_force() thus forcing GDB to terminate. After (re)reading Pedro's remarks, I think there's still a problem with this area of the code (in which gdb_exception_quit is turned into an error in interpreter_exec_cmd), but that problem existed before this patch series and I think that fully addressing it should be the subject of a different set of patches. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26761 --- gdb/cli/cli-interp.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
Comments
On 2023-01-12 1:56 a.m., Kevin Buettner wrote: > In gdb/cli/cli-interp.c, safe_execute_command catches gdb_exception. > In the previous series, I had changed it to instead catch > gdb_exception_error, which would allow gdb_exception_quit and > gdb_exception_forced_quit to not be caught, thus propagating as > normal. > > Pedro found some problems with doing this for safe_execute_command. > See: > > https://sourceware.org/pipermail/gdb-patches/2022-March/186320.html > > Pedro suggested: "Maybe we can just eliminate safe_execute_command and > let exceptions propagate normally." > > I'm not doing that here, though I think it might be worth trying. > > Instead, what I've done is to catch gdb_exception_forced_quit and, > when caught, call quit_force() thus forcing GDB to terminate. > > After (re)reading Pedro's remarks, I think there's still a problem > with this area of the code (in which gdb_exception_quit is turned into > an error in interpreter_exec_cmd), but that problem existed before this > patch series and I think that fully addressing it should be the > subject of a different set of patches. > I sent a patch implementing my suggestion, here: https://inbox.sourceware.org/gdb-patches/20230127230545.77750-1-pedro@palves.net/ I think that when that goes in, this patch can be dropped. Pedro Alves > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26761 > --- > gdb/cli/cli-interp.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c > index 5f2ff726f26..066e55b64f1 100644 > --- a/gdb/cli/cli-interp.c > +++ b/gdb/cli/cli-interp.c > @@ -353,6 +353,17 @@ safe_execute_command (struct ui_out *command_uiout, const char *command, > { > execute_command (command, from_tty); > } > + catch (gdb_exception_forced_quit &exception) > + { > + /* Due to the way that the cli_inter::exec is structured, it is > + not safe to only catch gdb_exception_error below, thus > + allowing quit exceptions to propagate through. (The CLI > + stream won't be reset as it should be.) So, for > + gdb_exception_forced_quit, which corresponds to GDB having > + received a SIGTERM signal, call quit_force() here which will > + cause GDB to terminate. */ > + quit_force (NULL, 0); > + } > catch (gdb_exception &exception) > { > e = std::move (exception); >
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 5f2ff726f26..066e55b64f1 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -353,6 +353,17 @@ safe_execute_command (struct ui_out *command_uiout, const char *command, { execute_command (command, from_tty); } + catch (gdb_exception_forced_quit &exception) + { + /* Due to the way that the cli_inter::exec is structured, it is + not safe to only catch gdb_exception_error below, thus + allowing quit exceptions to propagate through. (The CLI + stream won't be reset as it should be.) So, for + gdb_exception_forced_quit, which corresponds to GDB having + received a SIGTERM signal, call quit_force() here which will + cause GDB to terminate. */ + quit_force (NULL, 0); + } catch (gdb_exception &exception) { e = std::move (exception);