1 # Copyright 2016-2017 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 accessing "non-variable" variables, i.e., variables which are
17 # optimized to a constant DWARF location expression and/or
18 # partially/fully optimized out.
22 if {![dwarf2_support]} { return 0 }
24 standard_testfile main.c nonvar-access-dw.S
26 # Make some DWARF for the test.
27 set asm_file [standard_output_file $srcfile2]
29 Dwarf::assemble $asm_file {
34 declare_labels int_type_label short_type_label
35 declare_labels struct_s_label struct_t_label
37 int_type_label: base_type {
39 {encoding @DW_ATE_signed}
40 {byte_size 4 DW_FORM_sdata}
43 struct_s_label: structure_type {
45 {byte_size 4 DW_FORM_sdata}
49 {type :$int_type_label}
50 {data_member_location 0 DW_FORM_udata}
51 {bit_size 8 DW_FORM_udata}
55 {type :$int_type_label}
56 {data_bit_offset 8 DW_FORM_udata}
57 {bit_size 24 DW_FORM_udata}
61 struct_t_label: structure_type {
63 {byte_size 4 DW_FORM_sdata}
67 {type :$int_type_label}
68 {data_member_location 0 DW_FORM_udata}
69 {bit_size 9 DW_FORM_udata}
73 {type :$int_type_label}
74 {data_bit_offset 9 DW_FORM_udata}
75 {bit_size 23 DW_FORM_udata}
81 {DW_AT_external 1 flag}
82 {low_pc [gdb_target_symbol main] DW_FORM_addr}
83 {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
87 {type :$int_type_label}
91 {type :$struct_s_label}
95 {type :$struct_s_label}
107 {type :$struct_t_label}
122 if { [prepare_for_testing "failed to prepare" ${testfile} \
123 [list $srcfile $asm_file] {nodebug}] } {
131 gdb_test "print def_s" " = \\{a = 0, b = -1\\}"
132 gdb_test "print def_t" " = \\{a = 0, b = -1\\}"
133 gdb_test "print undef_int" " = <optimized out>"
134 gdb_test "print undef_s.a" " = <optimized out>"