]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dynarr-ptr.exp
CommitLineData
e2882c85 1# Copyright 2014-2018 Free Software Foundation, Inc.
7828a5f5
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 dynarr-ptr.c dynarr-ptr-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 dynarr-ptr.c program.
28# Any program would do, but since we already have dynarr-ptr.c
29# specifically for this testcase, might as well use that.
30
5b362f04 31if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
7828a5f5
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 } {
44 declare_labels integer_label array_label array_ptr_label \
45 array_typedef_label
46 set ptr_size [get_sizeof "void *" 96]
c6f0b406 47 set int_size [get_sizeof "int" 4]
7828a5f5
JB
48
49 integer_label: DW_TAG_base_type {
c6f0b406 50 {DW_AT_byte_size $int_size DW_FORM_sdata}
7828a5f5
JB
51 {DW_AT_encoding @DW_ATE_signed}
52 {DW_AT_name integer}
53 }
54
55 array_label: DW_TAG_array_type {
56 {DW_AT_name foo__array_type}
57 {DW_AT_type :$integer_label}
58 {external 1 flag}
59 } {
60 DW_TAG_subrange_type {
61 {DW_AT_type :$integer_label}
62 {DW_AT_lower_bound {
63 DW_OP_push_object_address
c6f0b406 64 DW_OP_const1u [expr {2 * $int_size}]
7828a5f5 65 DW_OP_minus
c6f0b406 66 DW_OP_deref_size $int_size
7828a5f5
JB
67 } SPECIAL_expr}
68 {DW_AT_upper_bound {
69 DW_OP_push_object_address
c6f0b406 70 DW_OP_const1u $int_size
7828a5f5 71 DW_OP_minus
c6f0b406 72 DW_OP_deref_size $int_size
7828a5f5
JB
73 } SPECIAL_expr}
74 }
75 }
76 array_ptr_label: DW_TAG_pointer_type {
8cbc97c6 77 {DW_AT_byte_size $ptr_size DW_FORM_data1}
7828a5f5
JB
78 {DW_AT_type :$array_label}
79 }
80 array_typedef_label: DW_TAG_typedef {
81 {DW_AT_name "foo__array_ptr"}
82 {DW_AT_type :$array_ptr_label}
83 }
84 DW_TAG_variable {
85 {DW_AT_name foo__three_ptr}
86 {DW_AT_type :$array_ptr_label}
87 {DW_AT_location {
2223449a 88 DW_OP_addr [gdb_target_symbol table_1_ptr]
7828a5f5
JB
89 } SPECIAL_expr}
90 {external 1 flag}
91 }
92 DW_TAG_variable {
93 {DW_AT_name foo__three_ptr_tdef}
94 {DW_AT_type :$array_typedef_label}
95 {DW_AT_location {
2223449a 96 DW_OP_addr [gdb_target_symbol table_1_ptr]
7828a5f5
JB
97 } SPECIAL_expr}
98 {external 1 flag}
99 }
100 DW_TAG_variable {
101 {DW_AT_name foo__five_ptr}
102 {DW_AT_type :$array_ptr_label}
103 {DW_AT_location {
2223449a 104 DW_OP_addr [gdb_target_symbol table_2_ptr]
7828a5f5
JB
105 } SPECIAL_expr}
106 {external 1 flag}
107 }
108 DW_TAG_variable {
109 {DW_AT_name foo__five_ptr_tdef}
110 {DW_AT_type :$array_typedef_label}
111 {DW_AT_location {
2223449a 112 DW_OP_addr [gdb_target_symbol table_2_ptr]
7828a5f5
JB
113 } SPECIAL_expr}
114 {external 1 flag}
115 }
116 }
117 }
118}
119
120# Now that we've generated the DWARF debugging info, rebuild our
121# program using our debug info instead of the info generated by
122# the compiler.
123
5b362f04 124if { [prepare_for_testing "failed to prepare" ${testfile} \
7828a5f5
JB
125 [list $srcfile $asm_file] {nodebug}] } {
126 return -1
127}
128
129if ![runto_main] {
130 return -1
131}
132
133gdb_test_no_output "set language ada"
134
135# foo.three_ptr.all
136
137gdb_test "print foo.three_ptr.all" \
138 " = \\(1, 2, 3\\)"
139
deede10c
JB
140gdb_test "print foo.three_ptr.all(1)" \
141 " = 1"
142
143gdb_test "print foo.three_ptr.all(2)" \
144 " = 2"
145
146gdb_test "print foo.three_ptr.all(3)" \
147 " = 3"
148
eb479039
JB
149gdb_test "print foo.three_ptr.all'first" \
150 " = 1"
151
152gdb_test "print foo.three_ptr.all'last" \
153 " = 3"
154
155gdb_test "print foo.three_ptr.all'length" \
156 " = 3"
157
96334934
JB
158gdb_test "ptype foo.three_ptr.all" \
159 " = array \\(<>\\) of integer"
160
deede10c
JB
161# foo.three_ptr
162
163gdb_test "print foo.three_ptr(1)" \
164 " = 1"
165
166gdb_test "print foo.three_ptr(2)" \
167 " = 2"
168
169gdb_test "print foo.three_ptr(3)" \
170 " = 3"
171
eb479039
JB
172gdb_test "print foo.three_ptr'first" \
173 " = 1"
174
175gdb_test "print foo.three_ptr'last" \
176 " = 3"
177
178gdb_test "print foo.three_ptr'length" \
179 " = 3"
180
96334934
JB
181gdb_test "ptype foo.three_ptr" \
182 " = access array \\(<>\\) of integer"
183
7828a5f5
JB
184# foo.three_ptr_tdef.all
185
186gdb_test "print foo.three_ptr_tdef.all" \
187 " = \\(1, 2, 3\\)"
188
deede10c
JB
189gdb_test "print foo.three_ptr_tdef.all(1)" \
190 " = 1"
191
192gdb_test "print foo.three_ptr_tdef.all(2)" \
193 " = 2"
194
195gdb_test "print foo.three_ptr_tdef.all(3)" \
196 " = 3"
197
eb479039
JB
198gdb_test "print foo.three_ptr_tdef.all'first" \
199 " = 1"
200
201gdb_test "print foo.three_ptr_tdef.all'last" \
202 " = 3"
203
204gdb_test "print foo.three_ptr_tdef.all'length" \
205 " = 3"
206
96334934
JB
207gdb_test "ptype foo.three_ptr_tdef.all" \
208 " = array \\(<>\\) of integer"
209
deede10c
JB
210# foo.three_ptr_tdef
211
212gdb_test "print foo.three_ptr_tdef(1)" \
213 " = 1"
214
215gdb_test "print foo.three_ptr_tdef(2)" \
216 " = 2"
217
218gdb_test "print foo.three_ptr_tdef(3)" \
219 " = 3"
220
eb479039
JB
221gdb_test "print foo.three_ptr_tdef'first" \
222 " = 1"
223
224gdb_test "print foo.three_ptr_tdef'last" \
225 " = 3"
226
227gdb_test "print foo.three_ptr_tdef'length" \
228 " = 3"
229
96334934
JB
230gdb_test "ptype foo.three_ptr_tdef" \
231 " = access array \\(<>\\) of integer"
232
7828a5f5
JB
233# foo.five_ptr.all
234
235gdb_test "print foo.five_ptr.all" \
236 " = \\(2 => 5, 8, 13, 21, 34\\)"
237
deede10c
JB
238gdb_test "print foo.five_ptr.all(2)" \
239 " = 5"
240
241gdb_test "print foo.five_ptr.all(3)" \
242 " = 8"
243
244gdb_test "print foo.five_ptr.all(4)" \
245 " = 13"
246
247gdb_test "print foo.five_ptr.all(5)" \
248 " = 21"
249
250gdb_test "print foo.five_ptr.all(6)" \
251 " = 34"
252
eb479039
JB
253gdb_test "print foo.five_ptr.all'first" \
254 " = 2"
255
256gdb_test "print foo.five_ptr.all'last" \
257 " = 6"
258
259gdb_test "print foo.five_ptr.all'length" \
260 " = 5"
261
96334934
JB
262gdb_test "ptype foo.five_ptr.all" \
263 " = array \\(<>\\) of integer"
264
deede10c
JB
265# foo.five_ptr
266
267gdb_test "print foo.five_ptr(2)" \
268 " = 5"
269
270gdb_test "print foo.five_ptr(3)" \
271 " = 8"
272
273gdb_test "print foo.five_ptr(4)" \
274 " = 13"
275
276gdb_test "print foo.five_ptr(5)" \
277 " = 21"
278
279gdb_test "print foo.five_ptr(6)" \
280 " = 34"
281
eb479039
JB
282gdb_test "print foo.five_ptr'first" \
283 " = 2"
284
285gdb_test "print foo.five_ptr'last" \
286 " = 6"
287
288gdb_test "print foo.five_ptr'length" \
289 " = 5"
290
96334934
JB
291gdb_test "ptype foo.five_ptr" \
292 " = access array \\(<>\\) of integer"
293
7828a5f5
JB
294# foo.five_ptr_tdef.all
295
296gdb_test "print foo.five_ptr_tdef.all" \
297 " = \\(2 => 5, 8, 13, 21, 34\\)"
deede10c
JB
298
299gdb_test "print foo.five_ptr_tdef.all(2)" \
300 " = 5"
301
302gdb_test "print foo.five_ptr_tdef.all(3)" \
303 " = 8"
304
305gdb_test "print foo.five_ptr_tdef.all(4)" \
306 " = 13"
307
308gdb_test "print foo.five_ptr_tdef.all(5)" \
309 " = 21"
310
311gdb_test "print foo.five_ptr_tdef.all(6)" \
312 " = 34"
313
eb479039
JB
314gdb_test "print foo.five_ptr_tdef.all'first" \
315 " = 2"
316
317gdb_test "print foo.five_ptr_tdef.all'last" \
318 " = 6"
319
320gdb_test "print foo.five_ptr_tdef.all'length" \
321 " = 5"
322
96334934
JB
323gdb_test "ptype foo.five_ptr_tdef.all" \
324 " = array \\(<>\\) of integer"
325
deede10c
JB
326# foo.five_ptr_tdef
327
328gdb_test "print foo.five_ptr_tdef(2)" \
329 " = 5"
330
331gdb_test "print foo.five_ptr_tdef(3)" \
332 " = 8"
333
334gdb_test "print foo.five_ptr_tdef(4)" \
335 " = 13"
336
337gdb_test "print foo.five_ptr_tdef(5)" \
338 " = 21"
339
340gdb_test "print foo.five_ptr_tdef(6)" \
341 " = 34"
eb479039
JB
342
343gdb_test "print foo.five_ptr_tdef'first" \
344 " = 2"
345
346gdb_test "print foo.five_ptr_tdef'last" \
347 " = 6"
348
349gdb_test "print foo.five_ptr_tdef'length" \
350 " = 5"
96334934
JB
351
352gdb_test "ptype foo.five_ptr_tdef" \
353 " = access array \\(<>\\) of integer"