1 # Copyright 2021-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 our workaround for a GCC 11 bug, where it sometimes puts a -1 value for 17 # DW_AT_data_member_location: 18 # 19 # Negative DW_AT_data_member_location 20 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101378 21 22 load_lib dwarf.exp 23 24 # This test can only be run on targets which support DWARF-2 and use gas. 25 require dwarf2_support 26 27 standard_testfile .c -dw.S 28 29 set asm_file [standard_output_file ${srcfile2}] 30 31 Dwarf::assemble ${asm_file} { 32 cu {} { 33 DW_TAG_compile_unit { 34 {DW_AT_language @DW_LANG_C99} 35 {DW_AT_producer "GNU C++17 11.1.0 -mtune=generic -march=x86-64 -g3 -O0"} 36 {name ${::srcfile}} 37 } { 38 declare_labels int_label struct_label 39 40 int_label: DW_TAG_base_type { 41 {DW_AT_byte_size 4 DW_FORM_udata} 42 {DW_AT_encoding @DW_ATE_signed} 43 {DW_AT_name "int"} 44 } 45 46 struct_label: DW_TAG_structure_type { 47 {DW_AT_name "the_struct"} 48 {DW_AT_byte_size 4 DW_FORM_udata} 49 } { 50 DW_TAG_member { 51 {DW_AT_name "field"} 52 {DW_AT_type :$int_label} 53 {DW_AT_data_member_location -1 DW_FORM_sdata} 54 } 55 } 56 57 DW_TAG_variable { 58 {DW_AT_name "s"} 59 {DW_AT_type :$struct_label} 60 {DW_AT_location {DW_OP_addr [gdb_target_symbol "s"]} SPECIAL_expr} 61 } 62 } 63 } 64 } 65 66 if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $asm_file] {nodebug}] } { 67 return 68 } 69 70 if { ![runto_main] } { 71 return 72 } 73 74 gdb_test "print /x s" " = {field = 0x11222211}" 75 gdb_test "print /x s.field" " = 0x11222211" 76