From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ICvRLpbM7WeujSQAWB0awg (envelope-from ) for ; Wed, 02 Apr 2025 19:47:34 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=quX1j89g; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BBA8F1E0C3; Wed, 2 Apr 2025 19:47:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 27AF01E0C0 for ; Wed, 2 Apr 2025 19:47:34 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA5E53856979 for ; Wed, 2 Apr 2025 23:47:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA5E53856979 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=quX1j89g Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id BEFEF3857C5D for ; Wed, 2 Apr 2025 23:45:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEFEF3857C5D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BEFEF3857C5D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637513; cv=none; b=BfeizCGCAa23fGDvVM9HTsCq6jahumCs8JxpYK/n76w85s+EVXR4G/w6/EGdvBq/eg9klgtaiNuZtuBpEqK9EFGuZ75v5w5jcVNGDBvoo5dHSE1rhqB26EuQAt1ZvGw+hXfImQAsMyPH2pEYUKwW2IDyjv14V/t5fDlaGfDQetA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637513; c=relaxed/simple; bh=JUtdKaDWUqlQ35DORuwXgNukWYrR4wn684A54llYgY4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=CgVqroXPfVnq+I0NvZ33msMYpnWYK33vJnlaV76sESCVVKU3s28/5uC2d4E8n3r30RP3/r1qkJ5zhD2ezO6l2qFX3XREXrEyGBXwuKxv+ixJg2T5Trp5YJvYflIDvh1AZq+oH4oRICDUgnOlSn5sQaFVdYPBoPCxfT0xCd8Vzlk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BEFEF3857C5D Received: from eig-obgw-6004a.ext.cloudfilter.net ([10.0.30.197]) by cmsmtp with ESMTPS id 03dguJnW4WuHK07lhuzjxN; Wed, 02 Apr 2025 23:45:13 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 07lgutJxiRlrs07lguJ449; Wed, 02 Apr 2025 23:45:12 +0000 X-Authority-Analysis: v=2.4 cv=Qamtvdbv c=1 sm=1 tr=0 ts=67edcc08 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=XR8D0OoHHMoA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=VAiYmlJAHfulRfEKCh4A:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 a=6Ogn3jAGHLSNbaov7Orx:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6H45HBBdqypG+3FE3d2+orDmPsU+Ndc7u7ehK8dcaiQ=; b=quX1j89gXaKDGlQl7nd/kCq4FL 3j4yUBuEHVaP+iuzQ1+2+o8ZvrXEsE/42siPMSZlWJOxKahpFTITs4Q+Ft9SfEqVHQZU7q6WyDLRG PEijw1B112sLm4rkQvu1wzukh; Received: from 97-122-123-18.hlrn.qwest.net ([97.122.123.18]:56394 helo=prentzel.local) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1u07lf-000000014hd-4A33; Wed, 02 Apr 2025 17:45:12 -0600 From: Tom Tromey Date: Wed, 02 Apr 2025 17:45:03 -0600 Subject: [PATCH v2 04/28] Ada import functions not in index MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250402-search-in-psyms-v2-4-ea91704487cb@tromey.com> References: <20250402-search-in-psyms-v2-0-ea91704487cb@tromey.com> In-Reply-To: <20250402-search-in-psyms-v2-0-ea91704487cb@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.123.18 X-Source-L: No X-Exim-ID: 1u07lf-000000014hd-4A33 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-123-18.hlrn.qwest.net (prentzel.local) [97.122.123.18]:56394 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfILfk8XyG7yo+RZnV/uiYigtmxL9pTdml9hU9IYXHHM7mgUnurgecvVMadM0tROu3Mda8gWue/szhoIwEhhGSZu5VGymQsD7hS8sxAhUDx8B/nOGwRS4 fWDU18oThtTV6XHn8y+Wp6bzUpNXYjKmmqhjtFlMow87crcXikTfK6oIDUZVqMnYWpK0l4uq16w/LdEm5Q2LCKVf4H5xVAcs1CM= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org The cooked index does not currently contain entries for Ada import functions. This means that whether or not these are visible to "break" depends on which CUs were previously expanded -- clearly a bug. This patch fixes the issue. I think the comments in the patch explain the fix reasonably well. Perhaps one to-do item here is to change GNAT to use DW_TAG_imported_declaration for these imports. This may eventually let us remove some of the current hacks. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32511 --- gdb/dwarf2/abbrev.c | 7 ++++++- gdb/dwarf2/abbrev.h | 8 ++++++++ gdb/dwarf2/cooked-indexer.c | 6 ++++-- gdb/dwarf2/read.c | 9 +++------ gdb/dwarf2/read.h | 6 ++++++ gdb/testsuite/gdb.ada/import.exp | 28 ++++++++++++++-------------- 6 files changed, 41 insertions(+), 23 deletions(-) diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c index 9f7ead88f1fa717985004709e73aa8e916acb1e1..5b7e99abd24ead974595993f72c7452ad0d2ce4c 100644 --- a/gdb/dwarf2/abbrev.c +++ b/gdb/dwarf2/abbrev.c @@ -242,7 +242,12 @@ abbrev_table::read (struct dwarf2_section_info *section, } else if (has_hardcoded_declaration && (cur_abbrev->tag != DW_TAG_variable || !has_external)) - cur_abbrev->interesting = false; + { + cur_abbrev->interesting = false; + if (cur_abbrev->tag == DW_TAG_subprogram && has_name + && has_linkage_name) + cur_abbrev->maybe_ada_import = true; + } else if (!tag_interesting_for_index (cur_abbrev->tag)) cur_abbrev->interesting = false; else diff --git a/gdb/dwarf2/abbrev.h b/gdb/dwarf2/abbrev.h index 29914f9c86dfa46bbab90f5e87a7c248760d942d..41e60adb3aaafb9e70b525cc9fb671f7846a7168 100644 --- a/gdb/dwarf2/abbrev.h +++ b/gdb/dwarf2/abbrev.h @@ -51,6 +51,14 @@ struct abbrev_info /* True if the DIE has children. */ bool has_children; bool interesting; + /* In Ada, an imported subprogram DIE will be marked as a + declaration, but will have both a name and a linkage name. This + declaration may be the only spot where that name is associated + with an object, so it has to show up in the index. But, because + abbrevs are CU-independent, we can't check the language when + computing them and instead we keep a separate flag to indicate + that the scanner should check this DIE. */ + bool maybe_ada_import; unsigned short size_if_constant; unsigned short sibling_offset; /* Number of attributes. */ diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c index 1f3a2357958f04e75ba4674c17464ddc14b64dab..7b9ffa79fe8fd6575a7d8c57424895073e790fba 100644 --- a/gdb/dwarf2/cooked-indexer.c +++ b/gdb/dwarf2/cooked-indexer.c @@ -20,6 +20,7 @@ #include "dwarf2/cooked-indexer.h" #include "dwarf2/cooked-index-worker.h" #include "dwarf2/error.h" +#include "dwarf2/read.h" /* See cooked-indexer.h. */ @@ -301,7 +302,7 @@ cooked_indexer::scan_attributes (dwarf2_per_cu *scanning_per_cu, || abbrev->tag == DW_TAG_namespace) && abbrev->has_children) *flags |= IS_TYPE_DECLARATION; - else + else if (!is_ada_import_or_export (reader->cu (), *name, *linkage_name)) { *linkage_name = nullptr; *name = nullptr; @@ -514,7 +515,8 @@ cooked_indexer::index_dies (cutu_reader *reader, /* If a DIE parent is a DW_TAG_subprogram, then the DIE is only interesting if it's a DW_TAG_subprogram or a DW_TAG_entry_point. */ bool die_interesting - = (abbrev->interesting + = ((abbrev->interesting + || (m_language == language_ada && abbrev->maybe_ada_import)) && (parent_entry == nullptr || parent_entry->tag != DW_TAG_subprogram || abbrev->tag == DW_TAG_subprogram diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 17f06ff134220d7753e7d9ac25e424965e9e55ed..ae8369266be1b1d7e5cc99cb1f44966a2392ec2b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -973,9 +973,6 @@ static void queue_comp_unit (dwarf2_per_cu *per_cu, static void process_queue (dwarf2_per_objfile *per_objfile); -static bool is_ada_import_or_export (dwarf2_cu *cu, const char *name, - const char *linkagename); - /* Class, the destructor of which frees all allocated queue entries. This will only have work to do if an error was thrown while processing the dwarf. If no error was thrown then the queue entries should have all @@ -16627,14 +16624,14 @@ add_ada_export_symbol (struct symbol *orig, const char *new_name, add_symbol_to_list (copy, list_to_add); } -/* A helper function that decides if a given symbol is an Ada Pragma - Import or Pragma Export. */ +/* See read.h. */ -static bool +bool is_ada_import_or_export (dwarf2_cu *cu, const char *name, const char *linkagename) { return (cu->lang () == language_ada + && name != nullptr && linkagename != nullptr && !streq (name, linkagename) /* The following exclusions are necessary because symbols diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 7f56dac32f186a321978190c388885999a7ea3fd..c39945d7da4e5a4bd33292849437bcbe396fbb0a 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -1299,4 +1299,10 @@ extern int dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return, extern file_and_directory &find_file_and_directory (die_info *die, dwarf2_cu *cu); +/* A helper function that decides if a given symbol is an Ada Pragma + Import or Pragma Export. */ + +extern bool is_ada_import_or_export (dwarf2_cu *cu, const char *name, + const char *linkagename); + #endif /* GDB_DWARF2_READ_H */ diff --git a/gdb/testsuite/gdb.ada/import.exp b/gdb/testsuite/gdb.ada/import.exp index 04bb7e1a0d9f18e732855114b008a03348235086..6f1026f545fcfd5bc19d1f6e72321d05ffe12960 100644 --- a/gdb/testsuite/gdb.ada/import.exp +++ b/gdb/testsuite/gdb.ada/import.exp @@ -54,6 +54,9 @@ gdb_test "print pkg.imported_var_ada" " = 42" gdb_test "print pkg.exported_var_ada" " = 99" gdb_test "print exported_var_ada" " = 99" +gdb_breakpoint "local_imported_func" message +gdb_test "print copy" " = 42" + # This passes with gcc 10 but fails with gcc 9. With gcc 9, we have: # <1><1659>: Abbrev Number: 4 (DW_TAG_subprogram) # <165a> DW_AT_external : 1 @@ -76,19 +79,16 @@ gdb_test "print exported_var_ada" " = 99" # The fact that things start to work when adding the DW_AT_declaration is # consistent with what is described in commit ff9baa5f1c5, so xfail this # (without pinpointing it to a specific gcc PR or commit). -if { [gcc_major_version] < 10 } { - setup_xfail *-*-* -} -gdb_breakpoint "pkg.imported_func_ada" message -gdb_breakpoint "imported_func" message -if { [gcc_major_version] < 10 } { - setup_xfail *-*-* +foreach func {"pkg.imported_func_ada" "imported_func"} { + clean_restart $testfile + if { [gcc_major_version] < 10 } { + setup_xfail *-*-* + } + gdb_breakpoint $func message } -gdb_breakpoint "imported_func_ada" message -gdb_breakpoint "local_imported_func" message -gdb_breakpoint "pkg.exported_func_ada" message -gdb_breakpoint "exported_func_ada" message -gdb_breakpoint "exported_func" message - -gdb_test "print copy" " = 42" +foreach func {"imported_func_ada" "pkg.exported_func_ada" \ + "exported_func_ada" "exported_func"} { + clean_restart $testfile + gdb_breakpoint $func message +} -- 2.46.1