Fix PR12616 - gdb does not implement DW_AT_data_bit_offset
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / nonvar-access.exp
1 # Copyright 2016 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 accessing "non-variable" variables, i.e., variables which are
17 # optimized to a constant DWARF location expression and/or
18 # partially/fully optimized out.
19
20 load_lib dwarf.exp
21
22 if {![dwarf2_support]} { return 0 }
23
24 standard_testfile main.c nonvar-access-dw.S
25
26 # Make some DWARF for the test.
27 set asm_file [standard_output_file $srcfile2]
28
29 Dwarf::assemble $asm_file {
30 cu {} {
31 compile_unit {
32 {DW_AT_name main.c}
33 } {
34 declare_labels int_type_label short_type_label
35 declare_labels struct_s_label
36
37 int_type_label: base_type {
38 {name "int"}
39 {encoding @DW_ATE_signed}
40 {byte_size 4 DW_FORM_sdata}
41 }
42
43 struct_s_label: structure_type {
44 {name s}
45 {byte_size 4 DW_FORM_sdata}
46 } {
47 member {
48 {name a}
49 {type :$int_type_label}
50 {data_member_location 0 DW_FORM_udata}
51 {bit_size 8 DW_FORM_udata}
52 }
53 member {
54 {name b}
55 {type :$int_type_label}
56 {data_bit_offset 8 DW_FORM_udata}
57 {bit_size 24 DW_FORM_udata}
58 }
59 }
60
61 DW_TAG_subprogram {
62 {name main}
63 {DW_AT_external 1 flag}
64 {low_pc [gdb_target_symbol main] DW_FORM_addr}
65 {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
66 } {
67 DW_TAG_variable {
68 {name undef_int}
69 {type :$int_type_label}
70 }
71 DW_TAG_variable {
72 {name undef_s}
73 {type :$struct_s_label}
74 }
75 DW_TAG_variable {
76 {name def_s}
77 {type :$struct_s_label}
78 {location {
79 const1u 0
80 stack_value
81 bit_piece 8 0
82 const1s -1
83 stack_value
84 bit_piece 24 0
85 } SPECIAL_expr}
86 }
87 }
88 }
89 }
90 }
91
92 if { [prepare_for_testing ${testfile}.exp ${testfile} \
93 [list $srcfile $asm_file] {nodebug}] } {
94 return -1
95 }
96
97 if ![runto_main] {
98 return -1
99 }
100
101 gdb_test "print def_s" " = \\{a = 0, b = -1\\}"
102 gdb_test "print undef_int" " = <optimized out>"
103 gdb_test "print undef_s.a" " = <optimized out>"
This page took 0.033053 seconds and 4 git commands to generate.