From patchwork Wed Jul 31 01:32:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 33867 Received: (qmail 58687 invoked by alias); 31 Jul 2019 01:32:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 58674 invoked by uid 89); 31 Jul 2019 01:32:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=201908 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Jul 2019 01:32:17 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1899D116F25; Tue, 30 Jul 2019 21:32:16 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Bzd+zD0Fhglq; Tue, 30 Jul 2019 21:32:16 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id CB1BB116EAB; Tue, 30 Jul 2019 21:32:15 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id x6V1W8PU938094 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 30 Jul 2019 22:32:08 -0300 From: Alexandre Oliva To: gdb-patches@sourceware.org Subject: support Ada EH ABI v1 Date: Tue, 30 Jul 2019 22:32:08 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 A new pair of hooks used by Ada exception handlers, for correct release of reraised exception occurrences, involves the introduction of new v1 symbols that GDB should use when available. The older, v0 ABI remains available in newer runtimes for bootstrapping purposes only. I've just contributed the corresponding compiler and runtime changes https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01836.html without the changes below, GDB will fail to catch handlers compiled by v1-capable compilers, so I'm going to hold off from installing the GCC changes until these are at least in GDB trunk. This patch was regressions tested on x86_64-linux-gnu. The pristine test run used a v0-generating compiler; its results were compared with those obtained with a patched gdb using both v0- and v1-generating compilers. Ok to install? for gdb/ChangeLog * ada-lang.c (exception_support_info_v0): Renamed from... (default_exception_support_info): ... this. Create new definition for v1. (ada_has_this_exception_support): Look up catch_handlers_sym. (ada_exception_support_info_sniffer): Try v0 after default. --- ada-lang.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git gdb/ada-lang.c gdb/ada-lang.c index 7a5cc4272c6bb..15a7a902b824a 100644 --- gdb/ada-lang.c +++ gdb/ada-lang.c @@ -11867,9 +11867,22 @@ static CORE_ADDR ada_unhandled_exception_name_addr_from_raise (void); /* The following exception support info structure describes how to implement exception catchpoints with the latest version of the - Ada runtime (as of 2007-03-06). */ + Ada runtime (as of 2019-08-??). */ static const struct exception_support_info default_exception_support_info = +{ + "__gnat_debug_raise_exception", /* catch_exception_sym */ + "__gnat_unhandled_exception", /* catch_exception_unhandled_sym */ + "__gnat_debug_raise_assert_failure", /* catch_assert_sym */ + "__gnat_begin_handler_v1", /* catch_handlers_sym */ + ada_unhandled_exception_name_addr +}; + +/* The following exception support info structure describes how to + implement exception catchpoints with an earlier version of the + Ada runtime (as of 2007-03-06) using v0 of the EH ABI. */ + +static const struct exception_support_info exception_support_info_v0 = { "__gnat_debug_raise_exception", /* catch_exception_sym */ "__gnat_unhandled_exception", /* catch_exception_unhandled_sym */ @@ -11938,8 +11951,34 @@ ada_has_this_exception_support (const struct exception_support_info *einfo) /* Make sure that the symbol we found corresponds to a function. */ if (SYMBOL_CLASS (sym) != LOC_BLOCK) - error (_("Symbol \"%s\" is not a function (class = %d)"), - SYMBOL_LINKAGE_NAME (sym), SYMBOL_CLASS (sym)); + { + error (_("Symbol \"%s\" is not a function (class = %d)"), + SYMBOL_LINKAGE_NAME (sym), SYMBOL_CLASS (sym)); + return 0; + } + + sym = standard_lookup (einfo->catch_handlers_sym, NULL, VAR_DOMAIN); + if (sym == NULL) + { + struct bound_minimal_symbol msym + = lookup_minimal_symbol (einfo->catch_handlers_sym, NULL, NULL); + + if (msym.minsym && MSYMBOL_TYPE (msym.minsym) != mst_solib_trampoline) + error (_("Your Ada runtime appears to be missing some debugging " + "information.\nCannot insert Ada exception catchpoint " + "in this configuration.")); + + return 0; + } + + /* Make sure that the symbol we found corresponds to a function. */ + + if (SYMBOL_CLASS (sym) != LOC_BLOCK) + { + error (_("Symbol \"%s\" is not a function (class = %d)"), + SYMBOL_LINKAGE_NAME (sym), SYMBOL_CLASS (sym)); + return 0; + } return 1; } @@ -11966,6 +12005,13 @@ ada_exception_support_info_sniffer (void) return; } + /* Try the v0 exception suport info. */ + if (ada_has_this_exception_support (&exception_support_info_v0)) + { + data->exception_info = &exception_support_info_v0; + return; + } + /* Try our fallback exception suport info. */ if (ada_has_this_exception_support (&exception_support_info_fallback)) {