Commit | Line | Data |
---|---|---|
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/>. | |
15 | load_lib dwarf.exp | |
16 | ||
17 | # This test can only be run on targets which support DWARF-2 and use gas. | |
18 | if {![dwarf2_support]} { | |
19 | return 0 | |
20 | } | |
21 | ||
22 | standard_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 | ||
31 | if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { | |
32 | untested ${testfile}.exp | |
33 | return -1 | |
34 | } | |
35 | ||
36 | # Make some DWARF for the test. | |
37 | set asm_file [standard_output_file $srcfile2] | |
38 | Dwarf::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 | ||
125 | if { [prepare_for_testing ${testfile}.exp ${testfile} \ | |
126 | [list $srcfile $asm_file] {nodebug}] } { | |
127 | return -1 | |
128 | } | |
129 | ||
130 | if ![runto_main] { | |
131 | return -1 | |
132 | } | |
133 | ||
134 | gdb_test_no_output "set language ada" | |
135 | ||
136 | # foo.three_ptr.all | |
137 | ||
138 | gdb_test "print foo.three_ptr.all" \ | |
139 | " = \\(1, 2, 3\\)" | |
140 | ||
deede10c JB |
141 | gdb_test "print foo.three_ptr.all(1)" \ |
142 | " = 1" | |
143 | ||
144 | gdb_test "print foo.three_ptr.all(2)" \ | |
145 | " = 2" | |
146 | ||
147 | gdb_test "print foo.three_ptr.all(3)" \ | |
148 | " = 3" | |
149 | ||
eb479039 JB |
150 | gdb_test "print foo.three_ptr.all'first" \ |
151 | " = 1" | |
152 | ||
153 | gdb_test "print foo.three_ptr.all'last" \ | |
154 | " = 3" | |
155 | ||
156 | gdb_test "print foo.three_ptr.all'length" \ | |
157 | " = 3" | |
158 | ||
96334934 JB |
159 | gdb_test "ptype foo.three_ptr.all" \ |
160 | " = array \\(<>\\) of integer" | |
161 | ||
deede10c JB |
162 | # foo.three_ptr |
163 | ||
164 | gdb_test "print foo.three_ptr(1)" \ | |
165 | " = 1" | |
166 | ||
167 | gdb_test "print foo.three_ptr(2)" \ | |
168 | " = 2" | |
169 | ||
170 | gdb_test "print foo.three_ptr(3)" \ | |
171 | " = 3" | |
172 | ||
eb479039 JB |
173 | gdb_test "print foo.three_ptr'first" \ |
174 | " = 1" | |
175 | ||
176 | gdb_test "print foo.three_ptr'last" \ | |
177 | " = 3" | |
178 | ||
179 | gdb_test "print foo.three_ptr'length" \ | |
180 | " = 3" | |
181 | ||
96334934 JB |
182 | gdb_test "ptype foo.three_ptr" \ |
183 | " = access array \\(<>\\) of integer" | |
184 | ||
7828a5f5 JB |
185 | # foo.three_ptr_tdef.all |
186 | ||
187 | gdb_test "print foo.three_ptr_tdef.all" \ | |
188 | " = \\(1, 2, 3\\)" | |
189 | ||
deede10c JB |
190 | gdb_test "print foo.three_ptr_tdef.all(1)" \ |
191 | " = 1" | |
192 | ||
193 | gdb_test "print foo.three_ptr_tdef.all(2)" \ | |
194 | " = 2" | |
195 | ||
196 | gdb_test "print foo.three_ptr_tdef.all(3)" \ | |
197 | " = 3" | |
198 | ||
eb479039 JB |
199 | gdb_test "print foo.three_ptr_tdef.all'first" \ |
200 | " = 1" | |
201 | ||
202 | gdb_test "print foo.three_ptr_tdef.all'last" \ | |
203 | " = 3" | |
204 | ||
205 | gdb_test "print foo.three_ptr_tdef.all'length" \ | |
206 | " = 3" | |
207 | ||
96334934 JB |
208 | gdb_test "ptype foo.three_ptr_tdef.all" \ |
209 | " = array \\(<>\\) of integer" | |
210 | ||
deede10c JB |
211 | # foo.three_ptr_tdef |
212 | ||
213 | gdb_test "print foo.three_ptr_tdef(1)" \ | |
214 | " = 1" | |
215 | ||
216 | gdb_test "print foo.three_ptr_tdef(2)" \ | |
217 | " = 2" | |
218 | ||
219 | gdb_test "print foo.three_ptr_tdef(3)" \ | |
220 | " = 3" | |
221 | ||
eb479039 JB |
222 | gdb_test "print foo.three_ptr_tdef'first" \ |
223 | " = 1" | |
224 | ||
225 | gdb_test "print foo.three_ptr_tdef'last" \ | |
226 | " = 3" | |
227 | ||
228 | gdb_test "print foo.three_ptr_tdef'length" \ | |
229 | " = 3" | |
230 | ||
96334934 JB |
231 | gdb_test "ptype foo.three_ptr_tdef" \ |
232 | " = access array \\(<>\\) of integer" | |
233 | ||
7828a5f5 JB |
234 | # foo.five_ptr.all |
235 | ||
236 | gdb_test "print foo.five_ptr.all" \ | |
237 | " = \\(2 => 5, 8, 13, 21, 34\\)" | |
238 | ||
deede10c JB |
239 | gdb_test "print foo.five_ptr.all(2)" \ |
240 | " = 5" | |
241 | ||
242 | gdb_test "print foo.five_ptr.all(3)" \ | |
243 | " = 8" | |
244 | ||
245 | gdb_test "print foo.five_ptr.all(4)" \ | |
246 | " = 13" | |
247 | ||
248 | gdb_test "print foo.five_ptr.all(5)" \ | |
249 | " = 21" | |
250 | ||
251 | gdb_test "print foo.five_ptr.all(6)" \ | |
252 | " = 34" | |
253 | ||
eb479039 JB |
254 | gdb_test "print foo.five_ptr.all'first" \ |
255 | " = 2" | |
256 | ||
257 | gdb_test "print foo.five_ptr.all'last" \ | |
258 | " = 6" | |
259 | ||
260 | gdb_test "print foo.five_ptr.all'length" \ | |
261 | " = 5" | |
262 | ||
96334934 JB |
263 | gdb_test "ptype foo.five_ptr.all" \ |
264 | " = array \\(<>\\) of integer" | |
265 | ||
deede10c JB |
266 | # foo.five_ptr |
267 | ||
268 | gdb_test "print foo.five_ptr(2)" \ | |
269 | " = 5" | |
270 | ||
271 | gdb_test "print foo.five_ptr(3)" \ | |
272 | " = 8" | |
273 | ||
274 | gdb_test "print foo.five_ptr(4)" \ | |
275 | " = 13" | |
276 | ||
277 | gdb_test "print foo.five_ptr(5)" \ | |
278 | " = 21" | |
279 | ||
280 | gdb_test "print foo.five_ptr(6)" \ | |
281 | " = 34" | |
282 | ||
eb479039 JB |
283 | gdb_test "print foo.five_ptr'first" \ |
284 | " = 2" | |
285 | ||
286 | gdb_test "print foo.five_ptr'last" \ | |
287 | " = 6" | |
288 | ||
289 | gdb_test "print foo.five_ptr'length" \ | |
290 | " = 5" | |
291 | ||
96334934 JB |
292 | gdb_test "ptype foo.five_ptr" \ |
293 | " = access array \\(<>\\) of integer" | |
294 | ||
7828a5f5 JB |
295 | # foo.five_ptr_tdef.all |
296 | ||
297 | gdb_test "print foo.five_ptr_tdef.all" \ | |
298 | " = \\(2 => 5, 8, 13, 21, 34\\)" | |
deede10c JB |
299 | |
300 | gdb_test "print foo.five_ptr_tdef.all(2)" \ | |
301 | " = 5" | |
302 | ||
303 | gdb_test "print foo.five_ptr_tdef.all(3)" \ | |
304 | " = 8" | |
305 | ||
306 | gdb_test "print foo.five_ptr_tdef.all(4)" \ | |
307 | " = 13" | |
308 | ||
309 | gdb_test "print foo.five_ptr_tdef.all(5)" \ | |
310 | " = 21" | |
311 | ||
312 | gdb_test "print foo.five_ptr_tdef.all(6)" \ | |
313 | " = 34" | |
314 | ||
eb479039 JB |
315 | gdb_test "print foo.five_ptr_tdef.all'first" \ |
316 | " = 2" | |
317 | ||
318 | gdb_test "print foo.five_ptr_tdef.all'last" \ | |
319 | " = 6" | |
320 | ||
321 | gdb_test "print foo.five_ptr_tdef.all'length" \ | |
322 | " = 5" | |
323 | ||
96334934 JB |
324 | gdb_test "ptype foo.five_ptr_tdef.all" \ |
325 | " = array \\(<>\\) of integer" | |
326 | ||
deede10c JB |
327 | # foo.five_ptr_tdef |
328 | ||
329 | gdb_test "print foo.five_ptr_tdef(2)" \ | |
330 | " = 5" | |
331 | ||
332 | gdb_test "print foo.five_ptr_tdef(3)" \ | |
333 | " = 8" | |
334 | ||
335 | gdb_test "print foo.five_ptr_tdef(4)" \ | |
336 | " = 13" | |
337 | ||
338 | gdb_test "print foo.five_ptr_tdef(5)" \ | |
339 | " = 21" | |
340 | ||
341 | gdb_test "print foo.five_ptr_tdef(6)" \ | |
342 | " = 34" | |
eb479039 JB |
343 | |
344 | gdb_test "print foo.five_ptr_tdef'first" \ | |
345 | " = 2" | |
346 | ||
347 | gdb_test "print foo.five_ptr_tdef'last" \ | |
348 | " = 6" | |
349 | ||
350 | gdb_test "print foo.five_ptr_tdef'length" \ | |
351 | " = 5" | |
96334934 JB |
352 | |
353 | gdb_test "ptype foo.five_ptr_tdef" \ | |
354 | " = access array \\(<>\\) of integer" |