From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6HvgATlpv2PY+hQAWB0awg (envelope-from ) for ; Wed, 11 Jan 2023 20:58:17 -0500 Received: by simark.ca (Postfix, from userid 112) id 056ED1E128; Wed, 11 Jan 2023 20:58:17 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=noC0jbkV; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B766F1E0D3 for ; Wed, 11 Jan 2023 20:58:16 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C025138493CB for ; Thu, 12 Jan 2023 01:58:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C025138493CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673488693; 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=noC0jbkV7KmRFH7b4Hev08GzR2xjJr2reNikXy2gsLDGXbc5dxCTg/RuRxf3PatAg 4OlvBtMtbnhO2xaZX6bxGFrBaOgI4F1yiv3/8OWOnKPsjqVH4IO8jjkvqHAr211sMn dRdVBq6Pi0PEpln30ECpsiIflS3wsUVpiMlC9El0= 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 ; 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 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-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: , From: Kevin Buettner via Gdb-patches Reply-To: Kevin Buettner Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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(+) 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); -- 2.34.3