Message ID | 20240827140021.32660-6-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 3E600384AB44 for <patchwork@sourceware.org>; Tue, 27 Aug 2024 14:00:16 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 0AC04385DDE0 for <gdb-patches@sourceware.org>; Tue, 27 Aug 2024 13:59:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0AC04385DDE0 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 0AC04385DDE0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724767160; cv=none; b=lXGWfic/KzkhiKxvtD0w2HWJxsyhU4qMFmnpdRcebiaszruooMCLTyjXyFCUf5aDPzmdQcrLSQDyneL4BORXI9BL+8dtyRlds7KjSYCpDHgr4odRBI7ta7nvBLAQwd/6YQJ/3o7s6s1MWuzZgHI+cU8f430ghYNoaJF3Vmelfto= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724767160; c=relaxed/simple; bh=wohSyLvmPaeA+yC1o7y8J0wg02pzyuVfdGDhJ9OOAc4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=TBVG7V9mugL1rHOcOdaiq8wFybZiKDJSqUWp6DhmNBJ3TXQCEfcCjV2rJq7v9fQZpG5rpHGKMIwBAiYQ4Xw84G1oWlS5qgbGPoIWIX0k65aIXdYdcP62TyjGwuAPgUbEizIFXDL8zPCdmbdUq+XLJ2Ws3w2kte9O096LGft6vPM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 160C821B16 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=CDMwXNE/nFiObeqQ3b/iztcPcBCTISLyOmsrKIazq+c=; b=bYRQD1ZCDwVoWnswBEga9CtBvKfThLy41h2PRaMj6y7cqfN3VSdu/yhaIWcMoNohxINZt0 QsNZ4Rc0jjAkPEnyGKZnIh34ZunpZG4LMz5XzihlNScCeYprXIa7Ws8MrGCV3A6qSULAKf p5sSEwgGjxJaxhfH+Dul+AsL39hzmQQ= 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=CDMwXNE/nFiObeqQ3b/iztcPcBCTISLyOmsrKIazq+c=; b=Z9gh9aIzFbaDeqb4wLRrc1Vj3Q5dX754SfBKq8CZV42IcDXd8zhqrD8Bx5DSH7t51TpM+0 N4iEvKnRYYHQdmBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=bYRQD1ZC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Z9gh9aIz 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=CDMwXNE/nFiObeqQ3b/iztcPcBCTISLyOmsrKIazq+c=; b=bYRQD1ZCDwVoWnswBEga9CtBvKfThLy41h2PRaMj6y7cqfN3VSdu/yhaIWcMoNohxINZt0 QsNZ4Rc0jjAkPEnyGKZnIh34ZunpZG4LMz5XzihlNScCeYprXIa7Ws8MrGCV3A6qSULAKf p5sSEwgGjxJaxhfH+Dul+AsL39hzmQQ= 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=CDMwXNE/nFiObeqQ3b/iztcPcBCTISLyOmsrKIazq+c=; b=Z9gh9aIzFbaDeqb4wLRrc1Vj3Q5dX754SfBKq8CZV42IcDXd8zhqrD8Bx5DSH7t51TpM+0 N4iEvKnRYYHQdmBA== 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 EF55413A44 for <gdb-patches@sourceware.org>; Tue, 27 Aug 2024 13:59:15 +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 4N/FOLPbzWbvBgAAD6G6ig (envelope-from <tdevries@suse.de>) for <gdb-patches@sourceware.org>; Tue, 27 Aug 2024 13:59:15 +0000 From: Tom de Vries <tdevries@suse.de> To: gdb-patches@sourceware.org Subject: [PATCH 6/7] [gdb] Handle ^C in ~scoped_remote_fd Date: Tue, 27 Aug 2024 16:00:20 +0200 Message-Id: <20240827140021.32660-6-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-Rspamd-Queue-Id: 160C821B16 X-Spam-Score: -5.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_DN_NONE(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns, imap1.dmz-prg2.suse.org:helo, suse.de:mid, suse.de:dkim] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: 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: ... try { fileio_error remote_errno; m_remote->remote_hostio_close (m_fd, &remote_errno); } catch (...) { /* Swallow exception before it escapes the dtor. If something goes wrong, likely the connection is gone, and there's nothing else that can be done. */ } ... This also swallows gdb_exception_quit and gdb_exception_forced_quit. I don't know whether these can actually happen here, but if not it's better to accommodate for the possibility anyway. Fix this by handling gdb_exception explicitly, and setting the quit flag if necessary. It could be that "catch (...)" should be replaced by "catch (const gdb_exception &)" but that depends on what kind of exception remote_hostio_close is expected to throw, and I don't know that, so I'm leaving it as is. Tested on aarch64-linux. --- gdb/remote.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
Comments
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> This also swallows gdb_exception_quit and gdb_exception_forced_quit. I don't
Tom> know whether these can actually happen here, but if not it's better to
Tom> accommodate for the possibility anyway.
Yeah, it's generally hard to know without digging pretty depp.
Tom> Fix this by handling gdb_exception explicitly, and setting the quit flag if
Tom> necessary.
Tom> It could be that "catch (...)" should be replaced by
Tom> "catch (const gdb_exception &)" but that depends on what kind of exception
Tom> remote_hostio_close is expected to throw, and I don't know that, so I'm
Tom> leaving it as is.
I think this is an improvement but while reading it I was left wondering
if it does the right thing for a forced quit.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
On 9/23/24 19:53, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: > > Tom> This also swallows gdb_exception_quit and gdb_exception_forced_quit. I don't > Tom> know whether these can actually happen here, but if not it's better to > Tom> accommodate for the possibility anyway. > > Yeah, it's generally hard to know without digging pretty depp. > > Tom> Fix this by handling gdb_exception explicitly, and setting the quit flag if > Tom> necessary. > > Tom> It could be that "catch (...)" should be replaced by > Tom> "catch (const gdb_exception &)" but that depends on what kind of exception > Tom> remote_hostio_close is expected to throw, and I don't know that, so I'm > Tom> leaving it as is. > > I think this is an improvement but while reading it I was left wondering > if it does the right thing for a forced quit. > Good point. I grepped for set_forced_quit_flag and found ~scoped_switch_fork_info, which has an identical problem, so I've updated the patch by just copying the solution from there: ... catch (const gdb_exception_quit &ex) { /* We can't throw from a destructor, so re-set the quit flag for later QUIT checking. */ set_quit_flag (); } catch (const gdb_exception_forced_quit &ex) { /* Like above, but (eventually) cause GDB to terminate by setting sync_quit_force_run. */ set_force_quit_flag (); } ... > Approved-By: Tom Tromey <tom@tromey.com> Thank for the review, pushed with that change. Thanks, - Tom
diff --git a/gdb/remote.c b/gdb/remote.c index 2c3988cb507..7cf26321b98 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -13237,6 +13237,16 @@ class scoped_remote_fd fileio_error remote_errno; m_remote->remote_hostio_close (m_fd, &remote_errno); } + catch (const gdb_exception &e) + { + if (e.reason != RETURN_ERROR) + { + /* Try to propagate gdb_exception_quit and + gdb_exception_forced_quit. We can't rethrow, so do the + next best thing. */ + set_quit_flag (); + } + } catch (...) { /* Swallow exception before it escapes the dtor. If