[gdb/symtab] Handle self-reference in inherit_abstract_dies
authorTom de Vries <tdevries@suse.de>
Mon, 28 Aug 2023 14:27:58 +0000 (16:27 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 28 Aug 2023 14:27:58 +0000 (16:27 +0200)
commit8d83f51b91072bc3d79061eba7e564ba9be6afd7
treec308385f7b86c05c4617e5051ae4924442297163
parentdaafebb58dac3de93ac4696dd334530b762ed67f
[gdb/symtab] Handle self-reference in inherit_abstract_dies

Building gdb with gcc 7.5.0 and -flto -O2 -flto-partition=one generates a
self-referencing DIE:
...
 <2><91dace>: Abbrev Number: 405 (DW_TAG_label)
    <91dad0>   DW_AT_abstract_origin: <0x91dace>
...

When encountering the self-reference DIE in inherit_abstract_dies we loop
following the abstract origin, effectively hanging gdb.

Fix this by handling self-referencing DIEs in the loop in
inherit_abstract_dies.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR symtab/30799
https://sourceware.org/bugzilla/show_bug.cgi?id=30799
gdb/dwarf2/read.c
gdb/testsuite/gdb.dwarf2/self-spec.exp