Fix corrupt DWARF in dw2-double-set-die-type
authorTom Tromey <tom@tromey.com>
Thu, 9 Jun 2022 13:19:13 +0000 (07:19 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 25 Jun 2022 17:11:51 +0000 (11:11 -0600)
commit1fa2e2287e8bcac6427f2495049e0ccfb3ee8514
tree40b8806ebaaa133cf4c7b96190620bc766776454
parenta858187afda380dd0bd9479f58c152178e275903
Fix corrupt DWARF in dw2-double-set-die-type

The dw2-double-set-die-type.exp test case caused an AddressSanitizer
failure in the new DWARF scanner.

The immediate cause was bad DWARF in the test -- in particular, the
the sibling attribute here:

     <2><181>: Abbrev Number: 33 (DW_TAG_subprogram)
<182>   DW_AT_external    : 1
<183>   DW_AT_name        : address
<18b>   DW_AT_type        : <0x171>
<18f>   DW_AT_declaration : 1
<190>   DW_AT_sibling     : <0x1a1>
    ...
     <1><1a1>: Abbrev Number: 23 (DW_TAG_pointer_type)
<1a2>   DW_AT_byte_size   : 4
<1a3>   DW_AT_type        : <0x1a7>

...points to a "sibling" DIE that is at a different child depth.

Because this test case doesn't really require sibling attributes, this
patch fixes the problem by removing them from the test.

Note that gdb is not generally robust against malformed DWARF.
Detecting and compensating for this problem would probably be
expensive and, IMO, is better left to some (still hypothetical) DWARF
linter.
gdb/testsuite/gdb.dwarf2/dw2-double-set-die-type.S