1 # Copyright 2021-2023 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 if { ![dwarf2_support] } {
29 standard_testfile .c -dw.S
31 set asm_file [standard_output_file ${srcfile2}]
33 Dwarf::assemble ${asm_file} {
36 {DW_AT_language @DW_LANG_C99}
37 {DW_AT_producer "GNU C++17 11.1.0 -mtune=generic -march=x86-64 -g3 -O0"}
40 declare_labels int_label struct_label
42 int_label: DW_TAG_base_type {
43 {DW_AT_byte_size 4 DW_FORM_udata}
44 {DW_AT_encoding @DW_ATE_signed}
48 struct_label: DW_TAG_structure_type {
49 {DW_AT_name "the_struct"}
50 {DW_AT_byte_size 4 DW_FORM_udata}
54 {DW_AT_type :$int_label}
55 {DW_AT_data_member_location -1 DW_FORM_sdata}
61 {DW_AT_type :$struct_label}
62 {DW_AT_location {DW_OP_addr [gdb_target_symbol "s"]} SPECIAL_expr}
68 if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $asm_file] {nodebug}] } {
72 if { ![runto_main] } {
76 gdb_test "print /x s" " = {field = 0x11222211}"
77 gdb_test "print /x s.field" " = 0x11222211"