1 # Copyright 2021-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 # Test our workaround for a GCC 11 bug, where it sometimes puts a -1 value for
17 # DW_AT_data_member_location:
19 # Negative DW_AT_data_member_location
20 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101378
24 # This test can only be run on targets which support DWARF-2 and use gas.
25 require dwarf2_support
27 standard_testfile .c -dw.S
29 set asm_file [standard_output_file ${srcfile2}]
31 Dwarf::assemble ${asm_file} {
34 {DW_AT_language @DW_LANG_C99}
35 {DW_AT_producer "GNU C++17 11.1.0 -mtune=generic -march=x86-64 -g3 -O0"}
38 declare_labels int_label struct_label
40 int_label: DW_TAG_base_type {
41 {DW_AT_byte_size 4 DW_FORM_udata}
42 {DW_AT_encoding @DW_ATE_signed}
46 struct_label: DW_TAG_structure_type {
47 {DW_AT_name "the_struct"}
48 {DW_AT_byte_size 4 DW_FORM_udata}
52 {DW_AT_type :$int_label}
53 {DW_AT_data_member_location -1 DW_FORM_sdata}
59 {DW_AT_type :$struct_label}
60 {DW_AT_location {DW_OP_addr [gdb_target_symbol "s"]} SPECIAL_expr}
66 if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $asm_file] {nodebug}] } {
70 if { ![runto_main] } {
74 gdb_test "print /x s" " = {field = 0x11222211}"
75 gdb_test "print /x s.field" " = 0x11222211"