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 BBFB7385559A for ; Thu, 12 Jan 2023 01:57:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBFB7385559A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673488639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LGuB103ZCdO9RzI59ThJRC5h+jdj0L0asmCG6GkWEiQ=; b=cmyAneEgl67KibW1Hcf/yIei6i4Sd2f/fRES0WnqUriW7/s0XQZOYuvJYljm93GlHbCMCS HZHYYRHZjOORROTIMgYr0AF9a3J9w2zXW/yD+Fb/1nM/oPn5tsZFMWS0KkUdfTACxhlysg Ana/wttbczr8nozIi3wZMAZCsy0xx24= 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) From: Kevin Buettner 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-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 List-Id: 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