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