From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 1B5263858C53 for ; Wed, 17 Jan 2024 18:59:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B5263858C53 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 1B5263858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705517945; cv=none; b=q+aM2qkpwWHzAir7I6DiD+FwtmojcpRMsw6DajvbmZGc+gOa/cpgWcrKYu10+xW9bT5x30N7t1giCBA1hUxDmGvWjKvPLroSiZ+m2V+id5BfadUCjJpsg+/pGbf6Y8oY3KP/KeLdqXRaUlm5gQE4ubw6ZyD021om6o1SH5fy7QU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705517945; c=relaxed/simple; bh=jQ1h6//UdxayDAvxPmuiEpky2mEKN6dM3xjNh29sDqQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Ja3o10urlHdz/xSyknRh14SaA2+sWZH1vDNfk8FAhuVCLFXIejXxFkjvIDGRNth1ASaeJtcWDTnS2Txbh9u1Spx4fat0THhyHVsOsLx0KcxAtT9gTNVrNonnyQjTpHGfh4pv+BdM6sfSTJ/QtNbsczQHlQxxDdjsEGuF12g6NBw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5005a.ext.cloudfilter.net ([10.0.29.234]) by cmsmtp with ESMTPS id Q8Khr5joACF6GQB7urfYRM; Wed, 17 Jan 2024 18:59:02 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QB7srXhsQfs4hQB7trYyaY; Wed, 17 Jan 2024 18:59:01 +0000 X-Authority-Analysis: v=2.4 cv=Q6TBXq6a c=1 sm=1 tr=0 ts=65a82375 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=AMDE52p7lMkdf-nf6v4A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=ZkBKjrbtfk8xYkqnmgMYqI4ymb84s2MWqpdIpr4MX1g=; b=ktI0JWegxOi64pIPc3I/hH8UKa xwWxHwctrCZmpHFbpUVDpwpI/F7Uu8iRPKh+h4Ol5YiB86jX6G8Uolqe/tgy88b2vq9iJ3GH6fyBd /17gHKYKq7R8cErUUwS3Xko2l; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:45122 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rQB7s-004FFp-2I for gdb-patches@sourceware.org; Wed, 17 Jan 2024 11:59:00 -0700 From: Tom Tromey Date: Wed, 17 Jan 2024 11:58:49 -0700 Subject: [PATCH 2/7] Change handling of DW_TAG_enumeration_type in DWARF scanner MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240117-die-map-madness-v1-2-42fb435ad1ed@tromey.com> References: <20240117-die-map-madness-v1-0-42fb435ad1ed@tromey.com> In-Reply-To: <20240117-die-map-madness-v1-0-42fb435ad1ed@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 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.68.157 X-Source-L: No X-Exim-ID: 1rQB7s-004FFp-2I X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:45122 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: MS4xfAoeNIv1u2/As1/ihUESUNMlsQUPVMzjC9hMtHJZUZk/3rAU3Em0ls2Q4Nms0zpsoUaP+Of+3DRnCKZzK2W+eC7+R50Z7OTwaghWsbYwwcTmFXD0P750 y8MY3cHSNml4z/VrNQb84TlZpyR7FXx1ho+7Xd9zKModtTlN4RKXrKk2q8CZyBo/F8JXoTeToq6DNTL0zWdXNU5UVsmLXBJHlK4= X-Spam-Status: No, score=-3022.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Currently the DWARF scanner will enter enumeration constants into the same namespace as the DW_TAG_enumeration_type itself. This is the right thing to do, but the implementation may result in strange entries being added to the addrmap that maps DIE ranges to entries. This came up when debugging an earlier version of this series; and while I don't think this should impact the current series, it seems better to clean this up anyway. In the new code, rather than pass the "wrong" scope down through recursive calls to the scanner, the correct scope is always passed, and then the parent handling is done when creating the enumerator entry. --- gdb/dwarf2/read.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 22cd89122cd..bf64d89ef3c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16522,6 +16522,12 @@ cooked_indexer::index_dies (cutu_reader *reader, info_ptr, abbrev, &name, &linkage_name, &flags, &sibling, &this_parent_entry, &defer, false); + /* If the parent is an enum, but not an enum class, then use the + grandparent instead. */ + if (this_parent_entry != nullptr + && this_parent_entry->tag == DW_TAG_enumeration_type + && (this_parent_entry->flags & IS_ENUM_CLASS) == 0) + this_parent_entry = this_parent_entry->get_parent (); if (abbrev->tag == DW_TAG_namespace && m_language == language_cplus @@ -16584,17 +16590,7 @@ cooked_indexer::index_dies (cutu_reader *reader, break; case DW_TAG_enumeration_type: - /* We need to recurse even for an anonymous enumeration. - Which scope we record as the parent scope depends on - whether we're reading an "enum class". If so, we use - the enum itself as the parent, yielding names like - "enum_class::enumerator"; otherwise we inject the - names into our own parent scope. */ - info_ptr = recurse (reader, info_ptr, - ((flags & IS_ENUM_CLASS) == 0) - ? parent_entry - : this_entry, - fully); + info_ptr = recurse (reader, info_ptr, this_entry, fully); continue; case DW_TAG_module: -- 2.43.0