[gdb/symtab] Fix gdb.dwarf2/enum-type-c++.exp with cc-with-debug-types

When running test-case gdb.dwarf2/enum-type-c++.exp with target board
cc-with-debug-types, we run into:
...
(gdb) FAIL: gdb.dwarf2/enum-type-c++.exp: val1 has a parent
...
because val1 has no parent:
...
    [31] ((cooked_index_entry *) 0x7efedc002e90)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0xef
    parent:     ((cooked_index_entry *) 0)

  ...

    [37] ((cooked_index_entry *) 0x38ffd280)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0xef
    parent:     ((cooked_index_entry *) 0)
...

There are two entries, which seems to be an inefficiency, but for now let's
focus on the correctness issue.

The debug info for val1 looks like this:
...
 <1><cb>: Abbrev Number: 2 (DW_TAG_namespace)
    <cc>   DW_AT_name        : ns
    <cf>   DW_AT_declaration : 1
 <2><d3>: Abbrev Number: 12 (DW_TAG_class_type)
    <d4>   DW_AT_name        : A
    <d6>   DW_AT_declaration : 1
 <3><d6>: Abbrev Number: 13 (DW_TAG_enumeration_type)
    <db>   DW_AT_declaration : 1
 <1><dd>: Abbrev Number: 14 (DW_TAG_enumeration_type)
    <e7>   DW_AT_specification: <0xd6>
 <2><ef>: Abbrev Number: 5 (DW_TAG_enumerator)
    <f0>   DW_AT_name        : val1
    <f4>   DW_AT_const_value : 1
...

Fix this by:
- adding a cooked index entry for DIE 0xcb (and consequently for child DIE
  0xd3), by marking it interesting,
- making sure that the entry for DIE 0xcb has a name, and
- using the entry for DIE 0xd3 as parent entry for DIE 0xdd.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2 files changed