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 # Test a huge enum. A colossal enum. If you will, a mega enum. 17 18 load_lib dwarf.exp 19 require dwarf2_support 20 21 standard_testfile main.c mega-enum.S 22 23 set asm_file [standard_output_file $srcfile2] 24 Dwarf::assemble $asm_file { 25 global srcfile 26 27 cu {} { 28 DW_TAG_compile_unit { 29 {DW_AT_language @DW_LANG_C} 30 {DW_AT_name $srcfile} 31 {DW_AT_comp_dir /tmp} 32 } { 33 declare_labels integer_label 34 35 integer_label: DW_TAG_base_type { 36 {DW_AT_byte_size 4 DW_FORM_sdata} 37 {DW_AT_encoding @DW_ATE_signed} 38 {DW_AT_name int} 39 } 40 41 DW_TAG_enumeration_type { 42 {DW_AT_name mega_enum} 43 {DW_AT_type :$integer_label} 44 } { 45 # In the past gdb used a 'short' for the field count. 46 # But this fails if there are too many fields. If the 47 # field count here is too high, gas takes a long time; 48 # so use a number that's just big enough. 49 for {set i 0} {$i < 65538} {incr i} { 50 DW_TAG_enumerator { 51 {DW_AT_name DEI_$i} 52 {DW_AT_const_value $i DW_FORM_sdata} 53 } 54 } 55 } 56 } 57 } 58 } 59 60 if {[prepare_for_testing "failed to prepare" ${testfile} \ 61 [list $srcfile $asm_file] {nodebug}]} { 62 return -1 63 } 64 65 # The largest known Fermat prime. 66 gdb_test "print/d DEI_65537" " = 65537" 67 gdb_test "print (enum mega_enum) 65537" " = DEI_65537" 68