]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/data-loc.exp
update copyright year range in GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / data-loc.exp
CommitLineData
61baf725 1# Copyright 2014-2017 Free Software Foundation, Inc.
3c8c5dcc
JB
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/>.
15load_lib dwarf.exp
16
17# This test can only be run on targets which support DWARF-2 and use gas.
18if {![dwarf2_support]} {
19 return 0
20}
21
22standard_testfile data-loc.c data-loc-dw.S
23
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.
26#
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.
30
5b362f04 31if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
3c8c5dcc
JB
32 return -1
33}
34
35# Make some DWARF for the test.
36set asm_file [standard_output_file $srcfile2]
37Dwarf::assemble $asm_file {
38 cu {} {
39 DW_TAG_compile_unit {
40 {DW_AT_language @DW_LANG_Ada95}
41 {DW_AT_name foo.adb}
42 {DW_AT_comp_dir /tmp}
43 } {
d36430db 44 declare_labels integer_label array_label array_ptr_label
c6f0b406 45 set int_size [get_sizeof "int" 4]
3c8c5dcc
JB
46
47 integer_label: DW_TAG_base_type {
c6f0b406 48 {DW_AT_byte_size $int_size DW_FORM_sdata}
3c8c5dcc
JB
49 {DW_AT_encoding @DW_ATE_signed}
50 {DW_AT_name integer}
51 }
52
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
58 DW_OP_deref
59 } SPECIAL_expr}
60 {external 1 flag}
61 } {
62 DW_TAG_subrange_type {
63 {DW_AT_type :$integer_label}
64 {DW_AT_lower_bound {
65 DW_OP_push_object_address
66 DW_OP_plus_uconst [get_sizeof "void *" 96]
67 DW_OP_deref
68 DW_OP_deref_size [get_sizeof "int" 4]
69 } SPECIAL_expr}
70 {DW_AT_upper_bound {
71 DW_OP_push_object_address
72 DW_OP_plus_uconst [get_sizeof "void *" 96]
73 DW_OP_deref
74 DW_OP_plus_uconst [get_sizeof "int" 4]
75 DW_OP_deref_size [get_sizeof "int" 4]
76 } SPECIAL_expr}
3c8c5dcc
JB
77 }
78 }
d36430db 79 array_ptr_label: DW_TAG_typedef {
3c8c5dcc
JB
80 {DW_AT_name foo__array_type}
81 {DW_AT_type :$array_label}
82 }
83 DW_TAG_variable {
84 {DW_AT_name foo__three}
85 {DW_AT_type :$array_label}
86 {DW_AT_location {
2223449a 87 DW_OP_addr [gdb_target_symbol table_1]
3c8c5dcc
JB
88 } SPECIAL_expr}
89 {external 1 flag}
90 }
d36430db
JB
91 DW_TAG_variable {
92 {DW_AT_name foo__three_tdef}
93 {DW_AT_type :$array_ptr_label}
94 {DW_AT_location {
2223449a 95 DW_OP_addr [gdb_target_symbol table_1]
d36430db
JB
96 } SPECIAL_expr}
97 {external 1 flag}
98 }
3c8c5dcc
JB
99 DW_TAG_variable {
100 {DW_AT_name foo__five}
101 {DW_AT_type :$array_label}
102 {DW_AT_location {
2223449a 103 DW_OP_addr [gdb_target_symbol table_2]
3c8c5dcc
JB
104 } SPECIAL_expr}
105 {external 1 flag}
106 }
d36430db
JB
107 DW_TAG_variable {
108 {DW_AT_name foo__five_tdef}
109 {DW_AT_type :$array_ptr_label}
110 {DW_AT_location {
2223449a 111 DW_OP_addr [gdb_target_symbol table_2]
d36430db
JB
112 } SPECIAL_expr}
113 {external 1 flag}
114 }
3c8c5dcc
JB
115 }
116 }
117}
118
119# Now that we've generated the DWARF debugging info, rebuild our
120# program using our debug info instead of the info generated by
121# the compiler.
122
5b362f04 123if { [prepare_for_testing "failed to prepare" ${testfile} \
3c8c5dcc
JB
124 [list $srcfile $asm_file] {nodebug}] } {
125 return -1
126}
127
128if ![runto_main] {
129 return -1
130}
131
132gdb_test_no_output "set language ada"
133
d36430db
JB
134# foo.three
135
3c8c5dcc
JB
136gdb_test "print foo.three" \
137 " = \\(1, 2, 3\\)"
138
139gdb_test "ptype foo.three" \
140 "type = array \\(1 .. 3\\) of integer"
141
142gdb_test "print foo.three(1)" \
143 " = 1"
144
145gdb_test "print foo.three(2)" \
146 " = 2"
147
148gdb_test "print foo.three(3)" \
149 " = 3"
150
151gdb_test "print foo.three'first" \
152 " = 1"
153
154gdb_test "print foo.three'last" \
155 " = 3"
156
157gdb_test "print foo.three'length" \
158 " = 3"
159
d36430db
JB
160# foo.three_tdef
161
162gdb_test "print foo.three_tdef" \
163 " = \\(1, 2, 3\\)"
164
165gdb_test "ptype foo.three_tdef" \
166 "type = array \\(1 .. 3\\) of integer"
167
168gdb_test "print foo.three_tdef(1)" \
169 " = 1"
170
171gdb_test "print foo.three_tdef(2)" \
172 " = 2"
173
174gdb_test "print foo.three_tdef(3)" \
175 " = 3"
176
177gdb_test "print foo.three_tdef'first" \
178 " = 1"
179
180gdb_test "print foo.three_tdef'last" \
181 " = 3"
182
183gdb_test "print foo.three_tdef'length" \
184 " = 3"
185
3c8c5dcc
JB
186gdb_test "print foo.five" \
187 " = \\(2 => 5, 8, 13, 21, 34\\)"
188
189gdb_test "ptype foo.five" \
190 "type = array \\(2 .. 6\\) of integer"
191
192gdb_test "ptype foo.array_type" \
193 "type = array \\(<>\\) of integer"
194
d36430db
JB
195# foo.five
196
3c8c5dcc
JB
197gdb_test "print foo.five(2)" \
198 " = 5"
199
200gdb_test "print foo.five(3)" \
201 " = 8"
202
203gdb_test "print foo.five(4)" \
204 " = 13"
205
206gdb_test "print foo.five(5)" \
207 " = 21"
208
209gdb_test "print foo.five(6)" \
210 " = 34"
211
212gdb_test "print foo.five'first" \
213 " = 2"
214
215gdb_test "print foo.five'last" \
216 " = 6"
217
218gdb_test "print foo.five'length" \
219 " = 5"
220
d36430db
JB
221# foo.five_tdef
222
223gdb_test "print foo.five_tdef" \
224 " = \\(2 => 5, 8, 13, 21, 34\\)"
225
226gdb_test "ptype foo.five_tdef" \
227 "type = array \\(2 .. 6\\) of integer"
228
229gdb_test "ptype foo.array_type" \
230 "type = array \\(<>\\) of integer"
231
232gdb_test "print foo.five_tdef(2)" \
233 " = 5"
234
235gdb_test "print foo.five_tdef(3)" \
236 " = 8"
237
238gdb_test "print foo.five_tdef(4)" \
239 " = 13"
240
241gdb_test "print foo.five_tdef(5)" \
242 " = 21"
243
244gdb_test "print foo.five_tdef(6)" \
245 " = 34"
246
247gdb_test "print foo.five_tdef'first" \
248 " = 2"
249
250gdb_test "print foo.five_tdef'last" \
251 " = 6"
252
253gdb_test "print foo.five_tdef'length" \
254 " = 5"
255
3c8c5dcc
JB
256gdb_test_no_output "set lang c"
257
d36430db
JB
258# foo__three
259
3c8c5dcc
JB
260gdb_test "print foo__three" \
261 " = \\{1, 2, 3\\}"
262
263gdb_test "ptype foo__three" \
264 "type = integer \\\[3\\\]"
265
d36430db
JB
266# foo__three_tdef
267
268gdb_test "print foo__three_tdef" \
269 " = \\{1, 2, 3\\}"
270
271gdb_test "ptype foo__three_tdef" \
272 "type = integer \\\[3\\\]"
273
274# foo__five
275
3c8c5dcc
JB
276gdb_test "print foo__five" \
277 " = \\{5, 8, 13, 21, 34\\}"
278
279gdb_test "ptype foo__five" \
280 "type = integer \\\[5\\\]"
281
d36430db
JB
282# foo__five_tdef
283
284gdb_test "print foo__five_tdef" \
285 " = \\{5, 8, 13, 21, 34\\}"
286
287gdb_test "ptype foo__five_tdef" \
288 "type = integer \\\[5\\\]"
289
3c8c5dcc
JB
290gdb_test "ptype foo__array_type" \
291 "type = integer \\\[variable length\\\]"