Message ID | 20240821114402.525-1-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 9545538654A2 for <patchwork@sourceware.org>; Wed, 21 Aug 2024 11:43:34 +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 949083857011 for <gdb-patches@sourceware.org>; Wed, 21 Aug 2024 11:43:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 949083857011 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 949083857011 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=1724240593; cv=none; b=k1L2nWAzB2RKgbFuWEp01puqHp7UxMfzZ+W2Z3cHlG75ZSoADDqCYfNOykjynUnZ/3zid4haaA604vkSGXpe1b/HA8XqOa4dCd3dcIFlhp7NsD9fLmAxbGTEI0ugaUgoFJhmz0qlnPuIbuiIVhO2q9+HgZioLI2Uf4yGIJIGfG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724240593; c=relaxed/simple; bh=hmYzUq1VwJ/nyPrbZP2uUJO1E9SFlriTDsGMpWX1a3o=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=mdL6xiZ8wGaevdIaLbuK9Dh6MwUh7p7QoShBWibD5NceHcZls5WFuNVAYe6vN0sNGAEMBorZOwwLYcsN9eDrDlqWv6w3ECO8lRcHkJeKTHX9qSU72WheN0glkJbSyEoogSi2qiW3S/iApmMt56JN70Jjhnvubtvvtxce4TLcE/I= 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 B471A1FDD4 for <gdb-patches@sourceware.org>; Wed, 21 Aug 2024 11:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724240591; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Jd/BBrTXQc5ml+e2+36G608EFGUxX/CydXxqXSdhL2g=; b=ZOOJQtxzUdqQJMVmaNaeeCIMmSYUbYm7UeH/UIuBazQEYYZx8ve51xVmm821FKkeJ1K80P 8xINqixNKtXSpcxiQJdHJjkrLo7iO0h2DOAjBgF2nTo+HgKfuQZQWi4eCVu8hVj7CJAR4B LcJAQ7efNEUdpfC0iqXmgrvJEB26G+M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724240591; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Jd/BBrTXQc5ml+e2+36G608EFGUxX/CydXxqXSdhL2g=; b=k9B+lak1zjckNJWI07DjqEJGpZAFimaLUDMAy7U7ThXQCrMTiXhe50IBz1j0p5rNXUIF3u XHvgK71tIsHvnTAw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724240591; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Jd/BBrTXQc5ml+e2+36G608EFGUxX/CydXxqXSdhL2g=; b=ZOOJQtxzUdqQJMVmaNaeeCIMmSYUbYm7UeH/UIuBazQEYYZx8ve51xVmm821FKkeJ1K80P 8xINqixNKtXSpcxiQJdHJjkrLo7iO0h2DOAjBgF2nTo+HgKfuQZQWi4eCVu8hVj7CJAR4B LcJAQ7efNEUdpfC0iqXmgrvJEB26G+M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724240591; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Jd/BBrTXQc5ml+e2+36G608EFGUxX/CydXxqXSdhL2g=; b=k9B+lak1zjckNJWI07DjqEJGpZAFimaLUDMAy7U7ThXQCrMTiXhe50IBz1j0p5rNXUIF3u XHvgK71tIsHvnTAw== 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 9C531139C2 for <gdb-patches@sourceware.org>; Wed, 21 Aug 2024 11:43:11 +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 cKmyJM/SxWbefQAAD6G6ig (envelope-from <tdevries@suse.de>) for <gdb-patches@sourceware.org>; Wed, 21 Aug 2024 11:43:11 +0000 From: Tom de Vries <tdevries@suse.de> To: gdb-patches@sourceware.org Subject: [PATCH] [gdb] Eliminate catch(...) in get_test_insn Date: Wed, 21 Aug 2024 13:44:02 +0200 Message-Id: <20240821114402.525-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.80 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]; TO_DN_NONE(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,imap1.dmz-prg2.suse.org:helo] 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 |
Eliminate catch(...) in get_test_insn
|
|
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. 21, 2024, 11:44 a.m. UTC
In get_test_insn in gdb/disasm-selftests.c, we find this code: ... try { kind = gdbarch_breakpoint_kind_from_pc (gdbarch, &pc); insn = gdbarch_sw_breakpoint_from_kind (gdbarch, kind, &bplen); } catch (...) { continue; } ... The catch is there to catch memory errors, but it swallows all exceptions, including gdb_exception_quit and gdb_exception_forced_quit. Fix this by limiting the catch to gdb_exception_error. Tested on x86_64-linux, by rebuilding and running gdb.gdb/unittest.exp. --- gdb/disasm-selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 28c3bf55f0f9aca8619c6d01be34a02a887c5577
Comments
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> The catch is there to catch memory errors, but it swallows all exceptions, including
Tom> gdb_exception_quit and gdb_exception_forced_quit.
Tom> Fix this by limiting the catch to gdb_exception_error.
Tom> Tested on x86_64-linux, by rebuilding and running gdb.gdb/unittest.exp.
Makes sense to me. Thanks for doing this... I suspect there's a number
of other spots that need a similar treatment.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
On 8/21/24 18:58, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: > > Tom> The catch is there to catch memory errors, but it swallows all exceptions, including > Tom> gdb_exception_quit and gdb_exception_forced_quit. > > Tom> Fix this by limiting the catch to gdb_exception_error. > > Tom> Tested on x86_64-linux, by rebuilding and running gdb.gdb/unittest.exp. > > Makes sense to me. Thanks for doing this... I suspect there's a number > of other spots that need a similar treatment. > Hi Tom, thanks for the review(s). After this and the type_to_type_object patch, there are these left: ... gdb/run-on-main-thread.c: catch (...) gdb/source-cache.c: catch (...) gdb/source-cache.c: catch (...) gdb/top.c: catch (...) gdb/target.c: catch (...) gdb/remote.c: catch (...) gdb/cli/cli-cmds.c: catch (...) gdbsupport/scope-exit.h: catch (...) ... I've looked them over, and spotted one case in source-cache.c that's also in a unit test, I'll try to fix that one as well. The other one in source-cache.c is a case of calling a function in an external library that may throw. The one in scope-exit, I think a rethrow is missing, I'll submit a patch for that one as well. The one in top.c, in execute_fn_to_string it looks it might be better rewritten in RAII style using a scope exit or some such, given that there's code duplication. Likewise for the one in target.c. The remote.c case is in a destructor. The cli-cmds.c is also a case of code duplication implementing finally functionality, but can't be easily rewritten in RAII style, I think. Anyway, it rethrows so it looks ok-ish to me. The one in run-on-main-thread.c silently swallows quit and forced_quit. I'm not sure yet if that's ok. Thanks, - Tom > Approved-By: Tom Tromey <tom@tromey.com> > > Tom
diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c index 14b7fb30bad..dd849fb1eb9 100644 --- a/gdb/disasm-selftests.c +++ b/gdb/disasm-selftests.c @@ -165,7 +165,7 @@ get_test_insn (struct gdbarch *gdbarch, size_t *len) kind = gdbarch_breakpoint_kind_from_pc (gdbarch, &pc); insn = gdbarch_sw_breakpoint_from_kind (gdbarch, kind, &bplen); } - catch (...) + catch (const gdb_exception_error &) { continue; }