1 # Copyright 2014-2015 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/>.
17 # This test can only be run on targets which support DWARF-2 and use gas.
18 if {![dwarf2_support]} {
22 standard_testfile data-loc.c data-loc-dw.S
24 # We need to know the size of integer and address types in order
25 # to write some of the debugging info we'd like to generate.
27 # For that, we ask GDB by debugging our data-loc.c program.
28 # Any program would do, but since we already have data-loc.c
29 # specifically for this testcase, might as well use that.
31 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
32 untested ${testfile}.exp
36 # Make some DWARF for the test.
37 set asm_file [standard_output_file $srcfile2]
38 Dwarf::assemble $asm_file {
41 {DW_AT_language @DW_LANG_Ada95}
45 declare_labels integer_label array_label array_ptr_label
47 integer_label: DW_TAG_base_type {
48 {DW_AT_byte_size 4 DW_FORM_sdata}
49 {DW_AT_encoding @DW_ATE_signed}
53 array_label: DW_TAG_array_type {
54 {DW_AT_name foo__array_type}
55 {DW_AT_type :$integer_label}
56 {DW_AT_data_location {
57 DW_OP_push_object_address
62 DW_TAG_subrange_type {
63 {DW_AT_type :$integer_label}
65 DW_OP_push_object_address
66 DW_OP_plus_uconst [get_sizeof "void *" 96]
68 DW_OP_deref_size [get_sizeof "int" 4]
71 DW_OP_push_object_address
72 DW_OP_plus_uconst [get_sizeof "void *" 96]
74 DW_OP_plus_uconst [get_sizeof "int" 4]
75 DW_OP_deref_size [get_sizeof "int" 4]
79 array_ptr_label: DW_TAG_typedef {
80 {DW_AT_name foo__array_type}
81 {DW_AT_type :$array_label}
84 {DW_AT_name foo__three}
85 {DW_AT_type :$array_label}
92 {DW_AT_name foo__three_tdef}
93 {DW_AT_type :$array_ptr_label}
100 {DW_AT_name foo__five}
101 {DW_AT_type :$array_label}
108 {DW_AT_name foo__five_tdef}
109 {DW_AT_type :$array_ptr_label}
119 # Now that we've generated the DWARF debugging info, rebuild our
120 # program using our debug info instead of the info generated by
123 if { [prepare_for_testing ${testfile}.exp ${testfile} \
124 [list $srcfile $asm_file] {nodebug}] } {
132 gdb_test_no_output "set language ada"
136 gdb_test "print foo.three" \
139 gdb_test "ptype foo.three" \
140 "type = array \\(1 .. 3\\) of integer"
142 gdb_test "print foo.three(1)" \
145 gdb_test "print foo.three(2)" \
148 gdb_test "print foo.three(3)" \
151 gdb_test "print foo.three'first" \
154 gdb_test "print foo.three'last" \
157 gdb_test "print foo.three'length" \
162 gdb_test "print foo.three_tdef" \
165 gdb_test "ptype foo.three_tdef" \
166 "type = array \\(1 .. 3\\) of integer"
168 gdb_test "print foo.three_tdef(1)" \
171 gdb_test "print foo.three_tdef(2)" \
174 gdb_test "print foo.three_tdef(3)" \
177 gdb_test "print foo.three_tdef'first" \
180 gdb_test "print foo.three_tdef'last" \
183 gdb_test "print foo.three_tdef'length" \
186 gdb_test "print foo.five" \
187 " = \\(2 => 5, 8, 13, 21, 34\\)"
189 gdb_test "ptype foo.five" \
190 "type = array \\(2 .. 6\\) of integer"
192 gdb_test "ptype foo.array_type" \
193 "type = array \\(<>\\) of integer"
197 gdb_test "print foo.five(2)" \
200 gdb_test "print foo.five(3)" \
203 gdb_test "print foo.five(4)" \
206 gdb_test "print foo.five(5)" \
209 gdb_test "print foo.five(6)" \
212 gdb_test "print foo.five'first" \
215 gdb_test "print foo.five'last" \
218 gdb_test "print foo.five'length" \
223 gdb_test "print foo.five_tdef" \
224 " = \\(2 => 5, 8, 13, 21, 34\\)"
226 gdb_test "ptype foo.five_tdef" \
227 "type = array \\(2 .. 6\\) of integer"
229 gdb_test "ptype foo.array_type" \
230 "type = array \\(<>\\) of integer"
232 gdb_test "print foo.five_tdef(2)" \
235 gdb_test "print foo.five_tdef(3)" \
238 gdb_test "print foo.five_tdef(4)" \
241 gdb_test "print foo.five_tdef(5)" \
244 gdb_test "print foo.five_tdef(6)" \
247 gdb_test "print foo.five_tdef'first" \
250 gdb_test "print foo.five_tdef'last" \
253 gdb_test "print foo.five_tdef'length" \
256 gdb_test_no_output "set lang c"
260 gdb_test "print foo__three" \
263 gdb_test "ptype foo__three" \
264 "type = integer \\\[3\\\]"
268 gdb_test "print foo__three_tdef" \
271 gdb_test "ptype foo__three_tdef" \
272 "type = integer \\\[3\\\]"
276 gdb_test "print foo__five" \
277 " = \\{5, 8, 13, 21, 34\\}"
279 gdb_test "ptype foo__five" \
280 "type = integer \\\[5\\\]"
284 gdb_test "print foo__five_tdef" \
285 " = \\{5, 8, 13, 21, 34\\}"
287 gdb_test "ptype foo__five_tdef" \
288 "type = integer \\\[5\\\]"
290 gdb_test "ptype foo__array_type" \
291 "type = integer \\\[variable length\\\]"