From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 78B133858D33; Wed, 9 Aug 2023 14:14:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78B133858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691590495; bh=BgXDgif3CGOZIrGYX6lVKIyJHDehZptVhEN4AhckriM=; h=From:To:Subject:Date:From; b=Y6HnHecdu65Q7LB4t8+Vn+U5zBWNolHS+YiKTDLeWZxMgdd6PX+SH1c3tSVlKb0HM XeUZ/GhsDtVXd+j354hND9QX8FwSNg6CalxvP0qtnqc0fp9TVCwi3b6Ue+3dDm/qju /Ra7J2w5eBcQt7JkM9aa6XjMgXMMONmRQ3JCbjWU= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/30739] New: [gdb/symtab] wrong Date: Wed, 09 Aug 2023 14:14:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: symtab X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30739 Bug ID: 30739 Summary: [gdb/symtab] wrong Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: symtab Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- I went looking for a test-case that triggers the m_deferred_entries case, a= nd found gdb.dwarf2/pr13961.exp, which contains: ... <1><25>: Abbrev Number: 8 (DW_TAG_class_type) <26> DW_AT_specification: <0x2a> <1><2a>: Abbrev Number: 2 (DW_TAG_class_type) <2b> DW_AT_name : foo <2f> DW_AT_byte_size : 4 <30> DW_AT_decl_file : 1 <31> DW_AT_decl_line : 1 <32> DW_AT_sibling : <0x44> ... The DIE at 0x25 contains an intra-CU forward reference, and is deferred. Then I looked at the resulting cooked index entries: ... [12] ((cooked_index_entry *) 0x3dbbd00) name: foo canonical: foo DWARF tag: DW_TAG_class_type flags: 0x0 [] DIE offset: 0x25 parent: ((cooked_index_entry *) 0x3dbbca0) [foo] [13] ((cooked_index_entry *) 0x3dbbca0) name: foo canonical: foo DWARF tag: DW_TAG_class_type flags: 0x0 [] DIE offset: 0x2a parent: ((cooked_index_entry *) 0) ... and noticed that 0x2a is the parent of 0x25. The parent field is documented as: ... /* The parent entry. This is NULL for top-level entries.=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 Otherwise, it points to the parent entry, such as a namespace or=20=20= =20=20=20=20=20=20=20=20=20 class. */ const cooked_index_entry *parent_entry; ... so I'd expect no parent for 0x25. I'd expect the current situation to match in a foo::foo name lookup. The parent is set here: ... for (const auto &entry : m_deferred_entries) { void *obj =3D m_die_range_map.find (entry.spec_offset); cooked_index_entry *parent =3D static_cast (obj= ); m_index_storage->add (entry.die_offset, entry.tag, entry.flags, entry.name, parent, m_per_cu); } ... and AFAICT, we store in m_die_range_map the parent of the respective DIE (though that's not clear from the comment describing it). But, for DIE 0x2a we have m_die_range_map.find (0x2a) =3D=3D 0x2a. AFAICT, this is an off-by-one error, fixed by: ... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index dd4fac52ca8..d60a592669a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16477,7 +16477,7 @@ cooked_indexer::recurse (cutu_reader *reader, if (parent_entry !=3D nullptr) { - CORE_ADDR start =3D form_addr (parent_entry->die_offset, + CORE_ADDR start =3D form_addr (parent_entry->die_offset + 1, reader->cu->per_cu->is_dwz); CORE_ADDR end =3D form_addr (sect_offset (info_ptr - 1 - reader->buf= fer), reader->cu->per_cu->is_dwz); ... which gives us: ... [12] ((cooked_index_entry *) 0x41e21f0) name: foo canonical: foo DWARF tag: DW_TAG_class_type flags: 0x0 [] DIE offset: 0x25 parent: ((cooked_index_entry *) 0) [13] ((cooked_index_entry *) 0x41e2190) name: foo canonical: foo DWARF tag: DW_TAG_class_type flags: 0x0 [] DIE offset: 0x2a parent: ((cooked_index_entry *) 0) ... --=20 You are receiving this mail because: You are on the CC list for the bug.=