From patchwork Mon Apr 8 21:11:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88202 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 658E23846411 for ; Mon, 8 Apr 2024 21:12:23 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id BF5103858CDA for ; Mon, 8 Apr 2024 21:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF5103858CDA 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 BF5103858CDA 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=1712610704; cv=none; b=p8GL9FEJkJzMOdnerB2nTHThi3mLAcPuoYwvuqaHGcwEeccNrWw+ckU9/nASsgLNUR3+wRZuP+pnoZHT2612EMdES6KWHdTZ7yhxBNYPR3z12E4JbA+XOiOUN60eTQSKzspeR1us9LFCnH7MMf+UigwTkQDW0luy0HJhjL7U9z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712610704; c=relaxed/simple; bh=z/qRhqhU7sOBh2EuB5XiZqCt0iSSR/hPK+yQAdJdgrw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=E7ktSCvd2AXh5tBQnqGi0tJs0i9sJuPMYvzVf5kOglUgRUMWsFEWwAwX4vF0YNvnELsU+CJX2FFZ051grXnTBpE2UPlOIAtIr3Ujw3zj5xoTIUn6hX6ibosf9fLPijGKZ9ShyE9f8TP1XJJOonkxX1mT/YMA3MLKy6sTeX1CQVU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6004a.ext.cloudfilter.net ([10.0.30.197]) by cmsmtp with ESMTPS id trCnrYgAatf2QtwHFrySf0; Mon, 08 Apr 2024 21:11:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id twHFr7oOVuv6XtwHFrNuCl; Mon, 08 Apr 2024 21:11:41 +0000 X-Authority-Analysis: v=2.4 cv=YbZ25BRf c=1 sm=1 tr=0 ts=66145d8d a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA: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=UsqE4FQuCtSj99I/gbMUXstpjRF0Vs2vIowVJjbM6PY=; b=HuAzTeYMmDr2KA3GILt4b5GrVY ZyfrPZZA5R6N4fOi5Ep0KOaQ3mk/gQ3J4nTu6v6jE2rdEq3PeKr3nCgIkfgl5LEhEmz/Q3AF6hRbb +wB/AS7fJqJ20zcVNuFT69JOr; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:54230 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 1rtwHF-001uXf-0a for gdb-patches@sourceware.org; Mon, 08 Apr 2024 15:11:41 -0600 From: Tom Tromey Date: Mon, 08 Apr 2024 15:11:38 -0600 Subject: [PATCH v2 2/7] Change handling of DW_TAG_enumeration_type in DWARF scanner MIME-Version: 1.0 Message-Id: <20240408-die-map-madness-v2-2-6741626d544d@tromey.com> References: <20240408-die-map-madness-v2-0-6741626d544d@tromey.com> In-Reply-To: <20240408-die-map-madness-v2-0-6741626d544d@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.82.115 X-Source-L: No X-Exim-ID: 1rtwHF-001uXf-0a X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net ([192.168.0.21]) [97.122.82.115]:54230 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: MS4xfHN4hX+eVoISEQ0VN68ttL2FI+o59Ny5LqkjKuNlo2RFOrvLlR+c2N/cO4pu/y/i7kgHTxffmnR46HABWLeW5KxaWFdzyCImikY6qOTEXe1xEANYR39g l8punp1p1ULsju//tBmacSoctFfeNUQ0VEV2TjJp5EseanjOHE90agloYPUxkC70oI7P2mMv+BSbw12qFmqG+dbda3XJ76wcwg0= X-Spam-Status: No, score=-3021.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, 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 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 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7b306d8594c..b54b381aef3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16469,6 +16469,12 @@ cooked_indexer::index_dies (cutu_reader *reader, flags &= ~IS_STATIC; flags |= parent_entry->flags & IS_STATIC; } + /* 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 + && !is_enum_class) + this_parent_entry = this_parent_entry->get_parent (); if (abbrev->tag == DW_TAG_namespace && m_language == language_cplus @@ -16531,15 +16537,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, - is_enum_class ? this_entry : parent_entry, - fully); + info_ptr = recurse (reader, info_ptr, this_entry, fully); continue; case DW_TAG_module: