Home | History | Annotate | Line # | Download | only in gdb.dwarf2
      1 # Copyright 2023-2024 Free Software Foundation, Inc.
      2 
      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.
      7 #
      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.
     12 #
     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/>.
     15 
     16 # Check that gdb doesn't hang or segfault on reading a DIE with a
     17 # specification/abstract_origin reference to itself.
     18 
     19 load_lib dwarf.exp
     20 
     21 require dwarf2_support
     22 
     23 standard_testfile main.c .S
     24 
     25 # Create the DWARF.
     26 set asm_file [standard_output_file $srcfile2]
     27 Dwarf::assemble $asm_file {
     28     cu {} {
     29 	compile_unit {{language @DW_LANG_C_plus_plus}} {
     30 	    # Check handling of self-referencing DIE.
     31 	    declare_labels c1
     32 	    c1: class_type {
     33 		{name c1}
     34 		{specification :$c1}
     35 	    }
     36 
     37 	    # Check handling of self-referencing child DIE.  Regression test
     38 	    # for PR30799.
     39 	    declare_labels f1 abstract_f1 f1_l
     40 	    abstract_f1: subprogram {}
     41 	    f1: subprogram {
     42 		{MACRO_AT_func {main}}
     43 		{abstract_origin :$abstract_f1}
     44 	    } {
     45 		f1_l: label {
     46 		    {abstract_origin :$f1_l}
     47 		}
     48 	    }
     49 	}
     50     }
     51 }
     52 
     53 if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" {}] {
     54     return -1
     55 }
     56 
     57 set index [have_index $binfile]
     58 require {string eq $index ""}
     59 
     60 require !readnow
     61 
     62 gdb_test "maint print objfiles $testfile" \
     63     "\r\n *qualified: *c1\r\n.*" \
     64     "class c1 in cooked index"
     65 
     66 gdb_test "maint expand-symtabs"
     67