Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / negative-data-member-location.exp
blob895a00589513d2176b8601c539b0b05eebc0dede
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
22 load_lib dwarf.exp
24 # This test can only be run on targets which support DWARF-2 and use gas.
25 if { ![dwarf2_support] } {
26     return 0
29 standard_testfile .c -dw.S
31 set asm_file [standard_output_file ${srcfile2}]
33 Dwarf::assemble ${asm_file} {
34     cu {} {
35         DW_TAG_compile_unit {
36             {DW_AT_language @DW_LANG_C99}
37             {DW_AT_producer "GNU C++17 11.1.0 -mtune=generic -march=x86-64 -g3 -O0"}
38             {name ${::srcfile}}
39         } {
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}
45                 {DW_AT_name "int"}
46             }
48             struct_label: DW_TAG_structure_type {
49                 {DW_AT_name "the_struct"}
50                 {DW_AT_byte_size 4 DW_FORM_udata}
51             } {
52                 DW_TAG_member {
53                     {DW_AT_name "field"}
54                     {DW_AT_type :$int_label}
55                     {DW_AT_data_member_location -1 DW_FORM_sdata}
56                 }
57             }
59             DW_TAG_variable {
60                 {DW_AT_name "s"}
61                 {DW_AT_type :$struct_label}
62                 {DW_AT_location {DW_OP_addr [gdb_target_symbol "s"]} SPECIAL_expr}
63             }
64         }
65     }
68 if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $asm_file] {nodebug}] } {
69     return
72 if { ![runto_main] } {
73     return
76 gdb_test "print /x s" " = {field = 0x11222211}"
77 gdb_test "print /x s.field" " = 0x11222211"