Message ID | 20240827140021.32660-7-tdevries@suse.de |
---|---|
State | Committed |
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 CC65C386075D for <patchwork@sourceware.org>; Tue, 27 Aug 2024 14:00:18 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 1A94B385EC31 for <gdb-patches@sourceware.org>; Tue, 27 Aug 2024 13:59:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A94B385EC31 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1A94B385EC31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724767161; cv=none; b=lflGP7isGl4cR6UMQQssRtAEvDlom7LtlAICM1bAp4ZEh+fvAGQaarauHh4Zdhu9IFrOZInRybgPb9YxzV9mFJDwWEO7yB2LivapVEWrtucRASoiiY82ozJwh3tCiNDxCyPSRjEneApCCO91tft1ZEuki1oErXGyIXuUNzuFauY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724767161; c=relaxed/simple; bh=9aC7XKOnxD3cdITodFQdVJUI+yknwHDc7FbehtjVlrI=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=vTz/IWeqWcxL9mfh/mBLbSJITJSMgpi1vlWR7gbcylNVoyVcqn6lja2D8gWTwLfTf5cJnXQEzMWb/qM/bDMjmCRHAbi3YeZHFez74ai0CL/OiygzGxf6olgwnuzGzhijZO0DX+L0vr1KeMn0E5ULpYIRPzGniPLl7fEYhG+qSt4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 34D021FB70 for <gdb-patches@sourceware.org>; Tue, 27 Aug 2024 13:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724767156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XzDfuTXdtUJZCWL7YLkRVIMV8DSmPPnzj8XuZgBhWwQ=; b=Tw1/yDJTH0PK9VCm3W/AEZP0dj7j1waWh8EM9F7q8K8WY9rEtjK2ipavw80rbkFugSLnEi 34g7ZfZGNhfxniBnuR72zSugkJ91Oq/v6XWV3TkWfk5SoEhMBgXOaBMtiM+IQgEiXV/pfG 67b9n/Kw43YDC5obPD7npYNcZSdHHLE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724767156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XzDfuTXdtUJZCWL7YLkRVIMV8DSmPPnzj8XuZgBhWwQ=; b=bG3YsoiVju9vm+cLty71oXF8mQftSFipbuzHVtcr5kjEF3FD0FcQoKUuNJnSoDC3/j8zSS KeJ37IcnxoeUe8Cw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724767156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XzDfuTXdtUJZCWL7YLkRVIMV8DSmPPnzj8XuZgBhWwQ=; b=Tw1/yDJTH0PK9VCm3W/AEZP0dj7j1waWh8EM9F7q8K8WY9rEtjK2ipavw80rbkFugSLnEi 34g7ZfZGNhfxniBnuR72zSugkJ91Oq/v6XWV3TkWfk5SoEhMBgXOaBMtiM+IQgEiXV/pfG 67b9n/Kw43YDC5obPD7npYNcZSdHHLE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724767156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XzDfuTXdtUJZCWL7YLkRVIMV8DSmPPnzj8XuZgBhWwQ=; b=bG3YsoiVju9vm+cLty71oXF8mQftSFipbuzHVtcr5kjEF3FD0FcQoKUuNJnSoDC3/j8zSS KeJ37IcnxoeUe8Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1D6E313A94 for <gdb-patches@sourceware.org>; Tue, 27 Aug 2024 13:59:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mOuABbTbzWbvBgAAD6G6ig (envelope-from <tdevries@suse.de>) for <gdb-patches@sourceware.org>; Tue, 27 Aug 2024 13:59:16 +0000 From: Tom de Vries <tdevries@suse.de> To: gdb-patches@sourceware.org Subject: [PATCH 7/7] [gdb] Handle SIGTERM in run_events Date: Tue, 27 Aug 2024 16:00:21 +0200 Message-Id: <20240827140021.32660-7-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240827140021.32660-1-tdevries@suse.de> References: <20240827140021.32660-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 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> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
Series | [1/7] Handle ^C in gnu_source_highlight_test | |
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | success | Build passed |
linaro-tcwg-bot/tcwg_gdb_build--master-arm | success | Build passed |
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 | success | Test passed |
Commit Message
Tom de Vries
Aug. 27, 2024, 2 p.m. UTC
While reviewing "catch (...)" uses I came across: ... for (auto &item : local) { try { item (); } catch (...) { /* Ignore exceptions in the callback. */ } } ... This means that when an item throws a gdb_exception_forced_quit, the exception is ignored and following items are executed. Fix this by handling gdb_exception_forced_quit explicity, and immediately rethrowing it. I wondered about ^C, and couldn't decide whether current behaviour is ok, so I left this alone, but I made the issue explicit in the source code. As for the "catch (...)", I think that it should let a non-gdb_exception propagate, so I've narrowed it to "catch (const gdb_exception &)". My rationale for this is as follows. There seem to be a few ways that "catch (...)" is allowed in gdb: - clean-up and rethrow (basically the SCOPE_EXIT pattern) - catch and handle an exception from a call into an external c++ library Since we're dealing with neither of those here, we remove the "catch (...)". Tested on aarch64-linux. --- gdb/run-on-main-thread.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
Comments
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> + catch (const gdb_exception_quit &e)
Tom> + {
Tom> + /* Should cancelation of a runnable event cancel the execution of
Tom> + the following one? The answer is not clear, so keep doing what
Tom> + we've done sofar: ignore this exception. */
Typo, "so far".
Maybe this should work differently in some cases, I'm not sure; but I
think right now DAP depends on QUIT working in these runnables.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
On 9/23/24 20:00, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: > > Tom> + catch (const gdb_exception_quit &e) > Tom> + { > Tom> + /* Should cancelation of a runnable event cancel the execution of > Tom> + the following one? The answer is not clear, so keep doing what > Tom> + we've done sofar: ignore this exception. */ > > Typo, "so far". > > Maybe this should work differently in some cases, I'm not sure; but I > think right now DAP depends on QUIT working in these runnables. > FWIW, I've done a test run with: ... diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c index a6213d4d85e..e6864600cbd 100644 --- a/gdb/run-on-main-thread.c +++ b/gdb/run-on-main-thread.c @@ -86,6 +86,7 @@ run_events (int error, gdb_client_data client_data) /* Should cancelation of a runnable event cancel the execution of the following one? The answer is not clear, so keep doing what we've done sofar: ignore this exception. */ + gdb_assert (false); } catch (const gdb_exception &) { ... and it didn't trigger once. > Approved-By: Tom Tromey <tom@tromey.com> Thanks for the review, pushed. - Tom
On 9/24/24 16:46, Tom de Vries wrote: > On 9/23/24 20:00, Tom Tromey wrote: >>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: >> >> Tom> + catch (const gdb_exception_quit &e) >> Tom> + { >> Tom> + /* Should cancelation of a runnable event cancel the >> execution of >> Tom> + the following one? The answer is not clear, so keep >> doing what >> Tom> + we've done sofar: ignore this exception. */ >> >> Typo, "so far". >> >> Maybe this should work differently in some cases, I'm not sure; but I >> think right now DAP depends on QUIT working in these runnables. >> > > FWIW, I've done a test run with: > ... > diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c > index a6213d4d85e..e6864600cbd 100644 > --- a/gdb/run-on-main-thread.c > +++ b/gdb/run-on-main-thread.c > @@ -86,6 +86,7 @@ run_events (int error, gdb_client_data client_data) > /* Should cancelation of a runnable event cancel the execution of > the following one? The answer is not clear, so keep doing what > we've done sofar: ignore this exception. */ > + gdb_assert (false); > } > catch (const gdb_exception &) > { > ... > and it didn't trigger once. > >> Approved-By: Tom Tromey <tom@tromey.com> > > Thanks for the review, pushed. And, I forgot to fix the typo you mentioned. There's one more spot that needs the same fix: ... gdb/symtab.c: /* Cust is best found sofar, save it. */ ... I've submitted a series that adds a spell checker based on a list I found at wikipedia ( https://sourceware.org/pipermail/gdb-patches/2024-September/211928.html ). That list doesn't contains "sofar->so far", but we could extend the functionality of the script by adding gdb/contrib/common-misspellings.txt and using that in addition. Thanks, - Tom
diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c index e30dabaff03..a6213d4d85e 100644 --- a/gdb/run-on-main-thread.c +++ b/gdb/run-on-main-thread.c @@ -74,7 +74,20 @@ run_events (int error, gdb_client_data client_data) { item (); } - catch (...) + catch (const gdb_exception_forced_quit &e) + { + /* GDB is terminating, so: + - make sure this is propagated, and + - no need to keep running things, so propagate immediately. */ + throw; + } + catch (const gdb_exception_quit &e) + { + /* Should cancelation of a runnable event cancel the execution of + the following one? The answer is not clear, so keep doing what + we've done sofar: ignore this exception. */ + } + catch (const gdb_exception &) { /* Ignore exceptions in the callback. */ }