1 # Copyright 2018-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This tests a segfault that occurs when reading inlined_subroutine DIEs
17 # with abstract_origins pointing to DIEs in other CUs.
19 # See https://bugzilla.redhat.com/show_bug.cgi?id=1638798 .
23 # This test can only be run on targets which support DWARF.
24 require dwarf2_support
26 standard_testfile main.c .S
28 # Create the DWARF. This is derived from the reproducer in the Fedora
29 # bugzila mentioned above. For clarity, some "superfluous" DIES have
30 # been left instead of simplifying/pruning the test further.
31 set asm_file [standard_output_file $srcfile2]
32 Dwarf::assemble $asm_file {
33 declare_labels Db D72f8 D736e
34 declare_labels D266465 D266477 D266483 D266496 D266498 D266ad3 D266ad9 \
35 D266ade D26b227 D26b237
36 declare_labels D26d8b1 D26d8c3 D26d8cf D26d944 D26d946 D26e103 D26e145 \
37 D26e415 D26e48c D26df00 D26df06 D26df0b D272519 D274c1a D274c42
41 {language @DW_LANG_C99}
45 {abstract_origin %$D272519}
49 D736e: inlined_subroutine {
50 {abstract_origin %$D26b227}
55 {abstract_origin %$D274c42}
63 D266465: compile_unit {
64 {language @DW_LANG_C99}
73 {encoding @DW_ATE_unsigned}
76 D266496: pointer_type {
80 D266498: restrict_type {
84 D266ad3: pointer_type {
89 D266ad9: restrict_type {
93 D266ade: const_type {}
100 D26b237: formal_parameter {
117 D26d8b1: compile_unit {
118 {language @DW_LANG_C99}
127 {encoding @DW_ATE_unsigned}
128 {name "long unsigned int"}
131 D26d944: pointer_type {
135 D26d946: restrict_type {
139 D26e103: structure_type {
146 {data_member_location 0 sdata}
150 D26e145: pointer_type {
160 D26e48c: pointer_type {
165 D26df00: pointer_type {
170 D26df06: restrict_type {
174 D26df0b: const_type {}
176 D272519: subprogram {
177 {name "bytes_repeat"}
181 D274c1a: subprogram {
194 D274c42: formal_parameter {
203 if {[prepare_for_testing "failed to prepare" $testfile \
204 "${asm_file} ${srcfile}" {}]} {
208 # All we need to do is set a breakpoint, which causes the DWARF
209 # info to be read, to demonstrate the problem.
211 gdb_breakpoint "bytes_repeat" message