From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5BF393858C50; Thu, 17 Aug 2023 11:21:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5BF393858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692271291; bh=In0b+HrFhOaPnnj7LUXiKXqSJ+DZm9U5cD+USjIF0yY=; h=From:To:Subject:Date:From; b=BQ3B+9sM00yfU4iSP+IT1ToTv45Yiwb5jJ7FnP82B0PPFVVmQgvzUeXV+7PVhH6Oa I4SA0tPEm10vMrcE2Gs6xOBWcUoge5KQ+0uWNKXLoVQInGvGKZQ48ESvPhALgd8rZl mtwfIYpYmqCtqIohMp0FWakG5kBKk3bpoX2huVKc= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/30775] New: [gdb/symtab] Cannot distinguish between nullptr and dont-know in m_die_range_map Date: Thu, 17 Aug 2023 11:21:30 +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=3D30775 Bug ID: 30775 Summary: [gdb/symtab] Cannot distinguish between nullptr and dont-know in m_die_range_map 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 wrote a dwarf assembly test-case containing the following dwarf: ... <1>: Abbrev Number: 3 (DW_TAG_class_type) DW_AT_specification: <0xcc> <1>: Abbrev Number: 4 (DW_TAG_class_type) DW_AT_specification: <0xbe> <1>: Abbrev Number: 5 (DW_TAG_namespace) DW_AT_name : N1 <2>: Abbrev Number: 6 (DW_TAG_class_type) DW_AT_name : C1 ... to try and trick the cooked index reader, expecting 0xbe to be deferred but 0xc3 not. That turned out to be not the case, 0xc3 is also deferred, and consequently= we have N1::C1 for all three class_type DIEs. The process of how it is deferred is not so pretty though. The first DIE, 0xbe is deferred because reference 0xcc is beyond the watermark_ptr (in other words, it's a forward reference). The second DIE, 0xc3 has a reference to 0xbe which is not beyond the watermark_ptr (in other words, a backward reference), so it's handled differently. First, the parent of 0xbe is looked up in m_die_range_map, which returns nullptr, not because the parent is nullptr but because 0xbe is deferred and= we don't know the parent yet. Then scan_attributes recurses into DIE 0xbe, find the same forward reference and defers DIE 0xc3, ignoring the incorrect parent. [ We could have saved the trouble of recursing into DIE 0xbe by looking up = 0xbe in m_deferred_entries (and doing that recursively as well to make sure that= the spec_die of the deferred entries is 0xcc in both cases, as is the case in t= he current situation). This would be a minor speed optimization. ] >From the software engineering point of view, looking up some incorrect information in m_die_range_map and then not using it is problematic. It's also not clear if that is done intentionally, or just because doing so= is currently not flagged. In conclusion, we need to be able to query m_die_range_map and be able to decide whether the response is: - parent is null pointer - don't know the parent - parent is some valid pointer Currently we cannot distinguish between the first two options, and we'd lik= e to assert that queries don't return "don't know the parent" to make sure that = we know if our mechanism for calculating parents of cooked index entries is failing. --=20 You are receiving this mail because: You are on the CC list for the bug.=