From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id B4AFC3858C50; Tue, 16 Apr 2024 17:55:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4AFC3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713290107; bh=+wYfTK7tFHsGP+PtTG0wNDhcStpnUNZeVS9HTUD1rlA=; h=From:To:Subject:Date:From; b=j6bm5gPuGCBCIai/KDWKjGVPUHyp1yDRWE/o07ubj0S16wQpXv2vtVwDpVZznHC7q iV77ThhJ6TTrBFSMrT5pYfByg2vN1sFNdH11F4EmElQ2VJj/CsXy8e6LIJgvjvyrik Cj+T0dbuF89zU3NMsaeTkBqVTM4JI8wYRmU8cSqY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Change handling of DW_TAG_enumeration_type in DWARF scanner X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 08b91f595d7e2f181e3ac18838ff5a9421aa4d33 X-Git-Newrev: 4e417d7bb1c7d8b8a73b73b0b7c051f0a6e1b6b6 Message-Id: <20240416175507.B4AFC3858C50@sourceware.org> Date: Tue, 16 Apr 2024 17:55:07 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4e417d7bb1c7= d8b8a73b73b0b7c051f0a6e1b6b6 commit 4e417d7bb1c7d8b8a73b73b0b7c051f0a6e1b6b6 Author: Tom Tromey Date: Fri Jan 12 18:01:00 2024 -0700 Change handling of DW_TAG_enumeration_type in DWARF scanner =20 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. =20 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. =20 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. Diff: --- 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 4c97fe12307..b7e04a1ebf3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16468,6 +16468,12 @@ cooked_indexer::index_dies (cutu_reader *reader, flags &=3D ~IS_STATIC; flags |=3D 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 !=3D nullptr + && this_parent_entry->tag =3D=3D DW_TAG_enumeration_type + && !is_enum_class) + this_parent_entry =3D this_parent_entry->get_parent (); =20 if (abbrev->tag =3D=3D DW_TAG_namespace && m_language =3D=3D language_cplus @@ -16530,15 +16536,7 @@ cooked_indexer::index_dies (cutu_reader *reader, break; =20 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 =3D recurse (reader, info_ptr, - is_enum_class ? this_entry : parent_entry, - fully); + info_ptr =3D recurse (reader, info_ptr, this_entry, fully); continue; =20 case DW_TAG_module: