Home | History | Annotate | Line # | Download | only in gdb.dwarf2
      1 # Copyright 2025 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 # Test a nameless "enum class".  This is nonsensical but previously
     17 # made gdb crash.
     18 
     19 load_lib dwarf.exp
     20 require dwarf2_support
     21 
     22 standard_testfile main.c .S
     23 
     24 set asm_file [standard_output_file $srcfile2]
     25 Dwarf::assemble $asm_file {
     26     global srcfile
     27 
     28     cu {} {
     29 	DW_TAG_compile_unit {
     30 	    {DW_AT_language @DW_LANG_D}
     31 	    {DW_AT_name	$srcfile}
     32 	    {DW_AT_comp_dir /tmp}
     33 	} {
     34 	    declare_labels integer_label
     35 
     36 	    integer_label: DW_TAG_base_type {
     37 		{DW_AT_byte_size 4 DW_FORM_sdata}
     38 		{DW_AT_encoding	 @DW_ATE_signed}
     39 		{DW_AT_name	 int}
     40 	    }
     41 
     42 	    DW_TAG_enumeration_type {
     43 		{DW_AT_type :$integer_label}
     44 		{DW_AT_enum_class 1 DW_FORM_flag}
     45 	    } {
     46 		DW_TAG_enumerator {
     47 		    {DW_AT_name VALUE}
     48 		    {DW_AT_const_value 17 DW_FORM_sdata}
     49 		}
     50 	    }
     51 	}
     52     }
     53 }
     54 
     55 if {[prepare_for_testing "failed to prepare" ${testfile} \
     56 	 [list $srcfile $asm_file] {nodebug}]} {
     57     return -1
     58 }
     59 
     60 # The bug was a crash, so just do anything here to verify gdb is still
     61 # alive.
     62 gdb_test "print 23" " = 23"
     63