From patchwork Tue Oct 25 11:19:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 59389 Return-Path: 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 184BD3856976 for ; Tue, 25 Oct 2022 11:20:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 184BD3856976 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666696842; bh=lvCaadagjjVDb6HrDQ68sPM4UiRQpnvJArtUkbDaah4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=JLzU8KGq9E8O7Tks/9Hu9ZjbtLOcSY8hmTu5Yn1Q1I9wqRhSP1z8P4cZXftbYI55H kmivlAbfhScSlXnlUa7Qt+0nsNQFgetczFuT4ooxAP+h1qX0uHBii/J4o4iHTtWBNE 5eM2MZpEl3H9UARrlznW/AbRPmA9qR3YPPJf1L0A= 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.220.29]) by sourceware.org (Postfix) with ESMTPS id 19D0D3857434 for ; Tue, 25 Oct 2022 11:19:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 19D0D3857434 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 058231F88E for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E6A2313A79 for ; Tue, 25 Oct 2022 11:19:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sL5AN1HGV2O1dAAAMHmgww (envelope-from ) for ; Tue, 25 Oct 2022 11:19:45 +0000 To: gdb-patches@sourceware.org Subject: [RFC 1/5] [gdb] Catch gdb_exception_quit in munmap_list::~munmap_list Date: Tue, 25 Oct 2022 13:19:41 +0200 Message-Id: <20221025111945.23886-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221025111945.23886-1-tdevries@suse.de> References: <20221025111945.23886-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 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 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I tried out adding this exception slicing detection code in munmap_list::~munmap_list () in gdb/compile/compile-object-load.c: ... try { ... } catch (const gdb_exception_error &ex) { /* There's not much the user can do, so just ignore this. */ } + catch (const gdb_exception_quit &ex) + { + throw; + } + catch (const gdb_exception &ex) + { + gdb_assert (0); + } ... and ran into: ... gdb/compile/compile-object-load.c: In destructor ‘munmap_list::~munmap_list()’: gdb/compile/compile-object-load.c:64:4: error: \ throw will always call terminate() [-Werror=terminate] throw; ^~~~~ gdb/compile/compile-object-load.c:64:4: note: \ in C++11 destructors default to noexcept ... This raises the question of how a gdb_exception_quit should be handled in the destructor. Currently it's handled implicitly, and will result in std::terminate, which in absense of a std::set_terminate should call abort, after printing the type of the current exception, in other words gdb_exception_quit. We have a couple of choices to handle this explicitly: - std::terminate (no change in behaviour), - gdb_assert (false) (also calls abort, but with more info), or - ignore (as we do for gdb_exception_error) It seems to me that a gdb_exception_quit should not cause an abort, so handle explicitly by ignoring: ... - catch (const gdb_exception_error &ex) + catch (const gdb_exception &ex) ... Tested on x86_64-linux (though I don't have a setup with libcc1). --- gdb/compile/compile-object-load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index 4c94ec53899..ca58775880b 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -54,7 +54,7 @@ munmap_list::~munmap_list () { gdbarch_infcall_munmap (target_gdbarch (), item.addr, item.size); } - catch (const gdb_exception_error &ex) + catch (const gdb_exception &ex) { /* There's not much the user can do, so just ignore this. */ From patchwork Tue Oct 25 11:19:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 59386 Return-Path: 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 4C0F43856DE5 for ; Tue, 25 Oct 2022 11:20:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C0F43856DE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666696813; bh=m3Lqp19CFKF3QG5fTwclA/UIqirXLTSzsiXMmAhfhCc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=G8bPvmeLg04n21BxssZKWyGV/vItdgJMCyeLxmseaktzFS83/iLnziG5Y8ls6017W TGNLslNd04xQjIIB0dUWJ5YFiSFctZlsUMEOlng2r01F7Ene4CIxQ/ZD8JenXRAR5v Ku9k1vs8lN3CCqOzbNC72PPD/+i0IIsUnnyeHNPQ= 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.220.29]) by sourceware.org (Postfix) with ESMTPS id 0AF5F3857427 for ; Tue, 25 Oct 2022 11:19:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0AF5F3857427 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1F3D41F8D9 for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0AF49134CA for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qEl7AVLGV2O1dAAAMHmgww (envelope-from ) for ; Tue, 25 Oct 2022 11:19:46 +0000 To: gdb-patches@sourceware.org Subject: [RFC 2/5] [gdbsupport] Add CATCH_ERROR and CATCH_ERROR_QUIT Date: Tue, 25 Oct 2022 13:19:42 +0200 Message-Id: <20221025111945.23886-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221025111945.23886-1-tdevries@suse.de> References: <20221025111945.23886-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 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 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add convenience macros CATCH_ERROR and CATCH_ERROR_QUIT, that can be used to rewrite catch clauses of try/catch statements. More concretely, this: ... catch (const gdb_exception &VAR) { BODY; } ... into: ... CATCH_ERROR_QUIT (VAR, { BODY; } ... and this: ... catch (const gdb_exception_error &VAR) { BODY; } ... into: ... CATCH_ERROR (VAR, { BODY; } ... --- gdbsupport/common-exceptions.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h index 543afda508a..ea998652edc 100644 --- a/gdbsupport/common-exceptions.h +++ b/gdbsupport/common-exceptions.h @@ -294,6 +294,37 @@ struct gdb_exception_quit : public gdb_exception } }; +#define CATCH_ERROR_QUIT(VAR, BODY) \ + catch (const gdb_exception_error &VAR) \ + { \ + BODY; \ + } \ + catch (const gdb_exception_quit &VAR) \ + { \ + BODY; \ + } \ + catch (const gdb_exception &) \ + { \ + /* Exception slicing occurred. */ \ + gdb_assert (0); \ + } + +#define CATCH_ERROR(VAR, BODY) \ + catch (const gdb_exception_error &VAR) \ + { \ + BODY; \ + } \ + catch (const gdb_exception_quit &) \ + { \ + throw; \ + } \ + catch (const gdb_exception &) \ + { \ + /* Exception slicing occurred. */ \ + gdb_assert (0); \ + } + + /* An exception type that inherits from both std::bad_alloc and a gdb exception. This is necessary because operator new can only throw std::bad_alloc, and OTOH, we want exceptions thrown due to memory From patchwork Tue Oct 25 11:19:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 59387 Return-Path: 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 9D8CB385AE58 for ; Tue, 25 Oct 2022 11:20:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D8CB385AE58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666696814; bh=tCXZgkJ6Om2lb13JsXyJ7AN9r/iLAWP6MQxQu9QMEsM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Zo6mVKnihNJ5TzX1E/t+ucONPbaD6VI95Y3UKlHF8ywlqooF4F5o4vnYAFamSIx7y S9C+Vr2UQSYS7dxMOTc6YKvUaCH7U3PII6kxXErFuiRVXfzc3c0lHvbct4BNOu2AbW qE2gvUlM0jTnf4mOIeevXM+NG+S4kLfz7z51vkfE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id EE0353857827 for ; Tue, 25 Oct 2022 11:19:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EE0353857827 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 368A71F8F5 for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 240AF134CA for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uK21B1LGV2O1dAAAMHmgww (envelope-from ) for ; Tue, 25 Oct 2022 11:19:46 +0000 To: gdb-patches@sourceware.org Subject: [RFC 3/5] [gdb/contrib] Add refactor.py Date: Tue, 25 Oct 2022 13:19:43 +0200 Message-Id: <20221025111945.23886-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221025111945.23886-1-tdevries@suse.de> References: <20221025111945.23886-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, 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 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: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add a refactoring script gdb/contrib/refactor.py that takes a transformation script as argument, for instance a script gdb/contrib/transform.py, like so: ... $ ./gdb/contrib/refactor.py transform ... --- gdb/contrib/refactor.py | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 gdb/contrib/refactor.py diff --git a/gdb/contrib/refactor.py b/gdb/contrib/refactor.py new file mode 100755 index 00000000000..de2f58bc077 --- /dev/null +++ b/gdb/contrib/refactor.py @@ -0,0 +1,61 @@ +#! /usr/bin/env python3 + +# Copyright (C) 2022 Free Software Foundation, Inc. +# +# This file is part of GDB. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import sys +import re + +# Define scope of refactoring. +dirs = ["gdb", "gdbserver", "gdbsupport"] +avoid_dir = "/testsuite/" +exts = [".c", ".cc", ".h"] + +transform_file = sys.argv[1] +transform_file = re.sub(r"\.py$", r"", transform_file) + +transformation = __import__(transform_file) + +def handle_file(filename): + file = open(filename, 'r+') + data = file.read() + file.close() + + transformation.have_match = False + data = transformation.transform(data) + if transformation.have_match: + file = open(filename, 'w') + file.write(data) + file.close() + +def main(): + for dir in dirs: + for walk_root, walk_dirs, walk_files in os.walk(dir): + for file in walk_files: + full = os.path.join(walk_root, file) + if avoid_dir in full: + continue + found = False + for ext in exts: + if file.endswith(ext): + found = True + break + if found: + handle_file(full) + +main() From patchwork Tue Oct 25 11:19:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 59388 Return-Path: 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 50CB43857016 for ; Tue, 25 Oct 2022 11:20:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50CB43857016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666696827; bh=Er6mcbfD1c8HljD1T+ANdovv65O1KTxEysH5SneyGIE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DNLqUdstSNBnpPW6BZLkig2bFjVVqxaG2x14BQqpFdY0d/Y4AaXUEni+SF5GYab+b Rzb9Xc0azdgAjwpAAhd78+7FedA5mk7UXyvnzhMqKSsgwQHiCQSCPIYvt+gI8AXur2 PbnrHyw/NEVZS6/UYMOK+ssFBj/EY6kFmHNzjTAs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 5E2AE3857357 for ; Tue, 25 Oct 2022 11:19:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5E2AE3857357 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5104722000 for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3E2D1134CA for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GA8RDlLGV2O1dAAAMHmgww (envelope-from ) for ; Tue, 25 Oct 2022 11:19:46 +0000 To: gdb-patches@sourceware.org Subject: [RFC 4/5] [gdb/contrib] Add refactor_gdb_exception.py Date: Tue, 25 Oct 2022 13:19:44 +0200 Message-Id: <20221025111945.23886-5-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221025111945.23886-1-tdevries@suse.de> References: <20221025111945.23886-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, 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 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: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add a transformation script refactor_gdb_exception.py, to be used with gdb/contrib/refactor.py that rewrites: ... catch (const gdb_exception/gdb_exception_error &VAR) { BODY; } ... using respectively CATCH_ERROR_QUIT and CATCH_ERROR. --- gdb/contrib/refactor_gdb_exception.py | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 gdb/contrib/refactor_gdb_exception.py diff --git a/gdb/contrib/refactor_gdb_exception.py b/gdb/contrib/refactor_gdb_exception.py new file mode 100644 index 00000000000..573ec90e996 --- /dev/null +++ b/gdb/contrib/refactor_gdb_exception.py @@ -0,0 +1,68 @@ +#! /usr/bin/env python3 + +# Copyright (C) 2022 Free Software Foundation, Inc. +# +# This file is part of GDB. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Implement a refactoring transformation to handling exception catching +# using CATCH_ERROR_QUIT and CATCH_ERROR. + +import re + +pattern_lines = [ + # \1 \2 \3 + r"^([ \t]*)catch \(const (gdb_exception(?:_error)?) &([a-zA-Z0-9]+)\)", + # \4 + r"([ \t]*){(?:}|", + # \5 + r"(.*?)^\4})" +] +pattern = "\n".join(pattern_lines) + +def repl(matchobj): + global have_match + have_match = True + + g1 = matchobj.group(1) + exception = matchobj.group(2) + var = matchobj.group(3) + g4 = matchobj.group(4) + body = matchobj.group(5) + + if exception == "gdb_exception": + m = "CATCH_ERROR_QUIT" + else: + m = "CATCH_ERROR" + + if body == None or body == "": + return r"%s%s (%s, {})" % (g1, m, var) + + body = re.sub(r"\n$", r"", body) + + # Apply recursively. + body = transform(body) + + repl_lines = [ + r"%s%s (%s, {" % (g1, m, var), + r"%s" % body, + r"%s})" % g4 + ] + repl= "\n".join(repl_lines) + + return repl + +def transform(data): + return re.sub(pattern, repl, data, 0, re.MULTILINE | re.DOTALL) From patchwork Tue Oct 25 11:19:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 59390 Return-Path: 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 B68913857BBC for ; Tue, 25 Oct 2022 11:21:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B68913857BBC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666696887; bh=Ck/jQRstw7DxfrGAMfFWZbnwsHCDP66oQuBx6/7fnUQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=JHZmAldgre0Xp8LxKA3AnIXJWSFGVg0Mw1FeC9BgECBkZS0NWCZFBglUXT886Kp+J 6IDWwvkykTTVk5tTkhkXhShGHwCRlM21+PWA1F+/iqGZVf05vCfBMVjCi30Hu0XwnZ OQ2EyOhxKOX0sKlUAlmtZJOJah2ovqFlrNPKcJD0= 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.220.28]) by sourceware.org (Postfix) with ESMTPS id 9A57D385735C for ; Tue, 25 Oct 2022 11:19:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A57D385735C Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A460922004 for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 61742134CA for ; Tue, 25 Oct 2022 11:19:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6MyTFlLGV2O1dAAAMHmgww (envelope-from ) for ; Tue, 25 Oct 2022 11:19:46 +0000 To: gdb-patches@sourceware.org Subject: [RFC 5/5] [gdb] Do refactor_gdb_exception refactoring Date: Tue, 25 Oct 2022 13:19:45 +0200 Message-Id: <20221025111945.23886-6-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221025111945.23886-1-tdevries@suse.de> References: <20221025111945.23886-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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 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: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Execute: ... $ ./gdb/contrib/refactor.py refactor_gdb_exception ... --- gdb/aarch64-linux-tdep.c | 5 +- gdb/aarch64-tdep.c | 10 +- gdb/ada-lang.c | 39 ++--- gdb/ada-typeprint.c | 5 +- gdb/amd64-tdep.c | 15 +- gdb/arch-utils.c | 3 +- gdb/break-catch-throw.c | 15 +- gdb/breakpoint.c | 59 +++---- gdb/btrace.c | 33 ++-- gdb/c-varobj.c | 19 +-- gdb/cli/cli-cmds.c | 10 +- gdb/cli/cli-script.c | 5 +- gdb/compile/compile-c-symbols.c | 15 +- gdb/compile/compile-cplus-symbols.c | 10 +- gdb/compile/compile-object-load.c | 5 +- gdb/compile/compile-object-run.c | 5 +- gdb/completer.c | 24 ++- gdb/corelow.c | 10 +- gdb/cp-abi.c | 10 +- gdb/cp-support.c | 14 +- gdb/cp-valprint.c | 10 +- gdb/darwin-nat.c | 10 +- gdb/disasm-selftests.c | 5 +- gdb/dtrace-probe.c | 4 +- gdb/dwarf2/frame-tailcall.c | 5 +- gdb/dwarf2/frame.c | 15 +- gdb/dwarf2/index-cache.c | 10 +- gdb/dwarf2/index-write.c | 5 +- gdb/dwarf2/loc.c | 15 +- gdb/dwarf2/read.c | 5 +- gdb/elf-none-tdep.c | 5 +- gdb/eval.c | 24 ++- gdb/event-top.c | 9 +- gdb/exec.c | 5 +- gdb/f-valprint.c | 5 +- gdb/fbsd-tdep.c | 20 +-- gdb/frame-unwind.c | 5 +- gdb/frame.c | 35 ++--- gdb/gdb_bfd.c | 5 +- gdb/gdbtypes.c | 5 +- gdb/gnu-v3-abi.c | 5 +- gdb/guile/guile-internal.h | 5 +- gdb/guile/scm-block.c | 5 +- gdb/guile/scm-breakpoint.c | 40 ++--- gdb/guile/scm-cmd.c | 5 +- gdb/guile/scm-disasm.c | 5 +- gdb/guile/scm-frame.c | 95 +++++------- gdb/guile/scm-lazy-string.c | 5 +- gdb/guile/scm-math.c | 5 +- gdb/guile/scm-param.c | 10 +- gdb/guile/scm-ports.c | 10 +- gdb/guile/scm-pretty-print.c | 4 +- gdb/guile/scm-symbol.c | 25 ++- gdb/guile/scm-symtab.c | 5 +- gdb/guile/scm-type.c | 59 +++---- gdb/guile/scm-value.c | 74 ++++----- gdb/i386-linux-tdep.c | 5 +- gdb/i386-tdep.c | 15 +- gdb/inf-loop.c | 5 +- gdb/infcmd.c | 10 +- gdb/inferior.h | 5 +- gdb/infrun.c | 29 ++-- gdb/jit.c | 5 +- gdb/language.c | 5 +- gdb/linespec.c | 19 +-- gdb/linux-fork.c | 5 +- gdb/linux-nat.c | 20 +-- gdb/linux-tdep.c | 5 +- gdb/linux-thread-db.c | 20 +-- gdb/main.c | 20 +-- gdb/maint-test-options.c | 5 +- gdb/mi/mi-cmd-break.c | 5 +- gdb/mi/mi-cmd-stack.c | 5 +- gdb/mi/mi-interp.c | 5 +- gdb/mi/mi-main.c | 10 +- gdb/objc-lang.c | 5 +- gdb/p-valprint.c | 5 +- gdb/parse.c | 10 +- gdb/printcmd.c | 20 +-- gdb/python/py-arch.c | 5 +- gdb/python/py-breakpoint.c | 35 ++--- gdb/python/py-cmd.c | 5 +- gdb/python/py-connection.c | 5 +- gdb/python/py-finishbreakpoint.c | 30 ++-- gdb/python/py-frame.c | 100 +++++------- gdb/python/py-framefilter.c | 10 +- gdb/python/py-gdb-readline.c | 5 +- gdb/python/py-inferior.c | 15 +- gdb/python/py-infthread.c | 15 +- gdb/python/py-lazy-string.c | 5 +- gdb/python/py-linetable.c | 5 +- gdb/python/py-objfile.c | 20 +-- gdb/python/py-param.c | 5 +- gdb/python/py-prettyprint.c | 9 +- gdb/python/py-progspace.c | 10 +- gdb/python/py-record-btrace.c | 20 +-- gdb/python/py-record.c | 10 +- gdb/python/py-symbol.c | 40 ++--- gdb/python/py-tui.c | 5 +- gdb/python/py-type.c | 94 +++++------- gdb/python/py-unwind.c | 20 +-- gdb/python/py-utils.c | 5 +- gdb/python/py-value.c | 145 +++++++----------- gdb/python/python.c | 43 ++---- gdb/record-btrace.c | 40 ++--- gdb/record-full.c | 20 +-- gdb/regcache.c | 5 +- gdb/remote-fileio.c | 5 +- gdb/remote.c | 25 ++- gdb/riscv-tdep.c | 10 +- gdb/rs6000-aix-tdep.c | 5 +- gdb/rs6000-tdep.c | 10 +- gdb/rust-lang.c | 5 +- gdb/rust-parse.c | 10 +- gdb/s390-tdep.c | 5 +- gdb/solib-dsbt.c | 4 +- gdb/solib-frv.c | 4 +- gdb/solib-svr4.c | 39 ++--- gdb/solib.c | 20 +-- gdb/source-cache.c | 5 +- gdb/sparc64-linux-tdep.c | 5 +- gdb/stack.c | 58 +++---- gdb/symfile-mem.c | 5 +- gdb/symmisc.c | 5 +- gdb/target.c | 5 +- gdb/thread.c | 10 +- gdb/top.c | 20 +-- gdb/tracefile-tfile.c | 5 +- gdb/tui/tui-disasm.c | 5 +- gdb/tui/tui-io.c | 5 +- gdb/tui/tui.c | 5 +- gdb/typeprint.c | 4 +- gdb/unittests/cli-utils-selftests.c | 5 +- gdb/unittests/gdb_tilde_expand-selftests.c | 5 +- gdb/unittests/gmp-utils-selftests.c | 5 +- .../parse-connection-spec-selftests.c | 5 +- gdb/valops.c | 9 +- gdb/valprint.c | 5 +- gdb/value.c | 10 +- gdb/varobj.c | 29 ++-- gdb/windows-nat.c | 10 +- gdb/x86-linux-nat.c | 5 +- gdbserver/gdbreplay.cc | 5 +- gdbserver/linux-low.cc | 10 +- gdbserver/server.cc | 30 ++-- gdbsupport/selftest.cc | 5 +- 146 files changed, 884 insertions(+), 1367 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index a321aee036a..7a91b8aede9 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1767,11 +1767,10 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, fault_addr = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); } - catch (const gdb_exception_error &exception) - { + CATCH_ERROR (exception, { exception_print (gdb_stderr, exception); return; - } + }) /* If this is not a memory tag violation, just return. */ if (si_code != SEGV_MTEAERR && si_code != SEGV_MTESERR) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index d9ddc84a140..556eb6ed0a2 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1031,11 +1031,10 @@ aarch64_make_prologue_cache (frame_info_ptr this_frame, void **this_cache) { aarch64_make_prologue_cache_1 (this_frame, cache); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) return cache; } @@ -1168,11 +1167,10 @@ aarch64_make_stub_cache (frame_info_ptr this_frame, void **this_cache) cache->prev_pc = get_frame_pc (this_frame); cache->available_p = 1; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) return cache; } diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 383f96bdc45..e4266c57553 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6482,10 +6482,9 @@ ada_tag_value_at_base_address (struct value *obj) offset_to_top = value_as_long (value_ind (value_ptradd (val, -2))); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { return obj; - } + }) /* If offset is null, nothing to do. */ @@ -6650,9 +6649,7 @@ ada_tag_name (struct value *tag) if (tsd != NULL) name = ada_tag_name_from_tsd (tsd); } - catch (const gdb_exception_error &e) - { - } + CATCH_ERROR (e, {}) return name; } @@ -8622,8 +8619,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, { xvz_found = get_int_var_value (xvz_name, size); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { /* We found the variable, but somehow failed to read its value. Rethrow the same error, but with a little bit more information, to help the user understand @@ -8632,7 +8628,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, throw_error (except.error, _("unable to read value of %s (%s)"), xvz_name, except.what ()); - } + }) if (xvz_found && fixed_record_type->length () != size) { @@ -12065,10 +12061,9 @@ ada_exception_message (void) { e_msg = ada_exception_message_1 (); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { e_msg.reset (nullptr); - } + }) return e_msg; } @@ -12088,11 +12083,10 @@ ada_exception_name_addr (enum ada_exception_catchpoint_kind ex) result = ada_exception_name_addr_1 (ex); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { warning (_("failed to get exception name: %s"), e.what ()); return 0; - } + }) return result; } @@ -12230,12 +12224,11 @@ create_excep_cond_exprs (struct ada_catchpoint *c, block_for_pc (bl->address), 0); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { warning (_("failed to reevaluate internal exception condition " "for catchpoint %d: %s"), c->number, e.what ()); - } + }) } ada_loc->excep_cond_expr = std::move (exp); @@ -12296,10 +12289,9 @@ should_stop_exception (const struct bp_location *bl) struct value *exc = parse_and_eval (expr); set_internalvar (var, exc); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { clear_internalvar (var); - } + }) } /* With no specific exception, should always stop. */ @@ -12319,11 +12311,10 @@ should_stop_exception (const struct bp_location *bl) scoped_value_mark mark; stop = value_true (evaluate_expression (ada_loc->excep_cond_expr.get ())); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_fprintf (gdb_stderr, ex, _("Error in testing exception condition:\n")); - } + }) return stop; } diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index c79226fcd7d..1c48f7e1805 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -159,8 +159,7 @@ print_range (struct type *type, struct ui_file *stream, lo = ada_discrete_type_low_bound (type); hi = ada_discrete_type_high_bound (type); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* This can happen when the range is dynamic. Sometimes, resolving dynamic property values requires us to have access to an actual object, which is not available @@ -168,7 +167,7 @@ print_range (struct type *type, struct ui_file *stream, Print the range as an unbounded range. */ gdb_printf (stream, "<>"); got_error = 1; - } + }) if (!got_error) { diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index bbfc509319c..d78c2e42e8b 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -2643,11 +2643,10 @@ amd64_frame_cache (frame_info_ptr this_frame, void **this_cache) { amd64_frame_cache_1 (this_frame, cache); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) return cache; } @@ -2771,11 +2770,10 @@ amd64_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache) cache->base_p = 1; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) *this_cache = cache; return cache; @@ -2953,11 +2951,10 @@ amd64_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache) cache->base_p = 1; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) return cache; } diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 5218bfc05e1..941c45523b1 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -1044,8 +1044,7 @@ gdbarch_skip_prologue_noexcept (gdbarch *gdbarch, CORE_ADDR pc) noexcept { new_pc = gdbarch_skip_prologue (gdbarch, pc); } - catch (const gdb_exception &ex) - {} + CATCH_ERROR_QUIT (ex, {}) return new_pc; } diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 6557ee71449..f08108ccabf 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -192,10 +192,9 @@ exception_catchpoint::check_status (struct bpstat *bs) ? canon.get () : type_name.c_str ()); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { exception_print (gdb_stderr, e); - } + }) if (name != nullptr) { @@ -219,8 +218,7 @@ exception_catchpoint::re_set () = new_probe_location_spec (exception_functions[kind].probe); sals = parse_probes (locspec.get (), filter_pspace, NULL); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* Using the probe interface failed. Let's fallback to the normal catchpoint mode. */ try @@ -230,14 +228,13 @@ exception_catchpoint::re_set () (exception_functions[kind].function)); sals = this->decode_location_spec (locspec.get (), filter_pspace); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* NOT_FOUND_ERROR just means the breakpoint will be pending, so let it through. */ if (ex.error != NOT_FOUND_ERROR) throw; - } - } + }) + }) update_breakpoint_locations (this, filter_pspace, sals, {}); } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 30826032360..d9c9bfdd725 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -965,8 +965,7 @@ set_breakpoint_location_condition (const char *cond_string, bp_location *loc, loc->disabled_by_cond = false; } } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { if (loc->enabled) { /* Warn if a user-enabled location is now becoming disabled-by-cond. @@ -982,7 +981,7 @@ set_breakpoint_location_condition (const char *cond_string, bp_location *loc, } loc->disabled_by_cond = true; - } + }) if (has_junk) error (_("Garbage '%s' follows condition"), cond_string); @@ -1054,14 +1053,13 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp, error (_("Junk at end of expression")); break; } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* Condition string is invalid. If this happens to be the last loc, abandon (if not forced) or continue (if forced). */ if (loc->next == nullptr && !force) throw; - } + }) } /* If we reach here, the condition is valid at some locations. */ @@ -2328,12 +2326,11 @@ parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond) aexpr = gen_eval_for_expr (scope, cond); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* If we got here, it means the condition could not be parsed to a valid bytecode expression and thus can't be evaluated on the target's side. It's no use iterating through the conditions. */ - } + }) /* We have a valid agent expression. */ return aexpr; @@ -2507,12 +2504,11 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) format_start, format_end - format_start, argvec.size (), argvec.data ()); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* If we got here, it means the command could not be parsed to a valid bytecode expression and thus can't be evaluated on the target's side. It's no use iterating through the other commands. */ - } + }) /* We have a valid agent expression, return it. */ return aexpr; @@ -5170,8 +5166,7 @@ bpstat_check_watchpoint (bpstat *bs) { e = watchpoint_check (bs); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_fprintf (gdb_stderr, ex, "Error evaluating expression " "for watchpoint %d\n", @@ -5184,7 +5179,7 @@ bpstat_check_watchpoint (bpstat *bs) } watchpoint_del_at_next_stop (b); e = WP_DELETED; - } + }) switch (e) { @@ -5414,11 +5409,10 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) { condition_result = breakpoint_cond_eval (cond); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_fprintf (gdb_stderr, ex, "Error in testing breakpoint condition:\n"); - } + }) } else { @@ -8734,13 +8728,12 @@ find_condition_and_thread_for_sals (const std::vector &sals, *rest = std::move (remaining); break; } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { num_failures++; /* If no sal remains, do not continue. */ if (num_failures == sals.size ()) throw; - } + }) } } @@ -8843,8 +8836,7 @@ create_breakpoint (struct gdbarch *gdbarch, { ops->create_sals_from_location_spec (locspec, &canonical); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* If caller is interested in rc value from parse, set value. */ if (e.error == NOT_FOUND_ERROR) @@ -8872,7 +8864,7 @@ create_breakpoint (struct gdbarch *gdbarch, } else throw; - } + }) if (!pending && canonical.lsals.empty ()) return 0; @@ -11339,9 +11331,7 @@ update_global_location_list_nothrow (enum ugll_insert_mode insert_mode) { update_global_location_list (insert_mode); } - catch (const gdb_exception_error &e) - { - } + CATCH_ERROR (e, {}) } /* Clear BKP from a BPS. */ @@ -12580,10 +12570,9 @@ update_breakpoint_locations (code_breakpoint *b, block_for_pc (sal.pc), 0); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { new_loc->disabled_by_cond = true; - } + }) } if (!sals_end.empty ()) @@ -12818,12 +12807,11 @@ breakpoint_re_set (void) { breakpoint_re_set_one (b); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_fprintf (gdb_stderr, ex, "Error in re-setting breakpoint %d: ", b->number); - } + }) } jit_breakpoint_re_set (); @@ -13345,13 +13333,12 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, bpt->enable_state = bp_enabled; update_watchpoint (w, true /* reparse */); } - catch (const gdb_exception &e) - { + CATCH_ERROR_QUIT (e, { bpt->enable_state = orig_enable_state; exception_fprintf (gdb_stderr, e, _("Cannot enable watchpoint %d: "), bpt->number); return; - } + }) } bpt->enable_state = bp_enabled; diff --git a/gdb/btrace.c b/gdb/btrace.c index a8e6049265c..da96887dd31 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -688,9 +688,7 @@ ftrace_classify_insn (struct gdbarch *gdbarch, CORE_ADDR pc) else if (gdbarch_insn_is_jump (gdbarch, pc)) iclass = BTRACE_INSN_JUMP; } - catch (const gdb_exception_error &error) - { - } + CATCH_ERROR (error, {}) return iclass; } @@ -1112,9 +1110,7 @@ btrace_compute_ftrace_bts (struct thread_info *tp, { size = gdb_insn_length (gdbarch, pc); } - catch (const gdb_exception_error &error) - { - } + CATCH_ERROR (error, {}) insn.pc = pc; insn.size = size; @@ -1383,10 +1379,9 @@ btrace_pt_readmem_callback (gdb_byte *buffer, size_t size, if (errcode != 0) result = -pte_nomap; } - catch (const gdb_exception_error &error) - { + CATCH_ERROR (error, { result = -pte_nomap; - } + }) return result; } @@ -1491,8 +1486,7 @@ btrace_compute_ftrace_pt (struct thread_info *tp, ftrace_add_pt (btinfo, decoder, &level, gaps); } - catch (const gdb_exception &error) - { + CATCH_ERROR_QUIT (error, { /* Indicate a gap in the trace if we quit trace processing. */ if (error.reason == RETURN_QUIT && !btinfo->functions.empty ()) ftrace_new_gap (btinfo, BDE_PT_USER_QUIT, gaps); @@ -1500,7 +1494,7 @@ btrace_compute_ftrace_pt (struct thread_info *tp, btrace_finalize_ftrace_pt (decoder, tp, level); throw; - } + }) btrace_finalize_ftrace_pt (decoder, tp, level); } @@ -1571,12 +1565,11 @@ btrace_compute_ftrace (struct thread_info *tp, struct btrace_data *btrace, { btrace_compute_ftrace_1 (tp, btrace, cpu, gaps); } - catch (const gdb_exception &error) - { + CATCH_ERROR_QUIT (error, { btrace_finalize_ftrace (tp, gaps); throw; - } + }) btrace_finalize_ftrace (tp, gaps); } @@ -1640,12 +1633,11 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf) && can_access_registers_thread (tp)) btrace_add_pc (tp); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { btrace_disable (tp); throw; - } + }) } /* See btrace.h. */ @@ -3071,13 +3063,12 @@ btrace_maint_update_pt_packets (struct btrace_thread_info *btinfo) { btrace_maint_decode_pt (&btinfo->maint, decoder); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { pt_pkt_free_decoder (decoder); if (except.reason < 0) throw; - } + }) pt_pkt_free_decoder (decoder); } diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 4911e37a200..c4911660bfd 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -97,10 +97,9 @@ adjust_value_for_child_access (struct value **value, *value = value_ind (*value); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { *value = NULL; - } + }) } *type = target_type; if (was_ptr) @@ -259,10 +258,9 @@ value_struct_element_index (struct value *value, int type_index) else result = value_primitive_field (value, 0, type_index, type); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { return NULL; - } + }) return result; } @@ -318,9 +316,7 @@ c_describe_child (const struct varobj *parent, int index, { *cvalue = value_subscript (value, real_index); } - catch (const gdb_exception_error &except) - { - } + CATCH_ERROR (except, {}) } if (ctype) @@ -393,10 +389,9 @@ c_describe_child (const struct varobj *parent, int index, *cvalue = value_ind (value); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { *cvalue = NULL; - } + }) } /* Don't use get_target_type because it calls diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index fe4041662ef..3b592710240 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -263,8 +263,7 @@ with_command_1 (const char *set_cmd_prefix, /* Execute the nested command. */ execute_command (nested_cmd, from_tty); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* Restore the setting and rethrow. If restoring the setting throws, swallow the new exception and warn. There's nothing else we can reasonably do. */ @@ -272,13 +271,12 @@ with_command_1 (const char *set_cmd_prefix, { do_set_command (org_value.c_str (), from_tty, set_cmd); } - catch (const gdb_exception &ex2) - { + CATCH_ERROR_QUIT (ex2, { warning (_("Couldn't restore setting: %s"), ex2.what ()); - } + }) throw; - } + }) /* Restore the setting. */ do_set_command (org_value.c_str (), from_tty, set_cmd); diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 2442f7ae38b..c956135fbb0 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1635,15 +1635,14 @@ script_from_file (FILE *stream, const char *file) { read_command_file (stream); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* Re-throw the error, but with the file name information prepended. */ throw_error (e.error, _("%s:%d: Error in sourced command file:\n%s"), source_file_name.c_str (), source_line_number, e.what ()); - } + }) } /* Print the definition of user command C to STREAM. Or, if C is a diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index ad6daba27a0..83991f92b9f 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -367,10 +367,9 @@ gcc_convert_symbol (void *datum, } } - catch (const gdb_exception &e) - { + CATCH_ERROR_QUIT (e, { context->plugin ().error (e.what ()); - } + }) if (compile_debug && !found) gdb_printf (gdb_stdlog, @@ -429,10 +428,9 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, } } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { context->plugin ().error (e.what ()); - } + }) if (compile_debug && !found) gdb_printf (gdb_stdlog, @@ -598,10 +596,9 @@ generate_c_for_for_one_variable (compile_instance *compiler, } } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { compiler->insert_symbol_error (sym, e.what ()); - } + }) } /* See compile-c.h. */ diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index b8e8e07a39d..b68c61d9d85 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -388,12 +388,11 @@ gcc_cplus_convert_symbol (void *datum, } } } - catch (const gdb_exception &e) - { + CATCH_ERROR_QUIT (e, { /* We can't allow exceptions to escape out of this callback. Safest is to simply emit a gcc error. */ instance->plugin ().error (e.what ()); - } + }) if (compile_debug && !found) gdb_printf (gdb_stdlog, @@ -466,10 +465,9 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context, } } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { instance->plugin ().error (e.what ()); - } + }) if (compile_debug && !found) gdb_printf (gdb_stdlog, diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index ca58775880b..4f7fe95bd3a 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -54,11 +54,10 @@ munmap_list::~munmap_list () { gdbarch_infcall_munmap (target_gdbarch (), item.addr, item.size); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* There's not much the user can do, so just ignore this. */ - } + }) } } diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index af761e8782c..e948f44cb39 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -165,8 +165,7 @@ compile_object_run (compile_module_up &&module) call_function_by_hand_dummy (func_val, NULL, args, do_module_cleanup, data); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* In the case of DTOR_FOUND or in the case of EXECUTED nothing needs to be done. */ dtor_found = find_dummy_frame_dtor (do_module_cleanup, data); @@ -176,7 +175,7 @@ compile_object_run (compile_module_up &&module) if (!dtor_found && !executed) do_module_cleanup (data, 0); throw; - } + }) dtor_found = find_dummy_frame_dtor (do_module_cleanup, data); gdb_assert (!dtor_found && executed); diff --git a/gdb/completer.c b/gdb/completer.c index b68b6de2057..edf4d3c2f7d 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1070,10 +1070,9 @@ complete_expression (completion_tracker &tracker, { exp = parse_expression_for_completion (text, &expr_completer); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { return; - } + }) /* Part of the parse_expression_for_completion contract. */ gdb_assert ((exp == nullptr) == (expr_completer == nullptr)); @@ -1456,11 +1455,10 @@ complete_line_internal (completion_tracker &tracker, { complete_line_internal_1 (tracker, text, line_buffer, point, reason); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (except.error != MAX_COMPLETIONS_REACHED_ERROR) throw; - } + }) } /* See completer.h. */ @@ -1697,10 +1695,9 @@ complete (const char *line, char const **word, int *quote_char) tracker = &tracker_handle_completions; } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { return {}; - } + }) return tracker->build_completion_result (*word, *word - line, strlen (line)); } @@ -1944,12 +1941,11 @@ gdb_completion_word_break_characters () { return gdb_completion_word_break_characters_throw (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* Set this to that gdb_rl_attempted_completion_function knows to abort early. */ current_completion.aborted = true; - } + }) return NULL; } @@ -2346,9 +2342,7 @@ gdb_rl_attempted_completion_function (const char *text, int start, int end) { return gdb_rl_attempted_completion_function_throw (text, start, end); } - catch (const gdb_exception &ex) - { - } + CATCH_ERROR_QUIT (ex, {}) return NULL; } diff --git a/gdb/corelow.c b/gdb/corelow.c index 293bc8d4f59..17061435eb7 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -581,10 +581,9 @@ core_target_open (const char *arg, int from_tty) target_update_thread_list (); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { exception_print (gdb_stderr, except); - } + }) p = bfd_core_file_failing_command (core_bfd); if (p) @@ -638,10 +637,9 @@ core_target_open (const char *arg, int from_tty) { thread_command (NULL, from_tty); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { exception_print (gdb_stderr, except); - } + }) } } diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index c32b1f7d2f0..715e342ee63 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -79,15 +79,14 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr, embedded_offset, address, val); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; throw_error (NOT_AVAILABLE_ERROR, _("Cannot determine virtual baseclass offset " "of incomplete object")); - } + }) return res; } @@ -116,10 +115,9 @@ value_rtti_type (struct value *v, int *full, { ret = (*current_cp_abi.rtti_type) (v, full, top, using_enc); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { return NULL; - } + }) return ret; } diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 77895a8bc98..cee8a003a81 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -151,10 +151,9 @@ inspect_type (struct demangle_parse_info *info, { sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { return 0; - } + }) if (sym != NULL) { @@ -241,10 +240,9 @@ inspect_type (struct demangle_parse_info *info, } /* If type_print threw an exception, there is little point in continuing, so just bow out gracefully. */ - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { return 0; - } + }) len = buf.size (); name = obstack_strdup (&info->obstack, buf.string ()); @@ -505,9 +503,7 @@ replace_typedefs (struct demangle_parse_info *info, sym = lookup_symbol (local_name.get (), 0, VAR_DOMAIN, 0).symbol; } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) if (sym != NULL) { diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index fac558deb05..c40cd2930cb 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -305,12 +305,11 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, v, stream, recurse + 1, opts); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { fprintf_styled (stream, metadata_style.style (), _(""), ex.what ()); - } + }) } else if (i == vptr_fieldno && type == vptr_basetype) { @@ -435,13 +434,12 @@ cp_print_value (struct value *val, struct ui_file *stream, value_embedded_offset (val), address, val); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == NOT_AVAILABLE_ERROR) skip = -1; else skip = 1; - } + }) if (skip == 0) { diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index eca97c9bde9..b75c341849b 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1668,13 +1668,12 @@ darwin_attach_pid (struct inferior *inf) darwin_setup_exceptions (inf); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exit_inferior (inf); switch_to_no_thread (); throw; - } + }) target_ops *darwin_ops = get_native_target (); if (!inf->target_is_pushed (darwin_ops)) @@ -1932,8 +1931,7 @@ The error was: %s"), { copy_shell_to_cache (shell, new_name); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { warning (_("This version of macOS has System Integrity Protection.\n\ Because `startup-with-shell' is enabled, gdb tried to work around SIP by\n\ caching a copy of your shell. However, this failed:\n\ @@ -1943,7 +1941,7 @@ you \"run\". To prevent these attempts, you can use:\n\ set startup-with-shell off"), ex.what ()); return false; - } + }) gdb_printf (_("Note: this version of macOS has System Integrity Protection.\n\ Because `startup-with-shell' is enabled, gdb has worked around this by\n\ diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c index db2d1e0ac59..4f7dbc4a9b5 100644 --- a/gdb/disasm-selftests.c +++ b/gdb/disasm-selftests.c @@ -320,11 +320,10 @@ memory_error_test (struct gdbarch *gdbarch) { di.print_insn (0); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == MEMORY_ERROR) saw_memory_error = true; - } + }) /* Expect MEMORY_ERROR. */ SELF_CHECK (saw_memory_error); diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index 14b35e8d41c..9433b9b1172 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -489,9 +489,7 @@ dtrace_process_dof_probe (struct objfile *objfile, expr = parse_expression_with_language (type_str.c_str (), language_c); } - catch (const gdb_exception_error &ex) - { - } + CATCH_ERROR (ex, {}) if (expr != NULL && expr->first_opcode () == OP_TYPE) type = value_type (evaluate_type (expr.get ())); diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c index a1e43cc18ed..3b4d39d42b3 100644 --- a/gdb/dwarf2/frame-tailcall.c +++ b/gdb/dwarf2/frame-tailcall.c @@ -402,8 +402,7 @@ dwarf2_tailcall_sniffer_first (frame_info_ptr this_frame, } } } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (entry_values_debug) exception_print (gdb_stdout, except); @@ -422,7 +421,7 @@ dwarf2_tailcall_sniffer_first (frame_info_ptr this_frame, /* Let unexpected errors propagate. */ throw; - } + }) /* Ambiguous unwind or unambiguous unwind verified as matching. */ if (chain == NULL || chain->length == 0) diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index d4bc53e5dd8..509409e2a1a 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -976,8 +976,7 @@ dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache) internal_error (_("Unknown CFA rule.")); } } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == NOT_AVAILABLE_ERROR) { cache->unavailable_retaddr = 1; @@ -985,7 +984,7 @@ dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache) } throw; - } + }) /* Initialize the register state. */ { @@ -2092,14 +2091,13 @@ dwarf2_build_frame_info (struct objfile *objfile) EH_CIE_OR_FDE_TYPE_ID); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { warning (_("skipping .eh_frame info of %s: %s"), objfile_name (objfile), e.what ()); fde_table.clear (); /* The cie_table is discarded below. */ - } + }) cie_table.clear (); } @@ -2121,13 +2119,12 @@ dwarf2_build_frame_info (struct objfile *objfile) cie_table, &fde_table, EH_CIE_OR_FDE_TYPE_ID); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { warning (_("skipping .debug_frame info of %s: %s"), objfile_name (objfile), e.what ()); fde_table.resize (num_old_fde_entries); - } + }) } struct dwarf2_fde *fde_prev = NULL; diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c index 6de58592050..b7e65675e7d 100644 --- a/gdb/dwarf2/index-cache.c +++ b/gdb/dwarf2/index-cache.c @@ -156,11 +156,10 @@ index_cache::store (dwarf2_per_objfile *per_objfile) build_id_str.c_str (), dwz_build_id_ptr, dw_index_kind::GDB_INDEX); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { index_cache_debug ("couldn't store index cache for objfile %s: %s", objfile_name (obj), except.what ()); - } + }) } #if HAVE_SYS_MMAN_H @@ -213,11 +212,10 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id, ((const gdb_byte *) mmap_resource->mapping.get (), mmap_resource->mapping.size ()); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { index_cache_debug ("couldn't read %s: %s", filename.c_str (), except.what ()); - } + }) return {}; } diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 3d215a6307b..82a520cf55b 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1548,12 +1548,11 @@ save_gdb_index_command (const char *arg, int from_tty) write_dwarf_index (per_objfile, arg, basename, dwz_basename, index_kind); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { exception_fprintf (gdb_stderr, except, _("Error while writing index for `%s': "), objfile_name (objfile)); - } + }) } } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index c42359ab96e..80b16f341d8 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1085,8 +1085,7 @@ call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc, { retval = call_site_find_chain_1 (gdbarch, caller_pc, callee_pc); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { if (e.error == NO_ENTRY_VALUE_ERROR) { if (entry_values_debug) @@ -1096,7 +1095,7 @@ call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc, } else throw; - } + }) return retval; } @@ -1519,8 +1518,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, retval = ctx.evaluate (data, size, as_lval, per_cu, frame, nullptr, type, subobj_type, subobj_byte_offset); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == NOT_AVAILABLE_ERROR) { free_values.free_to_mark (); @@ -1538,7 +1536,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, } else throw; - } + }) /* We need to clean up all the values that are not needed any more. The problem with a value_ref_ptr class is that it disconnects the @@ -1603,8 +1601,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, result = ctx.evaluate (dlbaton->data, dlbaton->size, true, per_cu, frame, addr_stack); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == NOT_AVAILABLE_ERROR) { return 0; @@ -1617,7 +1614,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, } else throw; - } + }) if (value_optimized_out (result)) return 0; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 071d0c48e99..0a2daeec210 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5436,10 +5436,9 @@ dwarf2_build_psymtabs (struct objfile *objfile) /* (maybe) store an index in the cache. */ global_index_cache.store (per_objfile); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { exception_print (gdb_stderr, except); - } + }) } /* Find the base address of the compilation unit for range lists and diff --git a/gdb/elf-none-tdep.c b/gdb/elf-none-tdep.c index d7d9e1dc3dc..f6411671f99 100644 --- a/gdb/elf-none-tdep.c +++ b/gdb/elf-none-tdep.c @@ -79,10 +79,9 @@ elf_none_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, { update_thread_list (); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { exception_print (gdb_stderr, e); - } + }) /* Like the Linux kernel, prefer dumping the signalled thread first. "First thread" is what tools use to infer the signalled thread. */ diff --git a/gdb/eval.c b/gdb/eval.c index d0a4a16ceb5..853fdd9a26f 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -169,8 +169,7 @@ fetch_subexp_value (struct expression *exp, { result = op->evaluate (nullptr, exp, EVAL_NORMAL); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* Ignore memory errors if we want watchpoints pointing at inaccessible memory to still be created; otherwise, throw the error to some higher catcher. */ @@ -184,7 +183,7 @@ fetch_subexp_value (struct expression *exp, throw; break; } - } + }) new_mark = value_mark (); if (mark == new_mark) @@ -206,9 +205,7 @@ fetch_subexp_value (struct expression *exp, value_fetch_lazy (result); *valp = result; } - catch (const gdb_exception_error &except) - { - } + CATCH_ERROR (except, {}) } } @@ -559,13 +556,12 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var) ret = value_of_variable (var, blk); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (noside != EVAL_AVOID_SIDE_EFFECTS) throw; ret = value_zero (var->type (), not_lval); - } + }) return ret; } @@ -908,13 +904,12 @@ structop_base_operation::evaluate_funcall { value = value_x_unop (vals[0], op, noside); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (except.error == NOT_FOUND_ERROR) break; else throw; - } + }) vals[0] = value; } @@ -1236,13 +1231,12 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp, value = value_x_unop (arg1, STRUCTOP_PTR, noside); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (except.error == NOT_FOUND_ERROR) break; else throw; - } + }) arg1 = value; } diff --git a/gdb/event-top.c b/gdb/event-top.c index 0e371194ee3..edb24f722a1 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -1284,12 +1284,11 @@ async_disconnect (gdb_client_data arg) quit_cover (); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { gdb_puts ("Could not kill the program being debugged", gdb_stderr); exception_print (gdb_stderr, exception); - } + }) for (inferior *inf : all_inferiors ()) { @@ -1298,9 +1297,7 @@ async_disconnect (gdb_client_data arg) { pop_all_targets (); } - catch (const gdb_exception &exception) - { - } + CATCH_ERROR_QUIT (exception, {}) } signal (SIGHUP, SIG_DFL); /*FIXME: ??????????? */ diff --git a/gdb/exec.c b/gdb/exec.c index 0890193faa3..f8397df95c2 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -199,11 +199,10 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, { symbol_file_add_main (exec_file_host, add_flags); } - catch (const gdb_exception_error &err) - { + CATCH_ERROR (err, { if (prev_err != err) warning ("%s", err.what ()); - } + }) } } diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 1742bbb5df2..30f2a019264 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -641,12 +641,11 @@ info_common_command_for_block (const struct block *block, const char *comname, value_print (val, gdb_stdout, &opts); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { fprintf_styled (gdb_stdout, metadata_style.style (), "", except.what ()); - } + }) gdb_putc ('\n'); } diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index bb5a8f3f61e..7461abde9c1 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -702,10 +702,9 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) { update_thread_list (); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { exception_print (gdb_stderr, e); - } + }) /* Like the kernel, prefer dumping the signalled thread first. "First thread" is what tools use to infer the signalled thread. @@ -1965,10 +1964,9 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) data->rtld_offsets_valid = true; return; } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { data->off_linkmap = -1; - } + }) try { @@ -1982,10 +1980,9 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) data->rtld_offsets_valid = true; return; } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { data->off_linkmap = -1; - } + }) } /* Helper function to read the TLS index of an object file associated @@ -2214,10 +2211,9 @@ fbsd_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout, timerid = parse_and_eval_long ("$_siginfo._reason._timer.si_timerid"); mqd = parse_and_eval_long ("$_siginfo._reason._mesgq.si_mqd"); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { return; - } + }) const char *meaning = fbsd_signal_cause (siggnal, code); if (meaning == nullptr) diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index e535d41225c..5347985a68c 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -135,8 +135,7 @@ frame_unwind_try_unwinder (frame_info_ptr this_frame, void **this_cache, frame_debug_printf ("trying unwinder \"%s\"", unwinder->name); res = unwinder->sniffer (unwinder, this_frame, this_cache); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { frame_debug_printf ("caught exception: %s", ex.message->c_str ()); /* Catch all exceptions, caused by either interrupt or error. @@ -158,7 +157,7 @@ frame_unwind_try_unwinder (frame_info_ptr this_frame, void **this_cache, return 0; } throw; - } + }) if (res) { diff --git a/gdb/frame.c b/gdb/frame.c index 3ddc0d06996..e93a7ae7e0a 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -590,8 +590,7 @@ compute_frame_id (frame_info_ptr fi) frame_debug_printf (" -> %s", fi->this_id.value.to_string ().c_str ()); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* On error, revert the frame id status to not computed. If the frame cache generation changed, the frame object doesn't exist anymore, so don't touch it. */ @@ -599,7 +598,7 @@ compute_frame_id (frame_info_ptr fi) fi->this_id.p = frame_id_status::NOT_COMPUTED; throw; - } + }) } /* Return a frame uniq ID that can be used to, later, re-find the @@ -950,8 +949,7 @@ frame_unwind_pc (frame_info_ptr this_frame) pc = gdbarch_unwind_pc (prev_gdbarch, this_frame); pc_p = true; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == NOT_AVAILABLE_ERROR) { this_frame->prev_pc.status = CC_UNAVAILABLE; @@ -968,7 +966,7 @@ frame_unwind_pc (frame_info_ptr this_frame) } else throw; - } + }) if (pc_p) { @@ -2132,8 +2130,7 @@ get_prev_frame_maybe_check_cycle (frame_info_ptr this_frame) prev_frame = NULL; } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { if (get_frame_cache_generation () == entry_generation) { prev_frame->next = NULL; @@ -2141,7 +2138,7 @@ get_prev_frame_maybe_check_cycle (frame_info_ptr this_frame) } throw; - } + }) return prev_frame; } @@ -2315,8 +2312,7 @@ get_prev_frame_always (frame_info_ptr this_frame) { prev_frame = get_prev_frame_always_1 (this_frame); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == MEMORY_ERROR) { this_frame->stop_reason = UNWIND_MEMORY_ERROR; @@ -2338,7 +2334,7 @@ get_prev_frame_always (frame_info_ptr this_frame) } else throw; - } + }) return prev_frame; } @@ -2586,13 +2582,12 @@ get_frame_pc_if_available (frame_info_ptr frame, CORE_ADDR *pc) { *pc = frame_unwind_pc (frame_info_ptr (frame->next)); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == NOT_AVAILABLE_ERROR) return false; else throw; - } + }) return true; } @@ -2668,12 +2663,11 @@ get_frame_address_in_block_if_available (frame_info_ptr this_frame, { *pc = get_frame_address_in_block (this_frame); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == NOT_AVAILABLE_ERROR) return false; throw; - } + }) return true; } @@ -2953,11 +2947,10 @@ get_frame_language (frame_info_ptr frame) pc = get_frame_address_in_block (frame); pc_p = true; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) if (pc_p) { diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index d2e18c74168..52dd885d805 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -430,12 +430,11 @@ gdb_bfd_iovec_fileio_close (struct bfd *abfd, void *stream) { target_fileio_close (fd, &target_errno); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* Also avoid crossing exceptions over bfd. */ gdb_bfd_close_warning (bfd_get_filename (abfd), ex.message->c_str ()); - } + }) /* Zero means success. */ return 0; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index a43d9265ad2..099a30eb2fa 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3182,10 +3182,9 @@ safe_parse_type (struct gdbarch *gdbarch, const char *p, int length) { type = parse_and_eval_type (p, length); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { type = builtin_type (gdbarch)->builtin_void; - } + }) return type; } diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 2f000e634a4..2777783a5ac 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -937,12 +937,11 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, { addr = value_as_address (vfn); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { fprintf_styled (gdb_stdout, metadata_style.style (), _(""), ex.what ()); got_error = 1; - } + }) if (!got_error) print_function_pointer_address (opts, gdbarch, addr, gdb_stdout); diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h index efd5cfd18c6..3a9013aec7a 100644 --- a/gdb/guile/guile-internal.h +++ b/gdb/guile/guile-internal.h @@ -704,10 +704,9 @@ gdbscm_wrap (Function &&func, Args &&... args) { result = func (std::forward (args)...); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c index 07c6a2bd5e5..47c049c4f05 100644 --- a/gdb/guile/scm-block.c +++ b/gdb/guile/scm-block.c @@ -687,10 +687,9 @@ gdbscm_lookup_block (SCM pc_scm) if (cust != NULL && cust->objfile () != NULL) block = block_for_pc (pc); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (cust == NULL || cust->objfile () == NULL) diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c index a7799416c50..d1d6b4e21f8 100644 --- a/gdb/guile/scm-breakpoint.c +++ b/gdb/guile/scm-breakpoint.c @@ -492,10 +492,9 @@ gdbscm_register_breakpoint_x (SCM self) gdb_assert_not_reached ("invalid breakpoint type"); } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { except = unpack (ex); - } + }) /* Ensure this gets reset, even if there's an error. */ pending_breakpoint_scm = SCM_BOOL_F; @@ -521,10 +520,9 @@ gdbscm_delete_breakpoint_x (SCM self) { delete_breakpoint (bp_smob->bp); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return SCM_UNSPECIFIED; @@ -617,10 +615,9 @@ gdbscm_set_breakpoint_enabled_x (SCM self, SCM newvalue) else disable_breakpoint (bp_smob->bp); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return SCM_UNSPECIFIED; @@ -653,10 +650,9 @@ gdbscm_set_breakpoint_silent_x (SCM self, SCM newvalue) { breakpoint_set_silent (bp_smob->bp, gdbscm_is_true (newvalue)); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return SCM_UNSPECIFIED; @@ -695,10 +691,9 @@ gdbscm_set_breakpoint_ignore_count_x (SCM self, SCM newvalue) { set_ignore_count (bp_smob->number, (int) value, 0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return SCM_UNSPECIFIED; @@ -817,10 +812,9 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue) { valid_id = valid_task_id (id); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (! valid_id) @@ -839,10 +833,9 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue) { breakpoint_set_task (bp_smob->bp, id); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return SCM_UNSPECIFIED; @@ -1005,10 +998,9 @@ gdbscm_breakpoint_commands (SCM self) ui_out_redirect_pop redir (current_uiout, &buf); print_command_lines (current_uiout, breakpoint_commands (bp), 0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); result = gdbscm_scm_from_c_string (buf.c_str ()); diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c index 764180d8198..fb8e6c69510 100644 --- a/gdb/guile/scm-cmd.c +++ b/gdb/guile/scm-cmd.c @@ -768,10 +768,9 @@ gdbscm_register_command_x (SCM self) c_smob->doc, cmd_list); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); /* Note: At this point the command exists in gdb. diff --git a/gdb/guile/scm-disasm.c b/gdb/guile/scm-disasm.c index 992a64b9331..1cabb4ffd05 100644 --- a/gdb/guile/scm-disasm.c +++ b/gdb/guile/scm-disasm.c @@ -258,10 +258,9 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest) else insn_len = gdb_print_insn (gdbarch, pc, &buf, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); result = scm_cons (dascm_make_insn (pc, buf.c_str (), insn_len), diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index f7ca141b2a7..760af6fead5 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -272,10 +272,9 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior) } gdbarch = get_frame_arch (frame_ptr); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { return gdbscm_scm_from_gdb_exception (unpack (except)); - } + }) f_scm = frscm_make_frame_smob (); f_smob = (frame_smob *) SCM_SMOB_DATA (f_scm); @@ -395,10 +394,9 @@ gdbscm_frame_valid_p (SCM self) frame_info_ptr frame = frscm_frame_smob_to_frame (f_smob); result = frame != nullptr; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return scm_from_bool (result); @@ -429,10 +427,9 @@ gdbscm_frame_name (SCM self) name = find_frame_funname (frame, &lang, NULL); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -471,10 +468,9 @@ gdbscm_frame_type (SCM self) type = get_frame_type (frame); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -503,10 +499,9 @@ gdbscm_frame_arch (SCM self) frame_info_ptr frame = frscm_frame_smob_to_frame (f_smob); found = frame != nullptr; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -540,10 +535,9 @@ gdbscm_frame_unwind_stop_reason (SCM self) stop_reason = get_frame_unwind_stop_reason (frame); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -577,10 +571,9 @@ gdbscm_frame_pc (SCM self) found = true; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -614,10 +607,9 @@ gdbscm_frame_block (SCM self) block = get_frame_block (frame, NULL); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -669,10 +661,9 @@ gdbscm_frame_function (SCM self) sym = find_pc_function (get_frame_address_in_block (frame)); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -710,10 +701,9 @@ gdbscm_frame_older (SCM self) prev = get_prev_frame (frame).get (); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -751,10 +741,9 @@ gdbscm_frame_newer (SCM self) next = get_next_frame (frame).get (); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -791,10 +780,9 @@ gdbscm_frame_sal (SCM self) sal = find_frame_sal (frame); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -838,10 +826,9 @@ gdbscm_frame_read_register (SCM self, SCM register_scm) value = value_of_register (regnum, frame); } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { except = unpack (ex); - } + }) xfree (register_str); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -888,10 +875,9 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) { frame = frscm_frame_smob_to_frame (f_smob).get (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (frame == NULL) @@ -941,10 +927,9 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) var = lookup_sym.symbol; block = lookup_sym.block; } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { except = unpack (ex); - } + }) } GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -964,10 +949,9 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) { value = read_var_value (var, block, frame_info_ptr (frame)); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return vlscm_scm_from_value (value); @@ -994,10 +978,9 @@ gdbscm_frame_select (SCM self) select_frame (frame); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (!found) @@ -1022,10 +1005,9 @@ gdbscm_newest_frame (void) { frame = get_current_frame ().get (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return frscm_scm_from_frame_unsafe (frame, current_inferior ()); @@ -1044,10 +1026,9 @@ gdbscm_selected_frame (void) { frame = get_selected_frame (_("No frame is currently selected")).get (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return frscm_scm_from_frame_unsafe (frame, current_inferior ()); diff --git a/gdb/guile/scm-lazy-string.c b/gdb/guile/scm-lazy-string.c index d260e09b91d..8c24b85b0fd 100644 --- a/gdb/guile/scm-lazy-string.c +++ b/gdb/guile/scm-lazy-string.c @@ -336,11 +336,10 @@ lsscm_safe_lazy_string_to_value (SCM string, int arg_pos, break; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { *except_scmp = gdbscm_scm_from_gdb_exception (unpack (except)); return NULL; - } + }) return value; } diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c index 022863ddd94..851cc6a8a6b 100644 --- a/gdb/guile/scm-math.c +++ b/gdb/guile/scm-math.c @@ -833,10 +833,9 @@ vlscm_convert_typed_value_from_scheme (const char *func_name, value = NULL; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { except_scm = gdbscm_scm_from_gdb_exception (unpack (except)); - } + }) if (gdbscm_is_true (except_scm)) { diff --git a/gdb/guile/scm-param.c b/gdb/guile/scm-param.c index c4e90412567..b7323e5b178 100644 --- a/gdb/guile/scm-param.c +++ b/gdb/guile/scm-param.c @@ -1037,10 +1037,9 @@ gdbscm_register_parameter_x (SCM self) (gdbscm_is_procedure (p_smob->show_func) ? pascm_show_func : NULL), set_list, show_list); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); /* Note: At this point the parameter exists in gdb. @@ -1086,10 +1085,9 @@ gdbscm_parameter_value (SCM self) { found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { except = unpack (ex); - } + }) xfree (newarg); GDBSCM_HANDLE_GDB_EXCEPTION (except); diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c index 9173cb6f26e..ef2e2cfba6f 100644 --- a/gdb/guile/scm-ports.c +++ b/gdb/guile/scm-ports.c @@ -320,10 +320,9 @@ ioscm_write (SCM port, const void *data, size_t size) else fputsn_filtered ((const char *) data, size, gdb_stdout); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); } @@ -387,10 +386,9 @@ ioscm_write (SCM port, SCM src, size_t start, size_t count) else fputsn_filtered ((const char *) data, count, gdb_stdout); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return count; diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index 5e6bb12a3a5..703c468c468 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -558,9 +558,7 @@ ppscm_pretty_print_one_value (SCM printer, struct value **out_value, (_("invalid result from pretty-printer to-string"), result); } } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) return result; } diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index b5704cdcb18..b66276ea5cf 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -485,10 +485,9 @@ gdbscm_symbol_needs_frame_p (SCM self) { result = symbol_read_needs_frame (symbol); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return scm_from_bool (result); @@ -554,10 +553,9 @@ gdbscm_symbol_value (SCM self, SCM rest) can happen with nested functions). */ value = read_var_value (symbol, NULL, frame_info); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return vlscm_scm_from_value (value); @@ -606,11 +604,10 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest) = get_selected_frame (_("no frame selected")); block = get_frame_block (selected_frame, NULL); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { xfree (name); exc = unpack (ex); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); } @@ -620,10 +617,9 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest) symbol = lookup_symbol (name, block, (domain_enum) domain, &is_a_field_of_this).symbol; } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { except = unpack (ex); - } + }) xfree (name); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -656,10 +652,9 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest) { symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { except = unpack (ex); - } + }) xfree (name); GDBSCM_HANDLE_GDB_EXCEPTION (except); diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c index 2ff66c49d51..00ab21ab5f3 100644 --- a/gdb/guile/scm-symtab.c +++ b/gdb/guile/scm-symtab.c @@ -595,10 +595,9 @@ gdbscm_find_pc_line (SCM pc_scm) sal = find_pc_line (pc, 0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return stscm_scm_from_sal (sal); diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 68a5b918e5b..e9ed909dcb9 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -132,10 +132,9 @@ tyscm_type_name (struct type *type) &type_print_raw_options); return stb.release (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { excp = gdbscm_scm_from_gdb_exception (unpack (except)); - } + }) gdbscm_throw (excp); } @@ -258,10 +257,9 @@ tyscm_equal_p_type_smob (SCM type1_scm, SCM type2_scm) { result = types_deeply_equal (type1, type2); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return scm_from_bool (result); @@ -627,9 +625,7 @@ gdbscm_type_sizeof (SCM self) { check_typedef (type); } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) /* Ignore exceptions. */ @@ -651,10 +647,9 @@ gdbscm_type_strip_typedefs (SCM self) { type = check_typedef (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return tyscm_scm_from_type (type); @@ -674,10 +669,9 @@ tyscm_get_composite (struct type *type) { type = check_typedef (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (type->code () != TYPE_CODE_PTR @@ -732,10 +726,9 @@ tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector, if (is_vector) make_vector_type (array); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return tyscm_scm_from_type (array); @@ -788,10 +781,9 @@ gdbscm_type_pointer (SCM self) { type = lookup_pointer_type (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return tyscm_scm_from_type (type); @@ -855,10 +847,9 @@ gdbscm_type_reference (SCM self) { type = lookup_lvalue_reference_type (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return tyscm_scm_from_type (type); @@ -894,10 +885,9 @@ gdbscm_type_const (SCM self) { type = make_cv_type (1, 0, type, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return tyscm_scm_from_type (type); @@ -918,10 +908,9 @@ gdbscm_type_volatile (SCM self) { type = make_cv_type (0, 1, type, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return tyscm_scm_from_type (type); @@ -942,10 +931,9 @@ gdbscm_type_unqualified (SCM self) { type = make_cv_type (0, 0, type, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return tyscm_scm_from_type (type); @@ -1247,10 +1235,9 @@ tyscm_lookup_typename (const char *type_name, const struct block *block) type = lookup_typename (current_language, type_name, block, 0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { return NULL; - } + }) return type; } diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 0107a4bd320..81ac984e586 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -164,10 +164,9 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) common_val_print (v_smob->value, &stb, 0, &opts, current_language); scm_puts (stb.c_str (), port); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (pstate->writingp) @@ -193,10 +192,9 @@ vlscm_equal_p_value_smob (SCM v1, SCM v2) { result = value_equal (v1_smob->value, v2_smob->value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return scm_from_bool (result); @@ -416,9 +414,7 @@ gdbscm_value_address (SCM self) { address = vlscm_scm_from_value (value_addr (value)); } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) if (gdbscm_is_exception (address)) return address; @@ -603,10 +599,9 @@ gdbscm_value_dynamic_type (SCM self) type = NULL; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (type == NULL) @@ -760,10 +755,9 @@ gdbscm_value_call (SCM self, SCM args) { ftype = check_typedef (value_type (function)); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); SCM_ASSERT_TYPE (ftype->code () == TYPE_CODE_FUNC, self, @@ -830,10 +824,9 @@ gdbscm_value_to_bytevector (SCM self) length = type->length (); contents = value_contents (value).data (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); bv = scm_c_make_bytevector (length); @@ -873,10 +866,9 @@ gdbscm_value_to_bool (SCM self) { type = check_typedef (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); SCM_ASSERT_TYPE (is_intlike (type, 1), self, SCM_ARG1, FUNC_NAME, @@ -889,10 +881,9 @@ gdbscm_value_to_bool (SCM self) else l = value_as_long (value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); return scm_from_bool (l != 0); @@ -917,10 +908,9 @@ gdbscm_value_to_integer (SCM self) { type = check_typedef (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); SCM_ASSERT_TYPE (is_intlike (type, 1), self, SCM_ARG1, FUNC_NAME, @@ -933,10 +923,9 @@ gdbscm_value_to_integer (SCM self) else l = value_as_long (value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); if (type->is_unsigned ()) @@ -965,10 +954,9 @@ gdbscm_value_to_real (SCM self) { type = check_typedef (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); SCM_ASSERT_TYPE (is_intlike (type, 0) || type->code () == TYPE_CODE_FLT, @@ -993,10 +981,9 @@ gdbscm_value_to_real (SCM self) check = value_from_longest (type, (LONGEST) d); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); /* TODO: Is there a better way to check if the value fits? */ @@ -1088,11 +1075,10 @@ gdbscm_value_to_string (SCM self, SCM rest) c_get_string (value, &buffer, &length, &char_type, &la_encoding); buffer_contents = buffer.release (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { xfree (encoding); exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); /* If errors is "error", scm_from_stringn may throw a Scheme exception. @@ -1210,10 +1196,9 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) result = lsscm_make_lazy_string (addr, length, encoding, type); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { except = unpack (ex); - } + }) xfree (encoding); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -1273,10 +1258,9 @@ gdbscm_value_print (SCM self) { common_val_print (value, &stb, 0, &opts, current_language); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { exc = unpack (except); - } + }) GDBSCM_HANDLE_GDB_EXCEPTION (exc); /* Use SCM_FAILED_CONVERSION_QUESTION_MARK to ensure this doesn't diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 5c2fed39868..4199ee06126 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -415,10 +415,9 @@ i386_linux_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout, access = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { return; - } + }) /* If this is not a boundary violation just return. */ if (sig_code != SIG_CODE_BONDARY_FAULT) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index e027df2b9c5..f2114624089 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2092,11 +2092,10 @@ i386_frame_cache (frame_info_ptr this_frame, void **this_cache) { i386_frame_cache_1 (this_frame, cache); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) return cache; } @@ -2272,11 +2271,10 @@ i386_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache) cache->base_p = 1; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) return cache; } @@ -2469,11 +2467,10 @@ i386_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache) cache->base_p = 1; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) *this_cache = cache; return cache; diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c index 2ae534b2f5c..e682a2c7907 100644 --- a/gdb/inf-loop.c +++ b/gdb/inf-loop.c @@ -69,8 +69,7 @@ inferior_event_handler (enum inferior_event_type event_type) { bpstat_do_actions (); } - catch (const gdb_exception &e) - { + CATCH_ERROR_QUIT (e, { /* If the user was running a foreground execution command, then propagate the error so that the prompt can be reenabled. Otherwise, the user already has @@ -80,7 +79,7 @@ inferior_event_handler (enum inferior_event_type event_type) throw; else exception_print (gdb_stderr, e); - } + }) } break; diff --git a/gdb/infcmd.c b/gdb/infcmd.c index c03ca103c91..a3ad1846fa3 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -263,11 +263,10 @@ post_create_inferior (int from_tty) regcache *rc = get_thread_regcache (thr); thr->set_stop_pc (regcache_read_pc (rc)); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) if (current_program_space->exec_bfd ()) { @@ -1577,10 +1576,9 @@ print_return_value (struct ui_out *uiout, struct return_value_info *rv) delete the breakpoint. */ print_return_value_1 (uiout, rv); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stdout, ex); - } + }) } /* Data for the FSM that manages the finish command. */ diff --git a/gdb/inferior.h b/gdb/inferior.h index 8877be38e36..2ea630a3996 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -81,8 +81,7 @@ struct infcall_suspend_state_deleter { restore_infcall_suspend_state (state); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* If we are restoring the inferior state due to an exception, some error message will be printed. So, only warn the user when we cannot restore during normal execution. */ @@ -94,7 +93,7 @@ struct infcall_suspend_state_deleter #endif if (!unwinding) warning (_("Failed to restore inferior state: %s"), e.what ()); - } + }) } }; diff --git a/gdb/infrun.c b/gdb/infrun.c index fcc4d80fc73..69f097705cc 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1791,8 +1791,7 @@ displaced_step_prepare (thread_info *thread) { status = displaced_step_prepare_throw (thread); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != MEMORY_ERROR && ex.error != NOT_SUPPORTED_ERROR) throw; @@ -1810,7 +1809,7 @@ displaced_step_prepare (thread_info *thread) /* Disable further displaced stepping attempts. */ thread->inf->displaced_step_state.failed_before = 1; - } + }) return status; } @@ -2680,8 +2679,7 @@ resume (gdb_signal sig) { resume_1 (sig); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* If resuming is being aborted for any reason, delete any single-step breakpoint resume_1 may have created, to avoid confusing the following resumption, and to avoid leaving @@ -2690,7 +2688,7 @@ resume (gdb_signal sig) if (inferior_ptid != null_ptid) delete_single_step_breakpoints (inferior_thread ()); throw; - } + }) } @@ -8041,10 +8039,9 @@ insert_exception_resume_breakpoint (struct thread_info *tp, inferior_thread ()->control.exception_resume_breakpoint = bp; } } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* We want to ignore errors here. */ - } + }) } /* A helper for check_exception_resume that sets an @@ -8137,9 +8134,7 @@ check_exception_resume (struct execution_control_state *ecs, } } } - catch (const gdb_exception_error &e) - { - } + CATCH_ERROR (e, {}) } static void @@ -8255,13 +8250,12 @@ keep_going_pass_signal (struct execution_control_state *ecs) { insert_breakpoints (); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { exception_print (gdb_stderr, e); stop_waiting (ecs); clear_step_over_info (); return; - } + }) ecs->event_thread->control.trap_expected = (remove_bp || remove_wps); @@ -8761,11 +8755,10 @@ normal_stop (void) { execute_cmd_pre_hook (stop_command); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_fprintf (gdb_stderr, ex, "Error while running hook_stop:\n"); - } + }) /* If the stop hook resumes the target, then there's no point in trying to notify about the previous stop; its context is diff --git a/gdb/jit.c b/gdb/jit.c index f383e105b0e..d57ed9e0def 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -715,10 +715,9 @@ jit_reader_try_read_symtab (gdbarch *gdbarch, jit_code_entry *code_entry, code_entry->symfile_size)) status = 0; } - catch (const gdb_exception &e) - { + CATCH_ERROR_QUIT (e, { status = 0; - } + }) if (status) { diff --git a/gdb/language.c b/gdb/language.c index 3962ee8fa24..dcd15c6e10a 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -165,10 +165,9 @@ set_language_command (const char *ignore, frame = get_selected_frame (NULL); flang = get_frame_language (frame); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { flang = language_unknown; - } + }) if (flang != language_unknown) set_language (flang); diff --git a/gdb/linespec.c b/gdb/linespec.c index 3db35998f7e..5d1574d7f5b 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2328,10 +2328,9 @@ convert_explicit_location_spec_to_linespec result->file_symtabs = symtabs_from_filename (source_filename, self->search_pspace); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { source_file_not_found_error (source_filename); - } + }) result->explicit_loc.source_filename = xstrdup (source_filename); } else @@ -2857,10 +2856,9 @@ linespec_complete_label (completion_tracker &tracker, func_name_match_type, NULL, unknown_offset); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { return; - } + }) complete_label (tracker, &parser, label_name); } @@ -2887,9 +2885,7 @@ linespec_complete (completion_tracker &tracker, const char *text, { parse_linespec (&parser, text, match_type); } - catch (const gdb_exception_error &except) - { - } + CATCH_ERROR (except, {}) if (parser.completion_quote_char != '\0' && parser.completion_quote_end != NULL @@ -3873,11 +3869,10 @@ find_linespec_symbols (struct linespec_state *state, /* If successful, we're done. If NOT_FOUND_ERROR was not thrown, rethrow the exception that we did get. */ - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (except.error != NOT_FOUND_ERROR) throw; - } + }) } } } diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index ca876a5cf94..c3b82533f9e 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -430,12 +430,11 @@ class scoped_switch_fork_info fork_load_infrun_state (m_oldfp); insert_breakpoints (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { warning (_("Couldn't restore checkpoint state in %s: %s"), target_pid_to_str (m_oldfp->ptid).c_str (), ex.what ()); - } + }) } } diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index f4f7aa81845..38c0fa470a8 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1066,8 +1066,7 @@ linux_nat_target::attach (const char *args, int from_tty) { inf_ptrace_target::attach (args, from_tty); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { pid_t pid = parse_pid_to_attach (args); std::string reason = linux_ptrace_attach_fail_reason (pid); @@ -1076,7 +1075,7 @@ linux_nat_target::attach (const char *args, int from_tty) ex.what ()); else throw_error (ex.error, "%s", ex.what ()); - } + }) /* The ptrace base target adds the main thread with (pid,0,0) format. Decorate it with lwp info. */ @@ -1357,11 +1356,10 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p) { linux_target->low_prepare_to_resume (lp); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (!check_ptrace_stopped_lwp_gone (lp)) throw; - } + }) detach_one_pid (lwpid, signo); @@ -1508,11 +1506,10 @@ linux_resume_one_lwp (struct lwp_info *lp, int step, enum gdb_signal signo) { linux_resume_one_lwp_throw (lp, step, signo); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (!check_ptrace_stopped_lwp_gone (lp)) throw; - } + }) } /* Resume LP. */ @@ -3377,11 +3374,10 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid) linux_resume_one_lwp_throw (lp, lp->step, GDB_SIGNAL_0); } } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (!check_ptrace_stopped_lwp_gone (lp)) throw; - } + }) } return 0; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 0a2fced7804..b6ecdd70452 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -2064,10 +2064,9 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) { update_thread_list (); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { exception_print (gdb_stderr, e); - } + }) /* Like the kernel, prefer dumping the signalled thread first. "First thread" is what tools use to infer the signalled diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 839271c01c5..ab99867ed9d 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -505,8 +505,7 @@ thread_db_find_new_threads_silently (thread_info *stopped) thread_db_find_new_threads_2 (stopped, true); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (libthread_db_debug) exception_fprintf (gdb_stdlog, except, "Warning: thread_db_find_new_threads_silently: "); @@ -534,7 +533,7 @@ thread_db_find_new_threads_silently (thread_info *stopped) "using libthread_db: ")); return 1; } - } + }) return 0; } @@ -775,8 +774,7 @@ check_thread_db (struct thread_db_info *info, bool log_progress) if (!tdb_testinfo->threads_seen) error (_("no threads seen")); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (warning_pre_print) gdb_puts (warning_pre_print, gdb_stderr); @@ -784,7 +782,7 @@ check_thread_db (struct thread_db_info *info, bool log_progress) _("libthread_db integrity checks failed: ")); test_passed = false; - } + }) if (test_passed && log_progress) debug_printf (_("libthread_db integrity checks passed.\n")); @@ -1024,12 +1022,11 @@ try_thread_db_load (const char *library, bool check_auto_load_safe) if (try_thread_db_load_1 (info)) return true; } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (libthread_db_debug) exception_fprintf (gdb_stdlog, except, "Warning: While trying to load libthread_db: "); - } + }) /* This library "refused" to work on current inferior. */ delete_thread_db_info (current_inferior ()->process_target (), @@ -1545,14 +1542,13 @@ find_new_threads_once (struct thread_db_info *info, int iteration, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (libthread_db_debug) { exception_fprintf (gdb_stdlog, except, "Warning: find_new_threads_once: "); } - } + }) if (libthread_db_debug) { diff --git a/gdb/main.c b/gdb/main.c index 8d2666ecc95..ced4837338c 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -410,8 +410,7 @@ start_event_loop () { result = gdb_do_one_event (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); /* If any exception escaped to here, we better enable @@ -436,7 +435,7 @@ start_event_loop () (*after_char_processing_hook) (); /* Maybe better to set a flag to be checked somewhere as to whether display the prompt or not. */ - } + }) if (result < 0) break; @@ -518,10 +517,9 @@ catch_command_errors (catch_command_errors_const_ftype command, if (do_bp_actions) bpstat_do_actions (); } - catch (const gdb_exception &e) - { + CATCH_ERROR_QUIT (e, { return handle_command_errors (e); - } + }) return 1; } @@ -1329,10 +1327,9 @@ captured_main (void *data) { captured_command_loop (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) } /* No exit -- exit is through quit_command. */ } @@ -1344,10 +1341,9 @@ gdb_main (struct captured_main_args *args) { captured_main (args); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) /* The only way to end up here is by an error (normal exit is handled by quit_force()), hence always return an error status. */ diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c index 14808972467..ddf9162cce5 100644 --- a/gdb/maint-test-options.c +++ b/gdb/maint-test-options.c @@ -324,11 +324,10 @@ maintenance_test_options_completer_mode (completion_tracker &tracker, save_completion_result (opts, res, text); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { save_completion_result (opts, true, text); throw; - } + }) } /* Implementation of the "maintenance test-options require-delimiter" diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 408f582ebc5..a6d7fa79889 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -58,10 +58,9 @@ breakpoint_notify (struct breakpoint *b) { print_breakpoint (b); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) } } diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index f0af7c9a014..b3a6ae2f9ed 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -549,11 +549,10 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, common_val_print (arg->val, &stb, 0, &opts, language_def (arg->sym->language ())); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { stb.printf (_(""), except.what ()); - } + }) } uiout->field_stream ("value", stb); } diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index af242208a0b..637d14ba936 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -847,10 +847,9 @@ mi_print_breakpoint_for_event (struct mi_interp *mi, breakpoint *bp) print_breakpoint (bp); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) } /* Emit notification about a created breakpoint. */ diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 3db7a50648d..f4ade7ce66d 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1920,11 +1920,10 @@ mi_execute_command (const char *cmd, int from_tty) { command = mi_parse (cmd, &token); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { mi_print_exception (token, exception); xfree (token); - } + }) if (command != NULL) { @@ -1940,8 +1939,7 @@ mi_execute_command (const char *cmd, int from_tty) { captured_mi_execute_command (current_uiout, command.get ()); } - catch (const gdb_exception &result) - { + CATCH_ERROR_QUIT (result, { /* Like in start_event_loop, enable input and force display of the prompt. Otherwise, any command that calls async_disable_stdin, and then throws, will leave input @@ -1953,7 +1951,7 @@ mi_execute_command (const char *cmd, int from_tty) somewhere. */ mi_print_exception (command->token, result); mi_out_rewind (current_uiout); - } + }) bpstat_do_actions (); diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 1a1d6215475..5f404a0371c 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -1279,12 +1279,11 @@ find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *), if (f (pc, new_pc) == 0) return 1; } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_fprintf (gdb_stderr, ex, "Unable to determine target of " "Objective-C method call (ignoring):\n"); - } + }) return 0; } diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 2786a8e8c86..cfca97b8975 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -728,14 +728,13 @@ pascal_object_print_value (struct value *val, struct ui_file *stream, { base_value = value_primitive_field (val, 0, i, type); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { base_value = nullptr; if (ex.error == NOT_AVAILABLE_ERROR) skip = -1; else skip = 1; - } + }) if (skip == 0) { diff --git a/gdb/parse.c b/gdb/parse.c index aa12f6fe012..8dcec063563 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -514,14 +514,13 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, { lang->parser (&ps); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { /* If parsing for completion, allow this to succeed; but if no expression elements have been written, then there's nothing to do, so fail. */ if (! ps.parse_completion || ps.expout->op == nullptr) throw; - } + }) expression_up result = ps.release (); result->op->set_outermost (); @@ -585,10 +584,9 @@ parse_expression_for_completion { exp = parse_exp_in_context (&string, 0, 0, 0, false, nullptr, completer); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { /* Nothing, EXP remains NULL. */ - } + }) /* If we didn't get a completion result, be sure to also not return an expression to our caller. */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 273aa5931a9..14578512f18 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2109,14 +2109,13 @@ do_one_display (struct display *d) d->exp = parse_expression (d->exp_string.c_str (), &tracker); d->block = tracker.block (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* Can't re-parse the expression. Disable this display item. */ d->enabled_p = false; warning (_("Unable to display \"%s\": %s"), d->exp_string.c_str (), ex.what ()); return; - } + }) } if (d->block) @@ -2175,12 +2174,11 @@ do_one_display (struct display *d) addr = gdbarch_addr_bits_remove (d->exp->gdbarch, addr); do_examine (d->format, d->exp->gdbarch, addr); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { gdb_printf (_("%p[%p]\n"), metadata_style.style ().ptr (), ex.what (), nullptr); - } + }) } else { @@ -2210,11 +2208,10 @@ do_one_display (struct display *d) val = evaluate_expression (d->exp.get ()); print_formatted (val, d->format.size, &opts, gdb_stdout); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { fprintf_styled (gdb_stdout, metadata_style.style (), _(""), ex.what ()); - } + }) gdb_printf ("\n"); } @@ -2407,12 +2404,11 @@ print_variable_and_value (const char *name, struct symbol *var, function. */ frame = NULL; } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { fprintf_styled (stream, metadata_style.style (), "", name, except.what ()); - } + }) gdb_printf (stream, "\n"); } diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index cf0978560f9..183d5407cf8 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -198,11 +198,10 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) { insn_len = gdb_print_insn (gdbarch, pc, &stb, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return NULL; - } + }) gdbpy_ref<> pc_obj = gdb_py_object_from_ulongest (pc); if (pc_obj == nullptr) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 7a757432948..210b094f100 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -205,10 +205,9 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure) else disable_breakpoint (self_bp->bp); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_SET_HANDLE_EXCEPTION (except); - } + }) return 0; } @@ -310,10 +309,9 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) { valid_id = valid_task_id (id); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_SET_HANDLE_EXCEPTION (except); - } + }) if (! valid_id) { @@ -352,10 +350,9 @@ bppy_delete_breakpoint (PyObject *self, PyObject *args) { delete_breakpoint (self_bp->bp); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -393,10 +390,9 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure) { set_ignore_count (self_bp->number, (int) value, 0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_SET_HANDLE_EXCEPTION (except); - } + }) return 0; } @@ -553,11 +549,10 @@ bppy_get_commands (PyObject *self, void *closure) ui_out_redirect_pop redir (current_uiout, &stb); print_command_lines (current_uiout, breakpoint_commands (bp), 0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return NULL; - } + }) return host_string_to_python_string (stb.c_str ()).release (); } @@ -958,12 +953,11 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) error(_("Do not understand breakpoint type to set.")); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { bppy_pending_object = NULL; gdbpy_convert_exception (except); return -1; - } + }) BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self); return 0; @@ -1465,10 +1459,9 @@ bplocpy_set_enabled (PyObject *py_self, PyObject *newvalue, void *closure) { enable_disable_bp_location (self->bp_loc, cmp == 1); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_SET_HANDLE_EXCEPTION (except); - } + }) return 0; } diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index 5cc392af175..aa3a0828dd0 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -538,11 +538,10 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) set_cmd_completer_handle_brkchars (cmd, cmdpy_completer_handle_brkchars); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return -1; - } + }) return 0; } diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c index 84660414dd0..573cd3a896c 100644 --- a/gdb/python/py-connection.c +++ b/gdb/python/py-connection.c @@ -430,11 +430,10 @@ connpy_send_packet (PyObject *self, PyObject *args, PyObject *kw) gdb_assert ((result == nullptr) == (PyErr_Occurred () != nullptr)); return result; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return nullptr; - } + }) } /* Global initialization for this file. */ diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index fdbff5cf6bf..f94baa58aba 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -127,11 +127,10 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) self_finishbp->return_value = Py_None; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); gdbpy_print_stack (); - } + }) } /* Triggered when gdbpy_should_stop has triggered the `stop' callback @@ -147,11 +146,10 @@ bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj) disable_breakpoint (bp_obj->bp); gdb_assert (bp_obj->bp->disposition == disp_del); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); gdbpy_print_stack (); - } + }) } /* Python function to create a new breakpoint. */ @@ -208,11 +206,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) frame_id = get_frame_id (prev_frame); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return -1; - } + }) if (PyErr_Occurred ()) return -1; @@ -267,11 +264,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { /* Just swallow. Either the return type or the function value remain NULL. */ - } + }) if (self_bpfinish->func_symbol == nullptr || self_bpfinish->function_value == nullptr) @@ -303,10 +299,9 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &code_breakpoint_ops, 0, 1, internal_bp, 0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_SET_HANDLE_EXCEPTION (except); - } + }) self_bpfinish->py_bp.bp->frame_id = frame_id; self_bpfinish->py_bp.is_finish_bp = 1; @@ -365,11 +360,10 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b, || frame_find_by_id (b->frame_id) == NULL)) bpfinishpy_out_of_scope (finish_bp); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); gdbpy_print_stack (); - } + }) } } } diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index cbce9457755..ba5163dd9db 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -96,10 +96,9 @@ frapy_is_valid (PyObject *self, PyObject *args) { frame = frame_object_to_frame_info (self); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (frame == NULL) Py_RETURN_FALSE; @@ -124,10 +123,9 @@ frapy_name (PyObject *self, PyObject *args) name = find_frame_funname (frame, &lang, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (name) { @@ -158,10 +156,9 @@ frapy_type (PyObject *self, PyObject *args) type = get_frame_type (frame); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return gdb_py_object_from_longest (type).release (); } @@ -179,10 +176,9 @@ frapy_arch (PyObject *self, PyObject *args) { FRAPY_REQUIRE_VALID (self, frame); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return gdbarch_to_arch_object (obj->gdbarch); } @@ -200,10 +196,9 @@ frapy_unwind_stop_reason (PyObject *self, PyObject *args) { FRAPY_REQUIRE_VALID (self, frame); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) stop_reason = get_frame_unwind_stop_reason (frame); @@ -225,10 +220,9 @@ frapy_pc (PyObject *self, PyObject *args) pc = get_frame_pc (frame); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return gdb_py_object_from_ulongest (pc).release (); } @@ -261,10 +255,9 @@ frapy_read_register (PyObject *self, PyObject *args) if (val == NULL) PyErr_SetString (PyExc_ValueError, _("Can't read register.")); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return val == NULL ? NULL : value_to_value_object (val); } @@ -283,10 +276,9 @@ frapy_block (PyObject *self, PyObject *args) FRAPY_REQUIRE_VALID (self, frame); block = get_frame_block (frame, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) for (fn_block = block; fn_block != NULL && fn_block->function () == NULL; @@ -328,10 +320,9 @@ frapy_function (PyObject *self, PyObject *args) gdb::unique_xmalloc_ptr funname = find_frame_funname (frame, &funlang, &sym); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (sym) return symbol_to_symbol_object (sym); @@ -370,11 +361,10 @@ frame_info_to_frame_object (frame_info_ptr frame) } frame_obj->gdbarch = get_frame_arch (frame); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return NULL; - } + }) return (PyObject *) frame_obj.release (); } @@ -395,10 +385,9 @@ frapy_older (PyObject *self, PyObject *args) prev = get_prev_frame (frame); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (prev) prev_obj = frame_info_to_frame_object (prev); @@ -427,10 +416,9 @@ frapy_newer (PyObject *self, PyObject *args) next = get_next_frame (frame); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (next) next_obj = frame_info_to_frame_object (next); @@ -459,10 +447,9 @@ frapy_find_sal (PyObject *self, PyObject *args) symtab_and_line sal = find_frame_sal (frame); sal_obj = symtab_and_line_to_sal_object (sal); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return sal_obj; } @@ -518,11 +505,10 @@ frapy_read_var (PyObject *self, PyObject *args) var = lookup_sym.symbol; block = lookup_sym.block; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return NULL; - } + }) if (!var) { @@ -545,10 +531,9 @@ frapy_read_var (PyObject *self, PyObject *args) val = read_var_value (var, block, frame); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return value_to_value_object (val); } @@ -566,10 +551,9 @@ frapy_select (PyObject *self, PyObject *args) select_frame (fi); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -587,10 +571,9 @@ frapy_level (PyObject *self, PyObject *args) return gdb_py_object_from_longest (frame_relative_level (fi)).release (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -610,10 +593,9 @@ frapy_language (PyObject *self, PyObject *args) return host_string_to_python_string (lang_def->name ()).release (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -630,10 +612,9 @@ gdbpy_newest_frame (PyObject *self, PyObject *args) { frame = get_current_frame (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return frame_info_to_frame_object (frame); } @@ -650,10 +631,9 @@ gdbpy_selected_frame (PyObject *self, PyObject *args) { frame = get_selected_frame ("No frame is currently selected."); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return frame_info_to_frame_object (frame); } diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index 0d7dc48c5a0..891191e6e6c 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -1147,11 +1147,10 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, { gdbarch = get_frame_arch (frame); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { /* Let gdb try to print the stack trace. */ return EXT_LANG_BT_NO_FILTERS; - } + }) gdbpy_enter enter_py (gdbarch); @@ -1232,11 +1231,10 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, success = py_print_frame (item.get (), flags, args_type, out, 0, levels_printed.get ()); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { gdbpy_convert_exception (except); success = EXT_LANG_BT_ERROR; - } + }) /* Do not exit on error printing a single frame. Print the error and continue with other frames. */ diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index af388d5ed72..9018a1ae9c4 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -45,8 +45,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, p = command_line_input (prompt, "python"); } /* Handle errors by raising Python exceptions. */ - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { /* Detect user interrupt (Ctrl-C). */ if (except.reason == RETURN_QUIT) return NULL; @@ -59,7 +58,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, gdbpy_convert_exception (except); PyEval_SaveThread (); return NULL; - } + }) /* Detect EOF (Ctrl-D). */ if (p == NULL) diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 8847a6d9308..62224cffa2a 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -427,10 +427,9 @@ infpy_threads (PyObject *self, PyObject *args) { update_thread_list (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) tuple = PyTuple_New (inf_obj->nthreads); if (!tuple) @@ -575,10 +574,9 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) read_memory (addr, buffer.get (), length); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return gdbpy_buffer_to_membuf (std::move (buffer), addr, length); @@ -766,10 +764,9 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) if (thread_info != NULL) return thread_to_thread_object (thread_info).release (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index 34f60526ac9..1b289cb94a3 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -94,10 +94,9 @@ thpy_get_details (PyObject *self, void *ignore) { extra_info = target_extra_thread_info (thread_obj->thread); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (extra_info == nullptr) Py_RETURN_NONE; @@ -212,10 +211,9 @@ thpy_switch (PyObject *self, PyObject *args) { switch_to_thread (thread_obj->thread); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -297,10 +295,9 @@ thpy_thread_handle (PyObject *self, PyObject *args) { hv = target_thread_info_to_thread_handle (thread_obj->thread); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (hv.size () == 0) { diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index 8cd8b91e91b..405f876c1cc 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -142,10 +142,9 @@ stpy_convert_to_value (PyObject *self, PyObject *args) break; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return value_to_value_object (val); } diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index 8e545febb17..a5e31648807 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -168,10 +168,9 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args) { pcs = find_pcs_for_symtab_line (symtab, py_line, &best_entry); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return build_line_table_tuple_from_pcs (py_line, pcs); } diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index c278925531b..0859cf50deb 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -160,10 +160,9 @@ objfpy_get_build_id (PyObject *self, void *closure) { build_id = build_id_bfd_get (objfile->obfd.get ()); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (build_id != NULL) { @@ -451,10 +450,9 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw) symbol_file_add_separate (abfd, file_name, 0, obj->objfile); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -485,10 +483,9 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) return symbol_to_symbol_object (sym); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -519,10 +516,9 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw) return symbol_to_symbol_object (sym); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index cab0c563b0e..78009ed9994 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -810,12 +810,11 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) set_doc.get (), show_doc.get (), doc.get (), set_list, show_list); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { Py_DECREF (self); gdbpy_convert_exception (except); return -1; - } + }) return 0; } diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 9276807341e..c798cb70383 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -217,9 +217,7 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) } } } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) return result; } @@ -665,10 +663,9 @@ gdbpy_get_varobj_pretty_printer (struct value *value) { value = value_copy (value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) gdbpy_ref<> val_obj (value_to_value_object (value)); if (val_obj == NULL) diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c index 4eb33e8292f..94195a9ce4a 100644 --- a/gdb/python/py-progspace.c +++ b/gdb/python/py-progspace.c @@ -420,10 +420,9 @@ pspy_block_for_pc (PyObject *o, PyObject *args) if (cust != NULL && cust->objfile () != NULL) block = block_for_pc (pc); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (cust == NULL || cust->objfile () == NULL) Py_RETURN_NONE; @@ -462,10 +461,9 @@ pspy_find_pc_line (PyObject *o, PyObject *args) sal = find_pc_line (pc, 0); result = symtab_and_line_to_sal_object (sal); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c index 85401010f0a..acdf7ca7c94 100644 --- a/gdb/python/py-record-btrace.c +++ b/gdb/python/py-record-btrace.c @@ -203,10 +203,9 @@ recpy_bt_insn_sal (PyObject *self, void *closure) { result = symtab_and_line_to_sal_object (find_pc_line (insn->pc, 0)); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -274,10 +273,9 @@ recpy_bt_insn_data (PyObject *self, void *closure) buffer.resize (insn->size); read_memory (insn->pc, buffer.data (), insn->size); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) object = PyBytes_FromStringAndSize ((const char *) buffer.data (), insn->size); @@ -304,11 +302,10 @@ recpy_bt_insn_decoded (PyObject *self, void *closure) { gdb_print_insn (target_gdbarch (), insn->pc, &strfile, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return NULL; - } + }) return PyBytes_FromString (strfile.string ().c_str ()); @@ -783,10 +780,9 @@ recpy_bt_goto (PyObject *self, PyObject *args) else target_goto_record (obj->number); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c index fd5cfee84eb..6d6ce552aa6 100644 --- a/gdb/python/py-record.c +++ b/gdb/python/py-record.c @@ -607,10 +607,9 @@ gdbpy_start_recording (PyObject *self, PyObject *args) record_start (method, format, 0); ret = gdbpy_current_recording (self, args); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); - } + }) return ret; } @@ -641,10 +640,9 @@ gdbpy_stop_recording (PyObject *self, PyObject *args) { record_stop (0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 93c86964f3e..79cb58f0365 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -220,10 +220,9 @@ sympy_needs_frame (PyObject *self, void *closure) { result = symbol_read_needs_frame (symbol); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (result) Py_RETURN_TRUE; @@ -303,10 +302,9 @@ sympy_value (PyObject *self, PyObject *args) can happen with nested functions). */ value = read_var_value (symbol, NULL, frame_info); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return value_to_value_object (value); } @@ -408,10 +406,9 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) selected_frame = get_selected_frame (_("No frame selected.")); block = get_frame_block (selected_frame, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) } try @@ -419,10 +416,9 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) symbol = lookup_symbol (name, block, (domain_enum) domain, &is_a_field_of_this).symbol; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) gdbpy_ref<> ret_tuple (PyTuple_New (2)); if (ret_tuple == NULL) @@ -467,10 +463,9 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) { symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (symbol) { @@ -515,10 +510,9 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw) = get_selected_frame (_("No frame selected.")); block = get_frame_block (selected_frame, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { /* Nothing. */ - } + }) try { @@ -530,10 +524,9 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw) if (symbol == nullptr) symbol = lookup_static_symbol (name, (domain_enum) domain).symbol; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (symbol) { @@ -603,10 +596,9 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) } } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return return_list.release (); } diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c index 6a92251a705..6c7752cf098 100644 --- a/gdb/python/py-tui.c +++ b/gdb/python/py-tui.c @@ -366,11 +366,10 @@ gdbpy_register_tui_window (PyObject *self, PyObject *args, PyObject *kw) gdbpy_tui_window_maker constr (gdbpy_ref<>::new_reference (cons_obj)); tui_register_window (name, constr); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return nullptr; - } + }) Py_RETURN_NONE; } diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 3e558dee7ad..3705e3105f5 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -314,10 +314,9 @@ typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind) { checked_type = check_typedef (checked_type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) gdbpy_ref<> type_holder; if (checked_type != type) @@ -475,10 +474,9 @@ typy_strip_typedefs (PyObject *self, PyObject *args) { type = check_typedef (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return type_to_type_object (type); } @@ -496,10 +494,9 @@ typy_get_composite (struct type *type) { type = check_typedef (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (!type->is_pointer_or_reference ()) break; @@ -566,10 +563,9 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) if (is_vector) make_vector_type (array); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return type_to_type_object (array); } @@ -600,10 +596,9 @@ typy_pointer (PyObject *self, PyObject *args) { type = lookup_pointer_type (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return type_to_type_object (type); } @@ -672,10 +667,9 @@ typy_reference (PyObject *self, PyObject *args) { type = lookup_lvalue_reference_type (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return type_to_type_object (type); } @@ -706,10 +700,9 @@ typy_const (PyObject *self, PyObject *args) { type = make_cv_type (1, 0, type, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return type_to_type_object (type); } @@ -724,10 +717,9 @@ typy_volatile (PyObject *self, PyObject *args) { type = make_cv_type (0, 1, type, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return type_to_type_object (type); } @@ -742,10 +734,9 @@ typy_unqualified (PyObject *self, PyObject *args) { type = make_cv_type (0, 0, type, NULL); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return type_to_type_object (type); } @@ -763,9 +754,7 @@ typy_get_sizeof (PyObject *self, void *closure) size_varies = TYPE_HAS_DYNAMIC_LENGTH (type); } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) /* Ignore exceptions. */ @@ -785,10 +774,9 @@ typy_get_alignof (PyObject *self, void *closure) { align = type_align (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { align = 0; - } + }) /* Ignore exceptions. */ @@ -806,10 +794,9 @@ typy_get_dynamic (PyObject *self, void *closure) { result = is_dynamic_type (type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { /* Ignore exceptions. */ - } + }) if (result) Py_RETURN_TRUE; @@ -833,10 +820,9 @@ typy_lookup_typename (const char *type_name, const struct block *block) type = lookup_typename (current_language, type_name, block, 0); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return type; } @@ -887,10 +873,9 @@ typy_lookup_type (struct demangle_component *demangled, break; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) } /* If we have a type from the switch statement above, just return @@ -929,10 +914,9 @@ typy_legacy_template_argument (struct type *type, const struct block *block, /* Note -- this is not thread-safe. */ info = cp_demangled_name_to_comp (type->name (), &err); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (! info) { @@ -1009,10 +993,9 @@ typy_template_argument (PyObject *self, PyObject *args) if (TYPE_IS_REFERENCE (type)) type = check_typedef (type->target_type ()); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) /* We might not have DW_TAG_template_*, so try to parse the type's name. This is inefficient if we do not have a template type -- @@ -1041,10 +1024,9 @@ typy_template_argument (PyObject *self, PyObject *args) { val = value_of_variable (sym, block); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return value_to_value_object (val); } @@ -1060,10 +1042,9 @@ typy_str (PyObject *self) &thetype, -1, 0, &type_print_raw_options); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return PyUnicode_Decode (thetype.c_str (), thetype.size (), host_charset (), NULL); @@ -1094,12 +1075,11 @@ typy_richcompare (PyObject *self, PyObject *other, int op) { result = types_deeply_equal (type1, type2); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { /* If there is a GDB exception, a comparison is not capable (or trusted), so exit. */ GDB_PY_HANDLE_EXCEPTION (except); - } + }) } if (op == (result ? Py_EQ : Py_NE)) diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 20b0ab460cc..a835e22c4d7 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -135,10 +135,9 @@ pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr) rc = 1; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); - } + }) return rc; } @@ -199,10 +198,9 @@ unwind_infopy_str (PyObject *self) value_print (value, &stb, &opts); stb.puts (")"); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) } else stb.puts (")"); @@ -350,10 +348,9 @@ pending_framepy_str (PyObject *self) sp_str = core_addr_to_string_nz (get_frame_sp (frame)); pc_str = core_addr_to_string_nz (get_frame_pc (frame)); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return PyUnicode_FromFormat ("SP=%s,PC=%s", sp_str, pc_str); } @@ -393,10 +390,9 @@ pending_framepy_read_register (PyObject *self, PyObject *args) "Cannot read register %d from frame.", regnum); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return val == NULL ? NULL : value_to_value_object (val); } diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 58c18c60e2c..b7f7bd4385a 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -242,10 +242,9 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr) { *addr = value_as_address (value_object_to_value (obj)); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_SET_HANDLE_EXCEPTION (except); - } + }) } else { diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 92a15304c34..69cd3833c02 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -245,10 +245,9 @@ valpy_dereference (PyObject *self, PyObject *args) res_val = value_ind (((value_object *) self)->value); result = value_to_value_object (res_val); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -288,10 +287,9 @@ valpy_referenced_value (PyObject *self, PyObject *args) result = value_to_value_object (res_val); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -311,10 +309,9 @@ valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode) self_val = ((value_object *) self)->value; result = value_to_value_object (value_ref (self_val, refcode)); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -347,10 +344,9 @@ valpy_const_value (PyObject *self, PyObject *args) res_val = make_cv_value (1, 0, self_val); result = value_to_value_object (res_val); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -371,11 +367,10 @@ valpy_get_address (PyObject *self, void *closure) res_val = value_addr (val_obj->value); val_obj->address = value_to_value_object (res_val); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { val_obj->address = Py_None; Py_INCREF (Py_None); - } + }) } Py_XINCREF (val_obj->address); @@ -449,10 +444,9 @@ valpy_get_dynamic_type (PyObject *self, void *closure) type = NULL; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (type == NULL) obj->dynamic_type = valpy_get_type (self, NULL); @@ -555,10 +549,9 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) str_obj = gdbpy_create_lazy_string_object (addr, length, user_encoding, type); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return str_obj; } @@ -590,10 +583,9 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw) { c_get_string (value, &buffer, &length, &char_type, &la_encoding); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding; return PyUnicode_Decode ((const char *) buffer.get (), @@ -772,10 +764,9 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) common_val_print (((value_object *) self)->value, &stb, 0, &opts, current_language); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL); } @@ -817,10 +808,9 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) result = value_to_value_object (res_val); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -895,10 +885,9 @@ value_has_field (struct value *v, PyObject *field) else has_field = 0; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_SET_HANDLE_EXCEPTION (except); - } + }) return has_field; } @@ -1106,10 +1095,9 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) { ftype = check_typedef (value_type (function)); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (ftype->code () != TYPE_CODE_FUNC) { @@ -1153,10 +1141,9 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) gdb::make_array_view (vargs, args_count)); result = value_to_value_object (return_value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -1178,10 +1165,9 @@ valpy_str (PyObject *self) common_val_print (((value_object *) self)->value, &stb, 0, &opts, current_language); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL); } @@ -1197,10 +1183,9 @@ valpy_get_is_optimized_out (PyObject *self, void *closure) { opt = value_optimized_out (value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (opt) Py_RETURN_TRUE; @@ -1219,10 +1204,9 @@ valpy_get_is_lazy (PyObject *self, void *closure) { opt = value_lazy (value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (opt) Py_RETURN_TRUE; @@ -1241,10 +1225,9 @@ valpy_fetch_lazy (PyObject *self, PyObject *args) if (value_lazy (value)) value_fetch_lazy (value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -1412,10 +1395,9 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) { result = valpy_binop_throw (opcode, self, other); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -1480,10 +1462,9 @@ valpy_negative (PyObject *self) val = value_neg (((value_object *) self)->value); result = value_to_value_object (val); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return result; } @@ -1507,10 +1488,9 @@ valpy_absolute (PyObject *self) if (value_less (value, value_zero (value_type (value), not_lval))) isabs = 0; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (isabs) return valpy_positive (self); @@ -1563,10 +1543,9 @@ valpy_invert (PyObject *self) { val = value_complement (((value_object *) self)->value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return value_to_value_object (val); } @@ -1690,10 +1669,9 @@ valpy_richcompare (PyObject *self, PyObject *other, int op) { result = valpy_richcompare_throw (self, other, op); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) /* In this case, the Python exception has already been set. */ if (result < 0) @@ -1729,10 +1707,9 @@ valpy_long (PyObject *self) l = value_as_long (value); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (type->is_unsigned ()) return gdb_py_object_from_ulongest (l).release (); @@ -1764,10 +1741,9 @@ valpy_float (PyObject *self) else error (_("Cannot convert value to float.")); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return PyFloat_FromDouble (d); } @@ -1910,11 +1886,10 @@ convert_value_from_python (PyObject *obj) PyErr_Format (PyExc_TypeError, _("Could not convert Python object: %S."), obj); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { gdbpy_convert_exception (except); return NULL; - } + }) return value; } @@ -1933,10 +1908,9 @@ gdbpy_history (PyObject *self, PyObject *args) { res_val = access_value_history (i); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return value_to_value_object (res_val); } @@ -1960,10 +1934,9 @@ gdbpy_add_history (PyObject *self, PyObject *args) int idx = record_latest_value (value); return gdb_py_object_from_longest (idx).release (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return nullptr; } @@ -1997,10 +1970,9 @@ gdbpy_convenience_variable (PyObject *self, PyObject *args) res_val = NULL; } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (res_val == NULL) Py_RETURN_NONE; @@ -2043,10 +2015,9 @@ gdbpy_set_convenience_variable (PyObject *self, PyObject *args) set_internalvar (var, value); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } diff --git a/gdb/python/python.c b/gdb/python/python.c index 29f2010ee8e..d0c31afd408 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -551,10 +551,9 @@ gdbpy_parameter (PyObject *self, PyObject *args) { found = lookup_cmd_composition (newarg.c_str (), &alias, &prefix, &cmd); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { GDB_PY_HANDLE_EXCEPTION (ex); - } + }) if (!found) return PyErr_Format (PyExc_RuntimeError, @@ -675,8 +674,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { /* If an exception occurred then we won't hit normal_stop (), or have an exception reach the top level of the event loop, which are the two usual places in which stdin would be re-enabled. So, before we @@ -684,7 +682,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) re-enable stdin here. */ async_enable_stdin (); GDB_PY_HANDLE_EXCEPTION (except); - } + }) if (to_string) return PyUnicode_FromString (to_string_res.c_str ()); @@ -903,12 +901,11 @@ gdbpy_decode_line (PyObject *self, PyObject *args) sals = def_sal; } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* We know this will always throw. */ gdbpy_convert_exception (ex); return NULL; - } + }) if (!sals.empty ()) { @@ -961,10 +958,9 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args) gdbpy_allow_threads allow_threads; result = parse_and_eval (expr_str); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) return value_to_value_object (result); } @@ -1427,10 +1423,9 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) gdb_printf (gdb_stdout, "%s", arg); } } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { GDB_PY_HANDLE_EXCEPTION (except); - } + }) Py_RETURN_NONE; } @@ -1500,9 +1495,7 @@ gdbpy_print_stack (void) { begin_line (); } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) } /* Print "message", just error print message. */ else @@ -1531,9 +1524,7 @@ gdbpy_print_stack (void) gdb_printf (gdb_stderr, "Python Exception %s: %s\n", type.get (), msg.get ()); } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) } } @@ -2217,13 +2208,12 @@ test_python () { CMD (output); } - catch (const gdb_exception &e) - { + CATCH_ERROR_QUIT (e, { saw_exception = true; SELF_CHECK (e.reason == RETURN_ERROR); SELF_CHECK (e.error == GENERIC_ERROR); SELF_CHECK (*e.message == "Python not initialized"); - } + }) SELF_CHECK (saw_exception); SELF_CHECK (output.empty ()); } @@ -2237,13 +2227,12 @@ test_python () { CMD (output); } - catch (const gdb_exception &e) - { + CATCH_ERROR_QUIT (e, { saw_exception = true; SELF_CHECK (e.reason == RETURN_ERROR); SELF_CHECK (e.error == GENERIC_ERROR); SELF_CHECK (*e.message == "Error while executing Python code."); - } + }) SELF_CHECK (saw_exception); std::string ref_output_0 ("Traceback (most recent call last):\n" " File \"\", line 0, in \n" diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 5cf978b932c..42630da52ac 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -293,10 +293,9 @@ record_btrace_on_new_thread (struct thread_info *tp) { btrace_enable (tp, &record_btrace_conf); } - catch (const gdb_exception_error &error) - { + CATCH_ERROR (error, { warning ("%s", error.what ()); - } + }) } /* Enable automatic tracing of new threads. */ @@ -1493,11 +1492,10 @@ record_btrace_target::insert_breakpoint (struct gdbarch *gdbarch, { ret = this->beneath ()->insert_breakpoint (gdbarch, bp_tgt); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { replay_memory_access = old; throw; - } + }) replay_memory_access = old; return ret; @@ -1523,11 +1521,10 @@ record_btrace_target::remove_breakpoint (struct gdbarch *gdbarch, { ret = this->beneath ()->remove_breakpoint (gdbarch, bp_tgt, reason); } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { replay_memory_access = old; throw; - } + }) replay_memory_access = old; return ret; @@ -2067,15 +2064,14 @@ record_btrace_start_replaying (struct thread_info *tp) if (upd_step_stack_frame_id) tp->control.step_stack_frame_id = frame_id; } - catch (const gdb_exception &except) - { + CATCH_ERROR_QUIT (except, { xfree (btinfo->replay); btinfo->replay = NULL; registers_changed_thread (tp); throw; - } + }) return replay; } @@ -2890,11 +2886,10 @@ cmd_record_btrace_bts_start (const char *args, int from_tty) { execute_command ("target record-btrace", from_tty); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { record_btrace_conf.format = BTRACE_FORMAT_NONE; throw; - } + }) } /* Start recording in Intel Processor Trace format. */ @@ -2911,11 +2906,10 @@ cmd_record_btrace_pt_start (const char *args, int from_tty) { execute_command ("target record-btrace", from_tty); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { record_btrace_conf.format = BTRACE_FORMAT_NONE; throw; - } + }) } /* Alias for "target record". */ @@ -2932,20 +2926,18 @@ cmd_record_btrace_start (const char *args, int from_tty) { execute_command ("target record-btrace", from_tty); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { record_btrace_conf.format = BTRACE_FORMAT_BTS; try { execute_command ("target record-btrace", from_tty); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { record_btrace_conf.format = BTRACE_FORMAT_NONE; throw; - } - } + }) + }) } /* The "show record btrace replay-memory-access" command. */ diff --git a/gdb/record-full.c b/gdb/record-full.c index 48b92281fe6..198cd6510df 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -760,11 +760,10 @@ record_full_message (struct regcache *regcache, enum gdb_signal signal) if (ret < 0) error (_("Process record: failed to record execution log.")); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { record_full_list_release (record_full_arch_list_tail); throw; - } + }) record_full_list->next = record_full_arch_list_head; record_full_arch_list_head->prev = record_full_list; @@ -784,11 +783,10 @@ record_full_message_wrapper_safe (struct regcache *regcache, { record_full_message (regcache, signal); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); return false; - } + }) return true; } @@ -1429,8 +1427,7 @@ record_full_wait_1 (struct target_ops *ops, status->set_stopped (GDB_SIGNAL_TRAP); } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { if (execution_direction == EXEC_REVERSE) { if (record_full_list->next) @@ -1440,7 +1437,7 @@ record_full_wait_1 (struct target_ops *ops, record_full_list = record_full_list->prev; throw; - } + }) } signal (SIGINT, handle_sigint); @@ -2456,11 +2453,10 @@ record_full_restore (void) record_full_arch_list_add (rec); } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { record_full_list_release (record_full_arch_list_tail); throw; - } + }) /* Add record_full_arch_list_head to the end of record list. */ record_full_first.next = record_full_arch_list_head; diff --git a/gdb/regcache.c b/gdb/regcache.c index 650e5bbe955..4fd719bee52 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1349,10 +1349,9 @@ regcache_read_pc_protected (regcache *regcache) { pc = regcache_read_pc (regcache); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { pc = 0; - } + }) return pc; } diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index fe191fb6069..03b6bb7b8aa 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -1191,13 +1191,12 @@ remote_fileio_request (remote_target *remote, char *buf, int ctrlc_pending_p) { do_remote_fileio_request (remote, buf); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { if (ex.reason == RETURN_QUIT) remote_fileio_reply (remote, -1, FILEIO_EINTR); else remote_fileio_reply (remote, -1, FILEIO_EIO); - } + }) } quit_handler = remote_fileio_o_quit_handler; diff --git a/gdb/remote.c b/gdb/remote.c index 5118ecd0a31..f8ae98e0c5c 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1280,8 +1280,7 @@ remote_target::remote_get_noisy_reply () gdbarch_relocate_instruction (target_gdbarch (), &to, from); relocated = 1; } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { if (ex.error == MEMORY_ERROR) { /* Propagate memory errors silently back to the @@ -1298,7 +1297,7 @@ remote_target::remote_get_noisy_reply () _("warning: relocating instruction: ")); } putpkt ("E01"); - } + }) if (relocated) { @@ -5868,14 +5867,13 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p) { remote->start_remote (from_tty, extended_p); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* Pop the partially set up target - unless something else did already before throwing the exception. */ if (ex.error != TARGET_CLOSE_ERROR) remote_unpush_target (remote); throw; - } + }) } remote_btrace_reset (rs); @@ -10178,8 +10176,7 @@ remote_target::remote_kill_k () { putpkt ("k"); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error == TARGET_CLOSE_ERROR) { /* If we got an (EOF) error that caused the target @@ -10195,7 +10192,7 @@ remote_target::remote_kill_k () the target. Just propagate the exception, and let the user or higher layers decide what to do. */ throw; - } + }) } void @@ -13508,15 +13505,14 @@ remote_target::get_trace_status (struct trace_status *ts) { p = remote_get_noisy_reply (); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != TARGET_CLOSE_ERROR) { exception_fprintf (gdb_stderr, ex, "qTStatus: "); return -1; } throw; - } + }) result = packet_ok (p, &remote_protocol_packets[PACKET_qTStatus]); @@ -14169,11 +14165,10 @@ remote_target::enable_btrace (thread_info *tp, { btrace_read_config (tp, &tinfo->conf); } - catch (const gdb_exception_error &err) - { + CATCH_ERROR (err, { if (err.message != NULL) warning ("%s", err.what ()); - } + }) return tinfo; } diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 0a050b272ff..568b960bee9 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1119,13 +1119,12 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, val = value_of_register (regnum, frame); regtype = value_type (val); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* Handle failure to read a register without interrupting the entire 'info registers' flow. */ gdb_printf (file, "%s\n", ex.what ()); return; - } + }) print_raw_format = (value_entirely_available (val) && !value_optimized_out (val)); @@ -3506,11 +3505,10 @@ riscv_frame_this_id (frame_info_ptr this_frame, cache = riscv_frame_cache (this_frame, prologue_cache); *this_id = cache->this_id; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* Ignore errors, this leaves the frame id as the predefined outer frame id which terminates the backtrace at this point. */ - } + }) } /* Implement the prev_register callback for RiscV frame unwinder. */ diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index d47974b51d1..8418f98b4f5 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -679,13 +679,12 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch, { pc = read_memory_unsigned_integer (addr, tdep->wordsize, byte_order); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* An error occured during reading. Probably a memory error due to the section not being loaded yet. This address cannot be a function descriptor. */ return addr; - } + }) pc_section = find_pc_section (pc); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index aac424a65be..09996758a5f 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -3587,12 +3587,11 @@ rs6000_frame_cache (frame_info_ptr this_frame, void **this_cache) cache->base = get_frame_register_unsigned (this_frame, gdbarch_sp_regnum (gdbarch)); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; return (struct rs6000_frame_cache *) (*this_cache); - } + }) /* If the function appears to be frameless, check a couple of likely indicators that we have simply failed to find the frame setup. @@ -3816,11 +3815,10 @@ rs6000_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache) cache->saved_regs[gdbarch_pc_regnum (gdbarch)].set_value (lr); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) return cache; } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 8673a908698..dc2d5806af3 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1460,12 +1460,11 @@ rust_structop::evaluate (struct type *expect_type, result = value_struct_elt (&lhs, {}, field_name, NULL, "structure"); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { error (_("Could not find field %s of struct variant %s::%s"), field_name, outer_type->name (), rust_last_path_segment (type->name ())); - } + }) } else result = value_struct_elt (&lhs, {}, field_name, NULL, "structure"); diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index f5eb63ec1e3..2ede71e13a9 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -2123,8 +2123,7 @@ rust_language::parser (struct parser_state *state) const { result = parser.parse_entry_point (); } - catch (const gdb_exception &exc) - { + CATCH_ERROR_QUIT (exc, { if (state->parse_completion) { result = std::move (parser.completion_op); @@ -2133,7 +2132,7 @@ rust_language::parser (struct parser_state *state) const } else throw; - } + }) state->set_operation (std::move (result)); @@ -2185,10 +2184,9 @@ rust_lex_exception_test (rust_parser *parser, const char *input, rust_lex_test_one (parser, input, DECIMAL_INTEGER); SELF_CHECK (0); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { SELF_CHECK (strcmp (except.what (), err) == 0); - } + }) } /* Test that INPUT lexes as the identifier, string, or byte-string diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index d0dba7654bb..8f1e8059689 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -2594,11 +2594,10 @@ s390_frame_unwind_cache (frame_info_ptr this_frame, if (!s390_prologue_frame_unwind_cache (this_frame, info)) s390_backchain_frame_unwind_cache (this_frame, info); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (ex.error != NOT_AVAILABLE_ERROR) throw; - } + }) return info; } diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index b866a0b4517..9dae8566f87 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -725,9 +725,7 @@ enable_break (void) { tmp_bfd = solib_bfd_open (buf); } - catch (const gdb_exception &ex) - { - } + CATCH_ERROR_QUIT (ex, {}) if (tmp_bfd == NULL) { diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 6ca303c3566..b226e816975 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -563,9 +563,7 @@ enable_break2 (void) { tmp_bfd = solib_bfd_open (buf); } - catch (const gdb_exception &ex) - { - } + CATCH_ERROR_QUIT (ex, {}) if (tmp_bfd == NULL) { diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 6acaf87960b..28afc2914a3 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -776,10 +776,9 @@ solib_svr4_r_map (CORE_ADDR debug_base) addr = read_memory_typed_address (debug_base + lmo->r_map_offset, ptr_type); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { exception_print (gdb_stderr, ex); - } + }) return addr; } @@ -815,10 +814,9 @@ solib_svr4_r_ldsomap (struct svr4_info *info) = read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset, lmo->r_version_size, byte_order); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { exception_print (gdb_stderr, ex); - } + }) if (version < 2 || lmo->r_ldsomap_offset == -1) return 0; @@ -843,10 +841,9 @@ solib_svr4_r_next (CORE_ADDR debug_base) = read_memory_unsigned_integer (debug_base + lmo->r_version_offset, lmo->r_version_size, byte_order); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { exception_print (gdb_stderr, ex); - } + }) /* The r_next field is added with r_version == 2. */ if (version < 2 || lmo->r_next_offset == -1) @@ -1809,11 +1806,10 @@ solib_event_probe_action (struct probe_and_action *pa) { probe_argc = pa->prob->get_argument_count (get_frame_arch (frame)); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { exception_print (gdb_stderr, ex); probe_argc = 0; - } + }) /* If get_argument_count throws an exception, probe_argc will be set to zero. However, if pa->prob does not have arguments, then @@ -2017,11 +2013,10 @@ svr4_handle_solib_event (void) { val = pa->prob->evaluate_argument (1, frame); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { exception_print (gdb_stderr, ex); val = NULL; - } + }) if (val == NULL) return; @@ -2069,11 +2064,10 @@ svr4_handle_solib_event (void) { val = pa->prob->evaluate_argument (2, frame); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { exception_print (gdb_stderr, ex); return; - } + }) if (val != NULL) lm = value_as_address (val); @@ -2226,13 +2220,12 @@ svr4_find_and_create_probe_breakpoints (svr4_info *info, { p->get_argument_count (gdbarch); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { exception_print (gdb_stderr, ex); warning (_("Initializing probes-based dynamic linker interface " "failed.\nReverting to original interface.")); return false; - } + }) } } @@ -2415,9 +2408,7 @@ enable_break (struct svr4_info *info, int from_tty) { tmp_bfd = solib_bfd_open (interp_name); } - catch (const gdb_exception &ex) - { - } + CATCH_ERROR_QUIT (ex, {}) if (tmp_bfd == NULL) goto bkpt_at_symbol; diff --git a/gdb/solib.c b/gdb/solib.c index 7cfdd81114c..38995910bb7 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -739,12 +739,11 @@ solib_read_symbols (struct so_list *so, symfile_add_flags flags) so->symbols_loaded = 1; } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { exception_fprintf (gdb_stderr, e, _("Error while reading shared" " library symbols for %s:\n"), so->so_name); - } + }) return true; } @@ -789,12 +788,11 @@ update_solib_list (int from_tty) { ops->open_symbol_file_object (from_tty); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_fprintf (gdb_stderr, ex, "Error reading attached " "process's symbol file.\n"); - } + }) } } @@ -915,12 +913,11 @@ update_solib_list (int from_tty) } } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { exception_fprintf (gdb_stderr, e, _("Error while mapping shared " "library sections:\n")); - } + }) /* Notify any observer that the shared object has been loaded now that we've added it to GDB's tables. */ @@ -1370,13 +1367,12 @@ reload_shared_libraries_1 (int from_tty) solib_map_sections (so); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { exception_fprintf (gdb_stderr, e, _("Error while mapping " "shared library sections:\n")); got_error = true; - } + }) if (!got_error && (auto_solib_add || was_loaded || libpthread_solib_p (so))) diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 2cc5b37a817..6d2fd9120ab 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -222,11 +222,10 @@ source_cache::ensure (struct symtab *s) { contents = get_plain_source_lines (s, fullname); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { /* If 's' is not found, an exception is thrown. */ return false; - } + }) if (source_styling && gdb_stdout->can_emit_style_escape ()) { diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c index fc8bd065c4c..db3c33274ec 100644 --- a/gdb/sparc64-linux-tdep.c +++ b/gdb/sparc64-linux-tdep.c @@ -139,10 +139,9 @@ sparc64_linux_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout, if (si_code >= SEGV_ACCADI && si_code <= SEGV_ADIPERR) addr = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { return; - } + }) /* Print out ADI event based on sig_code value */ switch (si_code) diff --git a/gdb/stack.c b/gdb/stack.c index 653251c200b..136f7b92b6f 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -372,9 +372,7 @@ print_stack_frame (frame_info_ptr frame, int print_level, if (set_current_sal) set_current_sal_from_frame (frame); } - catch (const gdb_exception_error &e) - { - } + CATCH_ERROR (e, {}) } /* Print nameless arguments of frame FRAME on STREAM, where START is @@ -488,12 +486,11 @@ print_frame_arg (const frame_print_options &fp_opts, common_val_print_checked (arg->val, &stb, 2, &vp_opts, language); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { stb.printf (_(""), except.what ()); style = metadata_style.style (); - } + }) } } @@ -516,10 +513,9 @@ read_frame_local (struct symbol *sym, frame_info_ptr frame, { argp->val = read_var_value (sym, NULL, frame); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { argp->error.reset (xstrdup (except.what ())); - } + }) } /* Read in inferior function parameter SYM at FRAME into ARGP. This @@ -541,11 +537,10 @@ read_frame_arg (const frame_print_options &fp_opts, { val = read_var_value (sym, NULL, frame); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { val_error = (char *) alloca (except.message->size () + 1); strcpy (val_error, except.what ()); - } + }) } if (SYMBOL_COMPUTED_OPS (sym) != NULL @@ -561,14 +556,13 @@ read_frame_arg (const frame_print_options &fp_opts, ops = SYMBOL_COMPUTED_OPS (sym); entryval = ops->read_variable_at_entry (sym, frame); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (except.error != NO_ENTRY_VALUE_ERROR) { entryval_error = (char *) alloca (except.message->size () + 1); strcpy (entryval_error, except.what ()); } - } + }) if (entryval != NULL && value_optimized_out (entryval)) entryval = NULL; @@ -617,8 +611,7 @@ read_frame_arg (const frame_print_options &fp_opts, type_deref->length ())) val_equal = 1; } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { /* If the dereferenced content could not be fetched do not display anything. */ if (except.error == NO_ENTRY_VALUE_ERROR) @@ -629,7 +622,7 @@ read_frame_arg (const frame_print_options &fp_opts, = (char *) alloca (except.message->size () + 1); strcpy (entryval_error, except.what ()); } - } + }) /* Value was not a reference; and its content matches. */ if (val == val_deref) @@ -665,11 +658,10 @@ read_frame_arg (const frame_print_options &fp_opts, { val = read_var_value (sym, NULL, frame); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { val_error = (char *) alloca (except.message->size () + 1); strcpy (val_error, except.what ()); - } + }) } if (fp_opts.print_entry_values == print_entry_values_only || fp_opts.print_entry_values == print_entry_values_both @@ -977,12 +969,11 @@ do_gdb_disassembly (struct gdbarch *gdbarch, DISASSEMBLY_RAW_INSN, how_many, low, high); } - catch (const gdb_exception_error &exception) - { + CATCH_ERROR (exception, { /* If an exception was thrown while doing the disassembly, print the error message, to give the user a clue of what happened. */ exception_print (gdb_stderr, exception); - } + }) } /* Converts the PRINT_FRAME_INFO choice to an optional enum print_what. @@ -1398,9 +1389,7 @@ print_frame (const frame_print_options &fp_opts, { print_frame_args (fp_opts, func, frame, numargs, gdb_stdout); } - catch (const gdb_exception_error &e) - { - } + CATCH_ERROR (e, {}) /* FIXME: ARGS must be a list. If one argument is a string it will have " that will not be properly escaped. */ @@ -1592,8 +1581,7 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) caller_pc = frame_unwind_caller_pc (fi); caller_pc_p = 1; } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { switch (ex.error) { case NOT_AVAILABLE_ERROR: @@ -1608,7 +1596,7 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) ex.what ()); break; } - } + }) } if (caller_pc_p) @@ -3027,8 +3015,7 @@ frame_apply_command_count (const char *which_command, gdb_printf ("%s", cmd_result.c_str ()); } } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { fi = get_selected_frame (_("frame apply " "unable to get selected frame.")); if (!flags.silent) @@ -3040,7 +3027,7 @@ frame_apply_command_count (const char *which_command, else throw; } - } + }) } } @@ -3081,12 +3068,11 @@ frame_apply_level_cmd_completer (struct cmd_list_element *ignore, levels.skip_range (); } } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* get_number throws if it parses a negative number, for example. But a seemingly negative number may be the start of an option instead. */ - } + }) const char *cmd = levels.cur_tok (); diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index 78c0e091a6e..699f573980f 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -197,10 +197,9 @@ add_vsyscall_page (inferior *inf) name.c_str (), 0 /* from_tty */); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) } } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 09dd97ffca3..224d555a6c9 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -313,11 +313,10 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) { print_symbol (gdbarch, sym, depth + 1, outfile); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { exception_fprintf (gdb_stderr, ex, "Error printing symbol:\n"); - } + }) } } gdb_printf (outfile, "\n"); diff --git a/gdb/target.c b/gdb/target.c index 74925e139dc..17e36a4a4a2 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1318,8 +1318,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) } /* If an error occurred, print TLS related messages here. Otherwise, throw the error to some higher catcher. */ - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { int objfile_is_library = (objfile->flags & OBJF_SHARED); switch (ex.error) @@ -1368,7 +1367,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) throw; break; } - } + }) } else error (_("Cannot find thread-local variables on this target")); diff --git a/gdb/thread.c b/gdb/thread.c index 349fc01dd48..021dcbf0dce 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1497,8 +1497,7 @@ thread_try_catch_cmd (thread_info *thr, gdb::optional ada_task, gdb_printf ("%s", cmd_result.c_str ()); } } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (!flags.silent) { if (!flags.quiet) @@ -1508,7 +1507,7 @@ thread_try_catch_cmd (thread_info *thr, gdb::optional ada_task, else throw; } - } + }) } /* Option definition of "thread apply"'s "-ascending" option. */ @@ -1646,12 +1645,11 @@ thread_apply_command_completer (cmd_list_element *ignore, parser.skip_range (); } } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* get_tid_range throws if it parses a negative number, for example. But a seemingly negative number may be the start of an option instead. */ - } + }) const char *cmd = parser.cur_tok (); diff --git a/gdb/top.c b/gdb/top.c index e9794184f07..2d591c5a8c3 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1836,10 +1836,9 @@ quit_force (int *exit_arg, int from_tty) for (inferior *inf : all_inferiors ()) kill_or_detach (inf, from_tty); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) /* Give all pushed targets a chance to do minimal cleanup, and pop them all out. */ @@ -1850,10 +1849,9 @@ quit_force (int *exit_arg, int from_tty) { pop_all_targets (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) } /* Save the history information if it is appropriate to do so. */ @@ -1878,10 +1876,9 @@ quit_force (int *exit_arg, int from_tty) gdb_safe_append_history (); } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) /* Destroy any values currently allocated now instead of leaving it to global destructors, because that may be too late. For @@ -1894,10 +1891,9 @@ quit_force (int *exit_arg, int from_tty) { do_final_cleanups (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) exit (exit_code); } diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 3266f357a27..f991a0056cc 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -548,12 +548,11 @@ tfile_target_open (const char *arg, int from_tty) if (trace_regblock_size == 0) error (_("No register block size recorded in trace file")); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* Remove the partially set up target. */ current_inferior ()->unpush_target (&tfile_ops); throw; - } + }) inferior_appeared (current_inferior (), TFILE_PID); diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index e4bbc47daa9..8feaf4c6130 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -119,15 +119,14 @@ tui_disassemble (struct gdbarch *gdbarch, { pc = pc + gdb_print_insn (gdbarch, pc, &gdb_dis_out, NULL); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { /* If PC points to an invalid address then we'll catch a MEMORY_ERROR here, this should stop the disassembly, but otherwise is fine. */ if (except.error != MEMORY_ERROR) throw; return pc; - } + }) /* Capture the disassembled instruction. */ tal.insn = gdb_dis_out.release (); diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index a30000ef626..ba52c3f337f 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -1264,8 +1264,7 @@ tui_getc (FILE *fp) { return tui_getc_1 (fp); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { /* Just in case, don't ever let an exception escape to readline. This shouldn't ever happen, but if it does, print the exception instead of just crashing GDB. */ @@ -1274,5 +1273,5 @@ tui_getc (FILE *fp) /* If we threw an exception, it's because we recognized the character. */ return 0; - } + }) } diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 45be33786e3..cd797a52d0f 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -122,13 +122,12 @@ tui_rl_switch_mode (int notused1, int notused2) tui_enable (); } } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); if (!tui_active) rl_prep_terminal (0); - } + }) /* Clear the readline in case switching occurred in middle of something. */ diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 79043122b17..4edfd0fb141 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -408,9 +408,7 @@ type_to_string (struct type *type) type_print (type, "", &stb, -1); return stb.release (); } - catch (const gdb_exception &except) - { - } + CATCH_ERROR_QUIT (except, {}) return {}; } diff --git a/gdb/unittests/cli-utils-selftests.c b/gdb/unittests/cli-utils-selftests.c index b67e3ff0bf9..a41f22c5dd4 100644 --- a/gdb/unittests/cli-utils-selftests.c +++ b/gdb/unittests/cli-utils-selftests.c @@ -83,13 +83,12 @@ test_number_or_range_parser () minus_one.get_number (); SELF_CHECK (false); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { SELF_CHECK (ex.reason == RETURN_ERROR); SELF_CHECK (ex.error == GENERIC_ERROR); SELF_CHECK (strcmp (ex.what (), "negative value") == 0); SELF_CHECK (strcmp (minus_one.cur_tok (), "-1") == 0); - } + }) } /* Test that a - followed by not a number does not give an error. */ diff --git a/gdb/unittests/gdb_tilde_expand-selftests.c b/gdb/unittests/gdb_tilde_expand-selftests.c index 333c83ebf98..9090f5653e3 100644 --- a/gdb/unittests/gdb_tilde_expand-selftests.c +++ b/gdb/unittests/gdb_tilde_expand-selftests.c @@ -73,13 +73,12 @@ do_test () gdb_tilde_expand ("~no_one_should_have_that_login/a"); SELF_CHECK (false); } - catch (const gdb_exception_error &e) - { + CATCH_ERROR (e, { SELF_CHECK (e.error == GENERIC_ERROR); SELF_CHECK (*e.message == "Could not find a match for '~no_one_should_have_that_login'."); - } + }) } } /* namespace gdb_tilde_expand_tests */ diff --git a/gdb/unittests/gmp-utils-selftests.c b/gdb/unittests/gmp-utils-selftests.c index fb307ef5578..c4ee0d7795f 100644 --- a/gdb/unittests/gmp-utils-selftests.c +++ b/gdb/unittests/gmp-utils-selftests.c @@ -93,13 +93,12 @@ check_as_integer_raises_out_of_range_error (const gdb_mpz &val) { val.as_integer (); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { SELF_CHECK (ex.reason == RETURN_ERROR); SELF_CHECK (ex.error == GENERIC_ERROR); SELF_CHECK (strstr (ex.what (), "Cannot export value") != nullptr); return; - } + }) /* The expected exception did not get raised. */ SELF_CHECK (false); } diff --git a/gdb/unittests/parse-connection-spec-selftests.c b/gdb/unittests/parse-connection-spec-selftests.c index 314b4f4dd0c..70efad445ad 100644 --- a/gdb/unittests/parse-connection-spec-selftests.c +++ b/gdb/unittests/parse-connection-spec-selftests.c @@ -212,13 +212,12 @@ test_conn (const parse_conn_test &c) { ret = parse_connection_spec (c.connspec, &hint); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { /* If we caught an error, we should check if this connection spec was supposed to fail. */ SELF_CHECK (c.should_fail); return; - } + }) SELF_CHECK (!c.should_fail); SELF_CHECK (ret.host_str == c.expected_result.host_str); diff --git a/gdb/valops.c b/gdb/valops.c index ecfceed199a..784d38e3888 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3819,8 +3819,7 @@ value_rtti_indirect_type (struct value *v, int *full, { target = value_ind (v); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { if (except.error == MEMORY_ERROR) { /* value_ind threw a memory error. The pointer is NULL or @@ -3829,7 +3828,7 @@ value_rtti_indirect_type (struct value *v, int *full, return NULL; } throw; - } + }) } else return NULL; @@ -3971,9 +3970,7 @@ value_of_this_silent (const struct language_defn *lang) { ret = value_of_this (lang); } - catch (const gdb_exception_error &except) - { - } + CATCH_ERROR (except, {}) return ret; } diff --git a/gdb/valprint.c b/gdb/valprint.c index 25db57ea794..b2db09ce025 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1072,11 +1072,10 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse, { language->value_print_inner (value, stream, recurse, &local_opts); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { fprintf_styled (stream, metadata_style.style (), _(""), except.what ()); - } + }) } /* See valprint.h. */ diff --git a/gdb/value.c b/gdb/value.c index 74af654c451..081838c8fe2 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1499,8 +1499,7 @@ value_optimized_out (struct value *value) { value_fetch_lazy (value); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { switch (ex.error) { case MEMORY_ERROR: @@ -1513,7 +1512,7 @@ value_optimized_out (struct value *value) default: throw; } - } + }) } return !value->optimized_out.empty (); @@ -2722,11 +2721,10 @@ show_convenience (const char *ignore, int from_tty) val = value_of_internalvar (gdbarch, var); value_print (val, gdb_stdout, &opts); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { fprintf_styled (gdb_stdout, metadata_style.style (), _(""), ex.what ()); - } + }) gdb_printf (("\n")); } diff --git a/gdb/varobj.c b/gdb/varobj.c index 467f9ff3a26..3dc3f57e05e 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -320,10 +320,9 @@ varobj_create (const char *objname, var->root->language_defn = var->root->exp->language_defn; } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { return NULL; - } + }) /* Don't allow variables to be created for types. */ enum exp_opcode opcode = var->root->exp->first_opcode (); @@ -371,14 +370,13 @@ varobj_create (const char *objname, { value = evaluate_expression (var->root->exp.get ()); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { /* Error getting the value. Try to at least get the right type. */ struct value *type_only_value = evaluate_type (var->root->exp.get ()); var->type = value_type (type_only_value); - } + }) if (value != NULL) { @@ -997,11 +995,10 @@ varobj_set_value (struct varobj *var, const char *expression) value = evaluate_expression (exp.get ()); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { /* We cannot proceed without a valid expression. */ return false; - } + }) /* All types that are editable must also be changeable. */ gdb_assert (varobj_value_is_changeable_p (var)); @@ -1025,10 +1022,9 @@ varobj_set_value (struct varobj *var, const char *expression) val = value_assign (var->value.get (), value); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { return false; - } + }) /* If the value has changed, record it, so that next -var-update can report this change. If a variable had a value of '1', we've set it @@ -1271,13 +1267,12 @@ install_new_value (struct varobj *var, struct value *value, bool initial) value_fetch_lazy (value); } - catch (const gdb_exception_error &except) - { + CATCH_ERROR (except, { /* Set the value to NULL, so that for the next -var-update, we don't try to compare the new value with this value, that we couldn't even read. */ value = NULL; - } + }) } } @@ -2013,9 +2008,7 @@ value_of_root_1 (struct varobj **var_handle) { new_val = evaluate_expression (var->root->exp.get ()); } - catch (const gdb_exception_error &except) - { - } + CATCH_ERROR (except, {}) } return new_val; diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 77ab2706fff..c378f8d5937 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1710,10 +1710,9 @@ windows_nat_target::get_windows_debug_event { windows_process.dll_loaded_event (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) ourstatus->set_loaded (); thread_id = current_event->dwThreadId; break; @@ -1730,10 +1729,9 @@ windows_nat_target::get_windows_debug_event { windows_process.handle_unload_dll (); } - catch (const gdb_exception &ex) - { + CATCH_ERROR_QUIT (ex, { exception_print (gdb_stderr, ex); - } + }) ourstatus->set_loaded (); thread_id = current_event->dwThreadId; break; diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index 80be9733310..61a6a668f80 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -221,11 +221,10 @@ x86_linux_nat_target::enable_btrace (thread_info *tp, { tinfo = linux_enable_btrace (ptid, conf); } - catch (const gdb_exception_error &exception) - { + CATCH_ERROR (exception, { error (_("Could not enable branch tracing for %s: %s"), target_pid_to_str (ptid).c_str (), exception.what ()); - } + }) return tinfo; } diff --git a/gdbserver/gdbreplay.cc b/gdbserver/gdbreplay.cc index 7d7bbb63c44..7037db3f847 100644 --- a/gdbserver/gdbreplay.cc +++ b/gdbserver/gdbreplay.cc @@ -480,8 +480,7 @@ main (int argc, char *argv[]) { captured_main (argc, argv); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { if (exception.reason == RETURN_ERROR) { fflush (stdout); @@ -489,7 +488,7 @@ main (int argc, char *argv[]) } exit (1); - } + }) gdb_assert_not_reached ("captured_main should never return"); } diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 1676328fc88..ae3b3ec3fbc 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -1485,11 +1485,10 @@ linux_process_target::detach_one_lwp (lwp_info *lwp) /* Finally, let it resume. */ low_prepare_to_resume (lwp); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (!check_ptrace_stopped_lwp_gone (lwp)) throw; - } + }) lwpid = lwpid_of (thread); if (ptrace (PTRACE_DETACH, lwpid, (PTRACE_TYPE_ARG3) 0, @@ -4199,8 +4198,7 @@ linux_process_target::resume_one_lwp (lwp_info *lwp, int step, int signal, { resume_one_lwp_throw (lwp, step, signal, info); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { if (check_ptrace_stopped_lwp_gone (lwp)) { /* This could because we tried to resume an LWP after its leader @@ -4211,7 +4209,7 @@ linux_process_target::resume_one_lwp (lwp_info *lwp, int step, int signal, } else throw; - } + }) } /* This function is called once per thread via for_each_thread. diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 366a843ea89..3dcff2f6c92 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -476,10 +476,9 @@ handle_btrace_general_set (char *own_buf) write_ok (own_buf); } - catch (const gdb_exception_error &exception) - { + CATCH_ERROR (exception, { sprintf (own_buf, "E.%s", exception.what ()); - } + }) return 1; } @@ -1880,11 +1879,10 @@ handle_qxfer_btrace (const char *annex, if (result != 0) memcpy (cs.own_buf, cache.buffer, cache.used_size); } - catch (const gdb_exception_error &exception) - { + CATCH_ERROR (exception, { sprintf (cs.own_buf, "E.%s", exception.what ()); result = -1; - } + }) if (result != 0) return -3; @@ -1951,11 +1949,10 @@ handle_qxfer_btrace_conf (const char *annex, if (result != 0) memcpy (cs.own_buf, cache.buffer, cache.used_size); } - catch (const gdb_exception_error &exception) - { + CATCH_ERROR (exception, { sprintf (cs.own_buf, "E.%s", exception.what ()); result = -1; - } + }) if (result != 0) return -3; @@ -3586,13 +3583,12 @@ detach_or_kill_for_exit_cleanup () { detach_or_kill_for_exit (); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { fflush (stdout); fprintf (stderr, "Detach or kill failed: %s\n", exception.what ()); exit_code = 1; - } + }) } #if GDB_SELF_TEST @@ -4049,8 +4045,7 @@ captured_main (int argc, char *argv[]) } } } - catch (const gdb_exception_error &exception) - { + CATCH_ERROR (exception, { fflush (stdout); fprintf (stderr, "gdbserver: %s\n", exception.what ()); @@ -4062,7 +4057,7 @@ captured_main (int argc, char *argv[]) if (run_once) throw_quit ("Quit"); - } + }) } } @@ -4076,8 +4071,7 @@ main (int argc, char *argv[]) { captured_main (argc, argv); } - catch (const gdb_exception &exception) - { + CATCH_ERROR_QUIT (exception, { if (exception.reason == RETURN_ERROR) { fflush (stdout); @@ -4087,7 +4081,7 @@ main (int argc, char *argv[]) } exit (exit_code); - } + }) gdb_assert_not_reached ("captured_main should never return"); } diff --git a/gdbsupport/selftest.cc b/gdbsupport/selftest.cc index 1b862bb9ce3..327bc439ec1 100644 --- a/gdbsupport/selftest.cc +++ b/gdbsupport/selftest.cc @@ -99,11 +99,10 @@ run_tests (gdb::array_view filters, bool verbose) ++ran; test.test (); } - catch (const gdb_exception_error &ex) - { + CATCH_ERROR (ex, { ++failed; debug_printf ("Self test failed: %s\n", ex.what ()); - } + }) reset (); }