From patchwork Tue Mar 11 14:12:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 107678 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 D23B7385770F for ; Tue, 11 Mar 2025 14:18:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D23B7385770F 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=v6SPdPJK X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id F07FC3857C6C for ; Tue, 11 Mar 2025 14:12:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F07FC3857C6C 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 F07FC3857C6C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741702379; cv=none; b=WuQL8SFnv/5/k4iBGYINu4SbYieVgYsfha76D01uf7tnkJSFR5s2uMB+FTm+Vkak6gm+Nbc8BQjz/mQfmi49jcOXHL64pW9CNLDeO2lUGQhhlPofu4L/UKgb1rIqq7C2frXLyOtU3jvGkN7JL/kt/7R5cIEZ2Xvc7XHlGQ2UMqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741702379; c=relaxed/simple; bh=dfLhRSPe3CSXl8Tu74cxx1/vMUuB6y/X0a8tQ+Lk8ac=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Dn8nBPOX8hVVMaZ4CoMXGpAexDV5GCfq3IGGaEP7M6K+WRMVUmRSHCvMF5B8YsyqtcvMivpuLLExGMGtyJ+DSfRhMc0dWke92Eh0HInO1+ORvlUAAhfqJdLytWrKCbccktReCJpplapTf83gfgeXrkrPFYZ282AnHp+dFL6wJ4s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5008a.ext.cloudfilter.net ([10.0.29.246]) by cmsmtp with ESMTPS id roULtds9af1UXs0LhtBX0b; Tue, 11 Mar 2025 14:12:49 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id s0LgtaH9jkhljs0Lgt2zW8; Tue, 11 Mar 2025 14:12:49 +0000 X-Authority-Analysis: v=2.4 cv=F79RdLhN c=1 sm=1 tr=0 ts=67d044e1 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=Vs1iUdzkB0EA: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=aXyvGtHsBvegO51ciAtWkLZI+rbrCj/DrHFMVFXlk8k=; b=v6SPdPJKiZmsAUYTcmOFa/DWC6 5XuLkRBbsnK6eSabCzpFGlO07C0BlzzBkTqT5s7OgbubJVCs1cyfBiy8ce/Lu2C/nefFPK8xyJISk xTjck6aEfHR3QzeIjgJesX0hO; Received: from 97-118-51-80.hlrn.qwest.net ([97.118.51.80]:33770 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 1ts0Lg-000000003jP-0cpC; Tue, 11 Mar 2025 08:12:48 -0600 From: Tom Tromey Date: Tue, 11 Mar 2025 08:12:44 -0600 Subject: [PATCH 08/28] Entries from anon-struct.exp not in cooked index MIME-Version: 1.0 Message-Id: <20250311-search-in-psyms-v1-8-d73d9be20983@tromey.com> References: <20250311-search-in-psyms-v1-0-d73d9be20983@tromey.com> In-Reply-To: <20250311-search-in-psyms-v1-0-d73d9be20983@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.118.51.80 X-Source-L: No X-Exim-ID: 1ts0Lg-000000003jP-0cpC X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-51-80.hlrn.qwest.net (prentzel.local) [97.118.51.80]:33770 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: MS4xfACOV5NnVWjZ5YLtat8vDrMMbQA1y+Z+tcgdO5wipug3Q9YJvG0NWEL+WPOhdWUezoAqccSX5pocEqNKyKpGkIodxLyt5sFiXa0rzMRpjiEYBHsQeFs+ 01bG1dWdn7AzmuG5JBNg4rc++Nn5EbJ7IUY0IvAOMSBoOSJV9L9troKwqveTqr/QI7RTEnGNJqdr9CQiE/m3V19/F4pe/SBcyOI= X-Spam-Status: No, score=-3018.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_LOTSOFHASH, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_W, RCVD_IN_MSPIKE_H2, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@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-storage.h | 7 +++++++ gdb/dwarf2/cooked-index.h | 7 +++++++ gdb/dwarf2/cooked-indexer.c | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/gdb/dwarf2/cooked-index-storage.h b/gdb/dwarf2/cooked-index-storage.h index 3d0b5b23f3a4093fd8f7abbfe8e749d5772e85af..bdf1ba12ac8bea1bc1d5f1c77e246a0fcec60890 100644 --- a/gdb/dwarf2/cooked-index-storage.h +++ b/gdb/dwarf2/cooked-index-storage.h @@ -62,6 +62,13 @@ class cooked_index_storage 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 () diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 02f4512213a6ce1eb52f336af63d4197fb6b666e..f6aa4c1d0ea75b699000a6fbf6431f84e92e7c92 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -304,6 +304,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-indexer.c b/gdb/dwarf2/cooked-indexer.c index f5ed116c097a9e569b9eb7731c9922e5d0d5f7a0..60af912244bfb3667ad8f47c384a5529ee3b8fc9 100644 --- a/gdb/dwarf2/cooked-indexer.c +++ b/gdb/dwarf2/cooked-indexer.c @@ -21,6 +21,8 @@ #include "dwarf2/cooked-index-storage.h" #include "dwarf2/error.h" #include "dwarf2/read.h" +#include "cp-support.h" +#include "demangle.h" /* See cooked-indexer.h. */ @@ -568,6 +570,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) {