From patchwork Sat Sep 8 21:55:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 29261 Received: (qmail 55664 invoked by alias); 8 Sep 2018 21:56:09 -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 55510 invoked by uid 89); 8 Sep 2018 21:56:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=D*adacore.com, U*brobecker, brobeckeradacorecom, brobecker@adacore.com 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; Sat, 08 Sep 2018 21:56:07 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B13C1117109 for ; Sat, 8 Sep 2018 17:56:05 -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 ZAB5r33Uacqc for ; Sat, 8 Sep 2018 17:56:05 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 9EB451170ED for ; Sat, 8 Sep 2018 17:56:05 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4233) id 9DA8E489; Sat, 8 Sep 2018 17:56:05 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [PATCH 3/8] (Ada) "catch assert" spurious internal error Date: Sat, 8 Sep 2018 17:55:55 -0400 Message-Id: <1536443760-78016-4-git-send-email-brobecker@adacore.com> In-Reply-To: <1536443760-78016-1-git-send-email-brobecker@adacore.com> References: <1536443760-78016-1-git-send-email-brobecker@adacore.com> We noticed while debugging a program compiled without assertions enabled and using an older compiler that inserting a catchpoint on failed assertions would cause an internal error: (gdb) catch assert ../../src/gdb/ada-lang.c:13321: internal-error: ada_exception_sal: Assertion`sym != NULL' failed. A problem internal to GDB has been detected, This is due to a combination of factors: 1. With older versions of the compiler, the function used as a hook was provided by a unit that's different from the unit which provides the hooks for the other exception catchpoints. 2. The program either does not use any assertion, or is compiled without the assertions enabled. With newer versions of the compiler, all such functions are provided by the same unit, so should normally always be available. However, there can still be reasons why this is not the case. Consider, for instance, the case of a runtime compiled with -ffunction-sections, in which case the hook might be eliminated unless assertions are used and enabled. So this patch transforms the internal error into a simple error. gdb/ChangeLog: * ada-lang.c (ada_exception_sal): Replace gdb_assert calls by calls to error. No testcase added, as the existing testcase gdb.ada/catch_ex.exp should trigger it when using an older version of GNAT as the Ada compiler. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 41dee6e..4aeb0ba 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2018-09-08 Joel Brobecker + * ada-lang.c (ada_exception_sal): Replace gdb_assert calls + by calls to error. + +2018-09-08 Joel Brobecker + * ada-lang.c (ada_unhandled_exception_name_addr_from_raise): Move update of loop variable "fi". diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 87ae275..c5cddd0 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13215,14 +13215,11 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex, sym_name = ada_exception_sym_name (ex); sym = standard_lookup (sym_name, NULL, VAR_DOMAIN); - /* We can assume that SYM is not NULL at this stage. If the symbol - did not exist, ada_exception_support_info_sniffer would have - raised an exception. - - Also, ada_exception_support_info_sniffer should have already - verified that SYM is a function symbol. */ - gdb_assert (sym != NULL); - gdb_assert (SYMBOL_CLASS (sym) == LOC_BLOCK); + if (sym == NULL) + error (_("Catchpoint symbol not found: %s"), sym_name); + + if (SYMBOL_CLASS (sym) != LOC_BLOCK) + error (_("Unable to insert catchpoint. %s is not a function."), sym_name); /* Set ADDR_STRING. */ *addr_string = xstrdup (sym_name);