From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CEWSKk3O7WdRjyQAWB0awg (envelope-from ) for ; Wed, 02 Apr 2025 19:54:53 -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=CEJ4mJfd; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AADAA1E0C3; Wed, 2 Apr 2025 19:54:53 -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 3F7DF1E0C0 for ; Wed, 2 Apr 2025 19:54:53 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E5BDB385B51B for ; Wed, 2 Apr 2025 23:54:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5BDB385B51B 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=CEJ4mJfd Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id EBF443857358 for ; Wed, 2 Apr 2025 23:45:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EBF443857358 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 EBF443857358 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637515; cv=none; b=Vr4zsV4YUVwbJaAfOGAHit/dILoBF4XV9uG4TTLW4SxPOLHrOcIqeJ7TL3C5dUVWEJsCBtUNwHtcKWFe+JJKWz2D64WITv+WiHWpxE97KFn5BclQ+wOqKlWxEu3cRGh9qHk0oAsnMMy3rmwBwV6/jM6NOYKuy9HvkTbyXBUgxTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637515; c=relaxed/simple; bh=DGzbVCbayoYhwpWzPbSN8x+Fl/LylPxs2XZrj6uopJ4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Sqx71AwgDGq1CDmoZ/6cCSyV7pwk7QdNaNyDdyAzVIzCrvOCoco1hQYbpYZmutyXA8LmIOxWuV0Hat5jVi0KuhgYQ6DJpR8MYpe9nxA4P+IODng6UgTZe0vPz2Tpq4m/fYglrEkeze+YNFddZGEtmBzJLIQAmaYou4W2CkyUu0s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBF443857358 Received: from eig-obgw-5008a.ext.cloudfilter.net ([10.0.29.246]) by cmsmtp with ESMTPS id 052AumyUYzZPa07liuJzCg; Wed, 02 Apr 2025 23:45:14 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 07lhuMBs1oAm007liuObDl; Wed, 02 Apr 2025 23:45:14 +0000 X-Authority-Analysis: v=2.4 cv=A/FqPbWG c=1 sm=1 tr=0 ts=67edcc0a a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=XR8D0OoHHMoA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=-N_JTRqwmrLdpAsqJsQA: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=vB+5vy2UNGmIjn6qTwk/AD+o5HM8wyr62BQxNmF/dRc=; b=CEJ4mJfdNdZ8CbfNL3AJk0tYcB VlnRuXtF8eFJiTKmmKDYijK8z0UCkHQJ0Yu5vHjQ9nT/uCvkr89isbDQ6yt4+L3LYxQpJpCJu8Tw3 3Zs/uEP6J8m9Sra3Stiqw/zQL; 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 1u07lh-000000014hd-1KCW; Wed, 02 Apr 2025 17:45:13 -0600 From: Tom Tromey Date: Wed, 02 Apr 2025 17:45:07 -0600 Subject: [PATCH v2 08/28] Entries from anon-struct.exp not in cooked index MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250402-search-in-psyms-v2-8-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: 1u07lh-000000014hd-1KCW 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: 9 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfIUcm10IgkDfKHeZocT0y3eY3erZQEChnTeBF4OMzxV8zzJlsiEwt+59Ns+egkK0vG4+Yg6OSto+yku19E5Oi7snQCxpQ1r6eIPEelJpU8TmRHuY6OU7 U/CNRxDaOgk1Afn3bnY5xMrwGTxhJmDkIJUOqhKn2cl4FRNLxBTTJ5sqcd2WDiqltkDspPdor4meUedUvnbkZa/UhFMaH8Ur6HM= 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 g++ will sometimes use a typedef to give a name to an otherwise anonymous type for linkage purposes. gdb tries to handle this odd scenario, which is enforced by anon-struct.exp. It's difficult to detect this problem in the current tree, but the cooked index does not include an entry for these DIEs. This patch changes gdb to add these to the index. This is needed by subsequent changes in this series. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32519 --- gdb/dwarf2/cooked-index-shard.h | 7 +++++++ gdb/dwarf2/cooked-index-worker.h | 7 +++++++ gdb/dwarf2/cooked-indexer.c | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/gdb/dwarf2/cooked-index-shard.h b/gdb/dwarf2/cooked-index-shard.h index eb809264cbb80612c864bcf4c04c68ff5d4e99fb..14f5c588c15b6a7ac6d558caabfd9a84b071895f 100644 --- a/gdb/dwarf2/cooked-index-shard.h +++ b/gdb/dwarf2/cooked-index-shard.h @@ -48,6 +48,13 @@ class cooked_index_shard cooked_index_entry_ref parent_entry, dwarf2_per_cu *per_cu); + /* Add a copy of NAME to the index. Return a pointer to the + copy. */ + const char *add (std::string_view name) + { + return m_names.insert (name); + } + /* Install a new fixed addrmap from the given mutable addrmap. */ void install_addrmap (addrmap_mutable *map) { diff --git a/gdb/dwarf2/cooked-index-worker.h b/gdb/dwarf2/cooked-index-worker.h index df5c31d572dfe89c067c1118d34e7d07e8a084aa..c6e005c14dea1bb891680969c17172d494a7de46 100644 --- a/gdb/dwarf2/cooked-index-worker.h +++ b/gdb/dwarf2/cooked-index-worker.h @@ -85,6 +85,13 @@ class cooked_index_worker_result name, parent_entry, per_cu); } + /* Add a copy of NAME to the index. Return a pointer to the + copy. */ + const char *add (std::string_view name) + { + return m_shard->add (name); + } + /* Install the current addrmap into the shard being constructed, then transfer ownership of the index to the caller. */ cooked_index_shard_up release_shard () diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c index bf9f1384781c54e067cb7e8441a5900613207a20..473dd451a704541668c91a26ad709daae1aa5343 100644 --- a/gdb/dwarf2/cooked-indexer.c +++ b/gdb/dwarf2/cooked-indexer.c @@ -21,6 +21,8 @@ #include "dwarf2/cooked-index-worker.h" #include "dwarf2/error.h" #include "dwarf2/read.h" +#include "cp-support.h" +#include "demangle.h" /* See cooked-indexer.h. */ @@ -569,6 +571,30 @@ cooked_indexer::index_dies (cutu_reader *reader, name = nullptr; } + /* An otherwise anonymous type might be given a name (via + typedef) for linkage purposes, and gdb tries to handle this + case. See anon-struct.exp. In this case, GCC will emit a + funny thing: a linkage name for the type, but in "type" form. + That is, it will not start with _Z. */ + if ((abbrev->tag == DW_TAG_class_type + || abbrev->tag == DW_TAG_structure_type + || abbrev->tag == DW_TAG_union_type) + && m_language == language_cplus + && name == nullptr + && linkage_name != nullptr) + { + gdb::unique_xmalloc_ptr dem + = gdb_demangle (linkage_name, DMGL_GNU_V3 | DMGL_TYPES); + if (dem != nullptr) + { + /* We're only interested in the last component. */ + std::vector split + = split_name (dem.get (), split_style::CXX); + name = m_index_storage->add (split.back ()); + linkage_name = nullptr; + } + } + cooked_index_entry *this_entry = nullptr; if (name != nullptr) { -- 2.46.1