1 From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2 From: Fedora GDB patches <invalid@email.com>
3 Date: Fri, 27 Oct 2017 21:07:50 +0200
4 Subject: gdb-archer-vla-tests.patch
6 FileName: gdb-archer-vla-tests.patch
10 gdb/testsuite/gdb.ada/packed_array.exp | 6 +
11 gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S | 358 ++++++++++++++++
12 gdb/testsuite/gdb.arch/x86_64-vla-pointer.c | 45 ++
13 gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp | 65 +++
14 gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S | 455 +++++++++++++++++++++
15 gdb/testsuite/gdb.arch/x86_64-vla-typedef.c | 45 ++
16 gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp | 64 +++
17 gdb/testsuite/gdb.base/arrayidx.c | 7 +
18 gdb/testsuite/gdb.base/arrayidx.exp | 10 +-
19 .../gdb.base/internal-var-field-address.c | 20 +
20 .../gdb.base/internal-var-field-address.exp | 26 ++
21 gdb/testsuite/gdb.base/vla-frame.c | 31 ++
22 gdb/testsuite/gdb.base/vla-frame.exp | 38 ++
23 gdb/testsuite/gdb.base/vla-overflow.c | 30 ++
24 gdb/testsuite/gdb.base/vla-overflow.exp | 109 +++++
25 gdb/testsuite/gdb.base/vla.c | 55 +++
26 gdb/testsuite/gdb.base/vla.exp | 62 +++
27 gdb/testsuite/gdb.cp/gdb9593.cc | 180 ++++++++
28 gdb/testsuite/gdb.cp/gdb9593.exp | 182 +++++++++
29 gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S | 246 +++++++++++
30 gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp | 66 +++
31 gdb/testsuite/gdb.dwarf2/dw2-stripped.c | 42 ++
32 gdb/testsuite/gdb.dwarf2/dw2-stripped.exp | 79 ++++
33 .../gdb.dwarf2/dw2-struct-member-data-location.S | 83 ++++
34 .../gdb.dwarf2/dw2-struct-member-data-location.exp | 37 ++
35 gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S | 121 ++++++
36 gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp | 39 ++
37 gdb/testsuite/gdb.fortran/dwarf-stride.exp | 42 ++
38 gdb/testsuite/gdb.fortran/dwarf-stride.f90 | 40 ++
39 gdb/testsuite/gdb.fortran/dynamic.exp | 154 +++++++
40 gdb/testsuite/gdb.fortran/dynamic.f90 | 98 +++++
41 gdb/testsuite/gdb.fortran/string.exp | 59 +++
42 gdb/testsuite/gdb.fortran/string.f90 | 37 ++
43 gdb/testsuite/gdb.fortran/subrange.exp | 72 ++++
44 gdb/testsuite/gdb.fortran/subrange.f90 | 28 ++
45 gdb/testsuite/gdb.mi/mi2-var-stale-type.c | 26 ++
46 gdb/testsuite/gdb.mi/mi2-var-stale-type.exp | 57 +++
47 gdb/testsuite/gdb.opt/array-from-register-func.c | 22 +
48 gdb/testsuite/gdb.opt/array-from-register.c | 28 ++
49 gdb/testsuite/gdb.opt/array-from-register.exp | 33 ++
50 gdb/testsuite/gdb.opt/fortran-string.exp | 39 ++
51 gdb/testsuite/gdb.opt/fortran-string.f90 | 28 ++
52 gdb/testsuite/gdb.pascal/arrays.exp | 104 +++++
53 gdb/testsuite/gdb.pascal/arrays.pas | 82 ++++
54 gdb/testsuite/lib/gdb.exp | 5 +
55 gdb/testsuite/lib/pascal.exp | 17 +
56 46 files changed, 3471 insertions(+), 1 deletion(-)
57 create mode 100644 gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
58 create mode 100644 gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
59 create mode 100644 gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
60 create mode 100644 gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
61 create mode 100644 gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
62 create mode 100644 gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
63 create mode 100644 gdb/testsuite/gdb.base/internal-var-field-address.c
64 create mode 100644 gdb/testsuite/gdb.base/internal-var-field-address.exp
65 create mode 100644 gdb/testsuite/gdb.base/vla-frame.c
66 create mode 100644 gdb/testsuite/gdb.base/vla-frame.exp
67 create mode 100644 gdb/testsuite/gdb.base/vla-overflow.c
68 create mode 100644 gdb/testsuite/gdb.base/vla-overflow.exp
69 create mode 100644 gdb/testsuite/gdb.base/vla.c
70 create mode 100644 gdb/testsuite/gdb.base/vla.exp
71 create mode 100644 gdb/testsuite/gdb.cp/gdb9593.cc
72 create mode 100644 gdb/testsuite/gdb.cp/gdb9593.exp
73 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
74 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
75 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-stripped.c
76 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
77 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
78 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
79 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
80 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
81 create mode 100644 gdb/testsuite/gdb.fortran/dwarf-stride.exp
82 create mode 100644 gdb/testsuite/gdb.fortran/dwarf-stride.f90
83 create mode 100644 gdb/testsuite/gdb.fortran/dynamic.exp
84 create mode 100644 gdb/testsuite/gdb.fortran/dynamic.f90
85 create mode 100644 gdb/testsuite/gdb.fortran/string.exp
86 create mode 100644 gdb/testsuite/gdb.fortran/string.f90
87 create mode 100644 gdb/testsuite/gdb.fortran/subrange.exp
88 create mode 100644 gdb/testsuite/gdb.fortran/subrange.f90
89 create mode 100644 gdb/testsuite/gdb.mi/mi2-var-stale-type.c
90 create mode 100644 gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
91 create mode 100644 gdb/testsuite/gdb.opt/array-from-register-func.c
92 create mode 100644 gdb/testsuite/gdb.opt/array-from-register.c
93 create mode 100644 gdb/testsuite/gdb.opt/array-from-register.exp
94 create mode 100644 gdb/testsuite/gdb.opt/fortran-string.exp
95 create mode 100644 gdb/testsuite/gdb.opt/fortran-string.f90
96 create mode 100644 gdb/testsuite/gdb.pascal/arrays.exp
97 create mode 100644 gdb/testsuite/gdb.pascal/arrays.pas
99 diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp
100 index 3e614b788a..0ae87786db 100644
101 --- a/gdb/testsuite/gdb.ada/packed_array.exp
102 +++ b/gdb/testsuite/gdb.ada/packed_array.exp
103 @@ -56,5 +56,11 @@ gdb_test_multiple "$test" "$test" {
104 # are. Observed with (FSF GNU Ada 4.5.3 20110124).
107 + -re "= \\(\\)\[\r\n\]+$gdb_prompt $" {
108 + # archer-jankratochvil-vla resolves it as a dynamic type resolved as an
109 + # empty array [0..-1].
110 + # DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref)
115 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
117 index 0000000000..3a983e6b22
119 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
121 + .file "x86_64-vla-pointer.c"
125 + .type foo, @function
128 + .file 1 "gdb.arch/x86_64-vla-pointer.c"
129 + # gdb.arch/x86_64-vla-pointer.c:22
133 +# PRED: ENTRY (FALLTHRU)
135 + .cfi_def_cfa_offset 16
138 + .cfi_def_cfa_register 6
142 + movl %edi, -52(%rbp)
143 + # gdb.arch/x86_64-vla-pointer.c:22
147 + # gdb.arch/x86_64-vla-pointer.c:23
149 + movl -52(%rbp), %eax
152 + movq %rdx, -32(%rbp)
156 + # gdb.arch/x86_64-vla-pointer.c:24
168 + imulq $16, %rax, %rax
172 + movq %rax, -40(%rbp)
173 + # gdb.arch/x86_64-vla-pointer.c:27
181 + # gdb.arch/x86_64-vla-pointer.c:28
182 + .loc 1 28 0 discriminator 3
183 + movl -20(%rbp), %eax
185 + movq -40(%rbp), %rdx
186 + movl -20(%rbp), %eax
188 + movb %cl, (%rdx,%rax)
189 +# SUCC: 4 (FALLTHRU,DFS_BACK)
190 + # gdb.arch/x86_64-vla-pointer.c:27
191 + .loc 1 27 0 discriminator 3
194 +# PRED: 3 (FALLTHRU,DFS_BACK) 2 [100.0%]
196 + # gdb.arch/x86_64-vla-pointer.c:27
197 + .loc 1 27 0 is_stmt 0 discriminator 1
198 + movl -20(%rbp), %eax
199 + cmpl -52(%rbp), %eax
200 +# SUCC: 3 5 (FALLTHRU)
203 +# PRED: 4 (FALLTHRU)
204 + # gdb.arch/x86_64-vla-pointer.c:30
205 + .loc 1 30 0 is_stmt 1
206 + movq -40(%rbp), %rax
209 + # gdb.arch/x86_64-vla-pointer.c:31
212 + movq -8(%rbp), %rbx
215 +# SUCC: EXIT [100.0%]
221 + .section .debug_info,"",@progbits
223 + .long 0xa5 # Length of Compilation Unit Info
224 + .value 0x4 # DWARF version number
225 + .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
226 + .byte 0x8 # Pointer Size (in bytes)
227 + .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
228 + .long .LASF3 # DW_AT_producer: "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
229 + .byte 0xc # DW_AT_language
230 + .long .LASF4 # DW_AT_name: "gdb.arch/x86_64-vla-pointer.c"
231 + .long .LASF5 # DW_AT_comp_dir: "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
232 + .quad .Ltext0 # DW_AT_low_pc
233 + .quad .Letext0-.Ltext0 # DW_AT_high_pc
234 + .long .Ldebug_line0 # DW_AT_stmt_list
235 + .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
237 + .ascii "foo\0" # DW_AT_name
238 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
239 + .byte 0x15 # DW_AT_decl_line
241 + .quad .LFB0 # DW_AT_low_pc
242 + .quad .LFE0-.LFB0 # DW_AT_high_pc
243 + .uleb128 0x1 # DW_AT_frame_base
244 + .byte 0x9c # DW_OP_call_frame_cfa
245 + # DW_AT_GNU_all_call_sites
246 + .long 0x80 # DW_AT_sibling
247 + .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter)
248 + .long .LASF6 # DW_AT_name: "size"
249 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
250 + .byte 0x15 # DW_AT_decl_line
251 + .long 0x80 # DW_AT_type
252 + .uleb128 0x3 # DW_AT_location
253 + .byte 0x91 # DW_OP_fbreg
255 + .uleb128 0x4 # (DIE (0x59) DW_TAG_typedef)
256 + .long .LASF7 # DW_AT_name: "array_t"
257 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
258 + .byte 0x17 # DW_AT_decl_line
259 + .long 0x87 # DW_AT_type
260 + .uleb128 0x5 # (DIE (0x64) DW_TAG_variable)
261 + .long .LASF0 # DW_AT_name: "array"
262 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
263 + .byte 0x18 # DW_AT_decl_line
264 + .long 0x59 # DW_AT_type
265 + .uleb128 0x3 # DW_AT_location
266 + .byte 0x91 # DW_OP_fbreg
268 + .byte 0x6 # DW_OP_deref
269 + .uleb128 0x6 # (DIE (0x73) DW_TAG_variable)
270 + .ascii "i\0" # DW_AT_name
271 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
272 + .byte 0x19 # DW_AT_decl_line
273 + .long 0x80 # DW_AT_type
274 + .uleb128 0x2 # DW_AT_location
275 + .byte 0x91 # DW_OP_fbreg
277 + .byte 0 # end of children of DIE 0x2d
278 + .uleb128 0x7 # (DIE (0x80) DW_TAG_base_type)
279 + .byte 0x4 # DW_AT_byte_size
280 + .byte 0x5 # DW_AT_encoding
281 + .ascii "int\0" # DW_AT_name
282 + .uleb128 0x8 # (DIE (0x87) DW_TAG_array_type)
283 + .long 0xa1 # DW_AT_type
284 + .long 0x9a # DW_AT_sibling
285 + .uleb128 0x9 # (DIE (0x90) DW_TAG_subrange_type)
286 + .long 0x9a # DW_AT_type
287 + .uleb128 0x3 # DW_AT_upper_bound
288 + .byte 0x91 # DW_OP_fbreg
290 + .byte 0x6 # DW_OP_deref
291 + .byte 0 # end of children of DIE 0x87
292 + .uleb128 0xa # (DIE (0x9a) DW_TAG_base_type)
293 + .byte 0x8 # DW_AT_byte_size
294 + .byte 0x7 # DW_AT_encoding
295 + .long .LASF1 # DW_AT_name: "sizetype"
296 + .uleb128 0xa # (DIE (0xa1) DW_TAG_base_type)
297 + .byte 0x1 # DW_AT_byte_size
298 + .byte 0x6 # DW_AT_encoding
299 + .long .LASF2 # DW_AT_name: "char"
300 + .byte 0 # end of children of DIE 0xb
301 + .section .debug_abbrev,"",@progbits
303 + .uleb128 0x1 # (abbrev code)
304 + .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
305 + .byte 0x1 # DW_children_yes
306 + .uleb128 0x25 # (DW_AT_producer)
307 + .uleb128 0xe # (DW_FORM_strp)
308 + .uleb128 0x13 # (DW_AT_language)
309 + .uleb128 0xb # (DW_FORM_data1)
310 + .uleb128 0x3 # (DW_AT_name)
311 + .uleb128 0xe # (DW_FORM_strp)
312 + .uleb128 0x1b # (DW_AT_comp_dir)
313 + .uleb128 0xe # (DW_FORM_strp)
314 + .uleb128 0x11 # (DW_AT_low_pc)
315 + .uleb128 0x1 # (DW_FORM_addr)
316 + .uleb128 0x12 # (DW_AT_high_pc)
317 + .uleb128 0x7 # (DW_FORM_data8)
318 + .uleb128 0x10 # (DW_AT_stmt_list)
319 + .uleb128 0x17 # (DW_FORM_sec_offset)
322 + .uleb128 0x2 # (abbrev code)
323 + .uleb128 0x2e # (TAG: DW_TAG_subprogram)
324 + .byte 0x1 # DW_children_yes
325 + .uleb128 0x3f # (DW_AT_external)
326 + .uleb128 0x19 # (DW_FORM_flag_present)
327 + .uleb128 0x3 # (DW_AT_name)
328 + .uleb128 0x8 # (DW_FORM_string)
329 + .uleb128 0x3a # (DW_AT_decl_file)
330 + .uleb128 0xb # (DW_FORM_data1)
331 + .uleb128 0x3b # (DW_AT_decl_line)
332 + .uleb128 0xb # (DW_FORM_data1)
333 + .uleb128 0x27 # (DW_AT_prototyped)
334 + .uleb128 0x19 # (DW_FORM_flag_present)
335 + .uleb128 0x11 # (DW_AT_low_pc)
336 + .uleb128 0x1 # (DW_FORM_addr)
337 + .uleb128 0x12 # (DW_AT_high_pc)
338 + .uleb128 0x7 # (DW_FORM_data8)
339 + .uleb128 0x40 # (DW_AT_frame_base)
340 + .uleb128 0x18 # (DW_FORM_exprloc)
341 + .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
342 + .uleb128 0x19 # (DW_FORM_flag_present)
343 + .uleb128 0x1 # (DW_AT_sibling)
344 + .uleb128 0x13 # (DW_FORM_ref4)
347 + .uleb128 0x3 # (abbrev code)
348 + .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
349 + .byte 0 # DW_children_no
350 + .uleb128 0x3 # (DW_AT_name)
351 + .uleb128 0xe # (DW_FORM_strp)
352 + .uleb128 0x3a # (DW_AT_decl_file)
353 + .uleb128 0xb # (DW_FORM_data1)
354 + .uleb128 0x3b # (DW_AT_decl_line)
355 + .uleb128 0xb # (DW_FORM_data1)
356 + .uleb128 0x49 # (DW_AT_type)
357 + .uleb128 0x13 # (DW_FORM_ref4)
358 + .uleb128 0x2 # (DW_AT_location)
359 + .uleb128 0x18 # (DW_FORM_exprloc)
362 + .uleb128 0x4 # (abbrev code)
363 + .uleb128 0x16 # (TAG: DW_TAG_typedef)
364 + .byte 0 # DW_children_no
365 + .uleb128 0x3 # (DW_AT_name)
366 + .uleb128 0xe # (DW_FORM_strp)
367 + .uleb128 0x3a # (DW_AT_decl_file)
368 + .uleb128 0xb # (DW_FORM_data1)
369 + .uleb128 0x3b # (DW_AT_decl_line)
370 + .uleb128 0xb # (DW_FORM_data1)
371 + .uleb128 0x49 # (DW_AT_type)
372 + .uleb128 0x13 # (DW_FORM_ref4)
375 + .uleb128 0x5 # (abbrev code)
376 + .uleb128 0x34 # (TAG: DW_TAG_variable)
377 + .byte 0 # DW_children_no
378 + .uleb128 0x3 # (DW_AT_name)
379 + .uleb128 0xe # (DW_FORM_strp)
380 + .uleb128 0x3a # (DW_AT_decl_file)
381 + .uleb128 0xb # (DW_FORM_data1)
382 + .uleb128 0x3b # (DW_AT_decl_line)
383 + .uleb128 0xb # (DW_FORM_data1)
384 + .uleb128 0x49 # (DW_AT_type)
385 + .uleb128 0x13 # (DW_FORM_ref4)
386 + .uleb128 0x2 # (DW_AT_location)
387 + .uleb128 0x18 # (DW_FORM_exprloc)
390 + .uleb128 0x6 # (abbrev code)
391 + .uleb128 0x34 # (TAG: DW_TAG_variable)
392 + .byte 0 # DW_children_no
393 + .uleb128 0x3 # (DW_AT_name)
394 + .uleb128 0x8 # (DW_FORM_string)
395 + .uleb128 0x3a # (DW_AT_decl_file)
396 + .uleb128 0xb # (DW_FORM_data1)
397 + .uleb128 0x3b # (DW_AT_decl_line)
398 + .uleb128 0xb # (DW_FORM_data1)
399 + .uleb128 0x49 # (DW_AT_type)
400 + .uleb128 0x13 # (DW_FORM_ref4)
401 + .uleb128 0x2 # (DW_AT_location)
402 + .uleb128 0x18 # (DW_FORM_exprloc)
405 + .uleb128 0x7 # (abbrev code)
406 + .uleb128 0x24 # (TAG: DW_TAG_base_type)
407 + .byte 0 # DW_children_no
408 + .uleb128 0xb # (DW_AT_byte_size)
409 + .uleb128 0xb # (DW_FORM_data1)
410 + .uleb128 0x3e # (DW_AT_encoding)
411 + .uleb128 0xb # (DW_FORM_data1)
412 + .uleb128 0x3 # (DW_AT_name)
413 + .uleb128 0x8 # (DW_FORM_string)
416 + .uleb128 0x8 # (abbrev code)
417 + .uleb128 0x1 # (TAG: DW_TAG_array_type)
418 + .byte 0x1 # DW_children_yes
419 + .uleb128 0x49 # (DW_AT_type)
420 + .uleb128 0x13 # (DW_FORM_ref4)
421 + .uleb128 0x1 # (DW_AT_sibling)
422 + .uleb128 0x13 # (DW_FORM_ref4)
425 + .uleb128 0x9 # (abbrev code)
426 + .uleb128 0x21 # (TAG: DW_TAG_subrange_type)
427 + .byte 0 # DW_children_no
428 + .uleb128 0x49 # (DW_AT_type)
429 + .uleb128 0x13 # (DW_FORM_ref4)
430 + .uleb128 0x2f # (DW_AT_upper_bound)
431 + .uleb128 0x18 # (DW_FORM_exprloc)
434 + .uleb128 0xa # (abbrev code)
435 + .uleb128 0x24 # (TAG: DW_TAG_base_type)
436 + .byte 0 # DW_children_no
437 + .uleb128 0xb # (DW_AT_byte_size)
438 + .uleb128 0xb # (DW_FORM_data1)
439 + .uleb128 0x3e # (DW_AT_encoding)
440 + .uleb128 0xb # (DW_FORM_data1)
441 + .uleb128 0x3 # (DW_AT_name)
442 + .uleb128 0xe # (DW_FORM_strp)
446 + .section .debug_aranges,"",@progbits
447 + .long 0x2c # Length of Address Ranges Info
448 + .value 0x2 # DWARF Version
449 + .long .Ldebug_info0 # Offset of Compilation Unit Info
450 + .byte 0x8 # Size of Address
451 + .byte 0 # Size of Segment Descriptor
452 + .value 0 # Pad to 16 byte boundary
454 + .quad .Ltext0 # Address
455 + .quad .Letext0-.Ltext0 # Length
458 + .section .debug_line,"",@progbits
460 + .section .debug_str,"MS",@progbits,1
462 + .string "gdb.arch/x86_64-vla-pointer.c"
466 + .string "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
472 + .string "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
477 + .ident "GCC: (GNU) 6.2.1 20160916 (Red Hat 6.2.1-2)"
478 + .section .note.GNU-stack,"",@progbits
479 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
481 index 0000000000..98ee43bbf2
483 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
485 +/* This testcase is part of GDB, the GNU debugger.
487 + Copyright 2009 Free Software Foundation, Inc.
489 + This program is free software; you can redistribute it and/or modify
490 + it under the terms of the GNU General Public License as published by
491 + the Free Software Foundation; either version 3 of the License, or
492 + (at your option) any later version.
494 + This program is distributed in the hope that it will be useful,
495 + but WITHOUT ANY WARRANTY; without even the implied warranty of
496 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
497 + GNU General Public License for more details.
499 + You should have received a copy of the GNU General Public License
500 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
507 + typedef char array_t[size];
511 + for (i = 0; i < size; i++)
514 + array[0] = 0; /* break-here */
519 +void foo (int size);
530 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
532 index 0000000000..3e2e64a6ab
534 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
536 +# Copyright 2009 Free Software Foundation, Inc.
538 +# This program is free software; you can redistribute it and/or modify
539 +# it under the terms of the GNU General Public License as published by
540 +# the Free Software Foundation; either version 3 of the License, or
541 +# (at your option) any later version.
543 +# This program is distributed in the hope that it will be useful,
544 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
545 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
546 +# GNU General Public License for more details.
548 +# You should have received a copy of the GNU General Public License
549 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
551 +if ![istarget "x86_64-*-*"] then {
552 + verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64."
556 +set testfile x86_64-vla-pointer
557 +set srcasmfile ${testfile}-foo.S
558 +set srcfile ${testfile}.c
559 +set binfile [standard_output_file ${testfile}]
560 +set binobjfile [standard_output_file ${testfile}-foo.o]
561 +if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
562 + untested "Couldn't compile test program"
565 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {}] != "" } {
566 + untested "Couldn't compile test program"
572 +gdb_reinitialize_dir $srcdir/$subdir
576 + untested x86_64-vla-pointer
580 +gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
582 +gdb_continue_to_breakpoint "break-here"
584 +gdb_test "whatis array" "type = array_t" "first: whatis array"
585 +gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "first: whatis array_t"
586 +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
588 +gdb_test "whatis *array" "type = char" "first: whatis *array"
589 +gdb_test "ptype *array" "type = char" "first: ptype *array"
591 +gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
592 +gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
593 +gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
594 +gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
596 +gdb_continue_to_breakpoint "break_here"
598 +gdb_test "whatis array" "type = array_t" "second: whatis array"
599 +gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "second: whatis array_t"
600 +gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
601 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
603 index 0000000000..66f7a399bf
605 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
607 + .file "x86_64-vla-typedef.c"
608 + .section .debug_abbrev,"",@progbits
610 + .section .debug_info,"",@progbits
612 + .section .debug_line,"",@progbits
617 + .type foo, @function
620 + .file 1 "x86_64-vla-typedef.c"
628 + movl %edi, -36(%rbp)
631 + movq %rax, -48(%rbp)
633 + movl -36(%rbp), %edx
636 + movq %rax, -24(%rbp)
644 + movq %rsp, -56(%rbp)
645 + movq -56(%rbp), %rax
649 + movq %rax, -56(%rbp)
650 + movq -56(%rbp), %rax
651 + movq %rax, -16(%rbp)
657 + movl -4(%rbp), %esi
658 + movl -4(%rbp), %eax
660 + movq -16(%rbp), %rdx
662 + movb %cl, (%rdx,%rax)
666 + movl -4(%rbp), %eax
667 + cmpl -36(%rbp), %eax
672 + movq -16(%rbp), %rax
674 + movq -48(%rbp), %rsp
680 + .section .debug_frame,"",@progbits
682 + .long .LECIE0-.LSCIE0
698 + .long .LEFDE0-.LASFDE0
710 + .long .LCFI1-.LCFI0
715 + .section .eh_frame,"a",@progbits
717 + .long .LECIE1-.LSCIE1
735 + .long .LEFDE1-.LASFDE1
737 + .long .LASFDE1-.Lframe1
748 + .long .LCFI1-.LCFI0
755 + .section .debug_loc,"",@progbits
758 + .quad .LFB2-.Ltext0
759 + .quad .LCFI0-.Ltext0
763 + .quad .LCFI0-.Ltext0
764 + .quad .LCFI1-.Ltext0
768 + .quad .LCFI1-.Ltext0
769 + .quad .LFE2-.Ltext0
775 + .section .debug_info
776 + .long .Ldebug_end - .Ldebug_start
779 + .long .Ldebug_abbrev0
788 + .long .Ldebug_line0
812 + .long .Ltag_array_type - .debug_info
813 + .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */
818 + .long .Ltag_typedef - .debug_info
820 + /* Debugging only: Skip the typedef indirection. */
821 + .long .Ltag_array_type - .debug_info
823 + /* DW_AT_location: DW_FORM_block1: start */
828 + .byte 0x6 /* DW_OP_deref */
830 + .byte 0x96 /* DW_OP_nop */
832 + /* DW_AT_location: DW_FORM_block1: end */
847 + .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
848 + .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */
849 + .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */
850 +1: /* DW_AT_data_location: DW_FORM_block1: start */
851 + .byte 2f - 3f /* length */
853 + .byte 0x97 /* DW_OP_push_object_address */
854 + .byte 0x6 /* DW_OP_deref */
855 +2: /* DW_AT_data_location: DW_FORM_block1: end */
857 + .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */
872 + .section .debug_abbrev
984 + .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
987 + .uleb128 0x49 /* DW_AT_type */
988 + .uleb128 0x13 /* DW_FORM_ref4 */
989 + .uleb128 0x1 /* DW_AT_sibling */
990 + .uleb128 0x13 /* DW_FORM_ref4 */
991 + .uleb128 0x50 /* DW_AT_data_location */
992 + .uleb128 0xa /* DW_FORM_block1 */
998 + .uleb128 0x49 /* DW_AT_type */
999 + .uleb128 0x13 /* DW_FORM_ref4 */
1025 + .section .debug_pubnames,"",@progbits
1028 + .long .Ldebug_info0
1033 + .section .debug_aranges,"",@progbits
1036 + .long .Ldebug_info0
1042 + .quad .Letext0-.Ltext0
1045 + .section .debug_str,"MS",@progbits,1
1051 + .string "x86_64-vla-typedef.c"
1057 + .string "gdb.arch"
1059 + .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
1060 + .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
1061 + .section .note.GNU-stack,"",@progbits
1062 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
1063 new file mode 100644
1064 index 0000000000..40099e9d39
1066 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
1068 +/* This testcase is part of GDB, the GNU debugger.
1070 + Copyright 2008 Free Software Foundation, Inc.
1072 + This program is free software; you can redistribute it and/or modify
1073 + it under the terms of the GNU General Public License as published by
1074 + the Free Software Foundation; either version 3 of the License, or
1075 + (at your option) any later version.
1077 + This program is distributed in the hope that it will be useful,
1078 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1079 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1080 + GNU General Public License for more details.
1082 + You should have received a copy of the GNU General Public License
1083 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1090 + typedef char array_t[size];
1094 + for (i = 0; i < size; i++)
1097 + array[0] = 0; /* break-here */
1102 +void foo (int size);
1113 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
1114 new file mode 100644
1115 index 0000000000..4ef6214629
1117 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
1119 +# Copyright 2009 Free Software Foundation, Inc.
1121 +# This program is free software; you can redistribute it and/or modify
1122 +# it under the terms of the GNU General Public License as published by
1123 +# the Free Software Foundation; either version 3 of the License, or
1124 +# (at your option) any later version.
1126 +# This program is distributed in the hope that it will be useful,
1127 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1128 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1129 +# GNU General Public License for more details.
1131 +# You should have received a copy of the GNU General Public License
1132 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1134 +# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
1136 +if ![istarget "x86_64-*-*"] then {
1137 + verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
1141 +set testfile x86_64-vla-typedef
1142 +set srcasmfile ${testfile}-foo.S
1143 +set srcfile ${testfile}.c
1144 +set binfile [standard_output_file ${testfile}]
1145 +set binobjfile [standard_output_file ${testfile}-foo.o]
1146 +if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
1147 + untested "Couldn't compile test program"
1150 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
1151 + untested "Couldn't compile test program"
1157 +gdb_reinitialize_dir $srcdir/$subdir
1158 +gdb_load ${binfile}
1161 + untested x86_64-vla-typedef
1165 +gdb_breakpoint "break_here"
1167 +gdb_continue_to_breakpoint "break_here"
1169 +gdb_test "whatis array" "type = array_t" "first: whatis array"
1171 +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
1173 +gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
1174 +gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
1175 +gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
1176 +gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
1178 +gdb_continue_to_breakpoint "break_here"
1180 +gdb_test "whatis array" "type = array_t" "second: whatis array"
1182 +gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
1183 diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c
1184 index 5a0d01d04f..9e4b16e902 100644
1185 --- a/gdb/testsuite/gdb.base/arrayidx.c
1186 +++ b/gdb/testsuite/gdb.base/arrayidx.c
1189 int array[] = {1, 2, 3, 4};
1201 diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
1202 index 91eb3c6056..af29a51f23 100644
1203 --- a/gdb/testsuite/gdb.base/arrayidx.exp
1204 +++ b/gdb/testsuite/gdb.base/arrayidx.exp
1205 @@ -49,4 +49,12 @@ gdb_test "print array" \
1206 "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
1207 "print array with array-indexes on"
1210 +set test "p unbound.a == &unbound.a\[0\]"
1211 +gdb_test_multiple $test $test {
1212 + -re " = 1\r\n$gdb_prompt $" {
1215 + -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
1216 + unsupported "$test (no GCC)"
1219 diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c
1220 new file mode 100644
1221 index 0000000000..eeb7b8501c
1223 +++ b/gdb/testsuite/gdb.base/internal-var-field-address.c
1225 +/* This testcase is part of GDB, the GNU debugger.
1227 + Copyright 2009 Free Software Foundation, Inc.
1229 + This program is free software; you can redistribute it and/or modify
1230 + it under the terms of the GNU General Public License as published by
1231 + the Free Software Foundation; either version 3 of the License, or
1232 + (at your option) any later version.
1234 + This program is distributed in the hope that it will be useful,
1235 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1236 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1237 + GNU General Public License for more details.
1239 + You should have received a copy of the GNU General Public License
1240 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1244 +} staticstruct = { 1 };
1245 diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp
1246 new file mode 100644
1247 index 0000000000..33c9e94eee
1249 +++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp
1251 +# Copyright 2009 Free Software Foundation, Inc.
1253 +# This program is free software; you can redistribute it and/or modify
1254 +# it under the terms of the GNU General Public License as published by
1255 +# the Free Software Foundation; either version 3 of the License, or
1256 +# (at your option) any later version.
1258 +# This program is distributed in the hope that it will be useful,
1259 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1260 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1261 +# GNU General Public License for more details.
1263 +# You should have received a copy of the GNU General Public License
1264 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1266 +set test internal-var-field-address
1267 +set binfile ${test}.x
1268 +if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "[standard_output_file ${binfile}]" object {debug}] != "" } {
1269 + untested "Couldn't compile test program"
1273 +clean_restart $binfile
1275 +gdb_test {set $varstruct = staticstruct}
1276 +gdb_test {p $varstruct.field} " = 1"
1277 diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c
1278 new file mode 100644
1279 index 0000000000..5750f68b3d
1281 +++ b/gdb/testsuite/gdb.base/vla-frame.c
1283 +/* This testcase is part of GDB, the GNU debugger.
1285 + Copyright 2011 Free Software Foundation, Inc.
1287 + This program is free software; you can redistribute it and/or modify
1288 + it under the terms of the GNU General Public License as published by
1289 + the Free Software Foundation; either version 3 of the License, or
1290 + (at your option) any later version.
1292 + This program is distributed in the hope that it will be useful,
1293 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1294 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1295 + GNU General Public License for more details.
1297 + You should have received a copy of the GNU General Public License
1298 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1300 +#include <string.h>
1303 +main (int argc, char **argv)
1306 + void (*f) (char *) = 0;
1308 + memset (s, 0, sizeof (s));
1314 diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp
1315 new file mode 100644
1316 index 0000000000..47736c7625
1318 +++ b/gdb/testsuite/gdb.base/vla-frame.exp
1320 +# Copyright 2011 Free Software Foundation, Inc.
1322 +# This program is free software; you can redistribute it and/or modify
1323 +# it under the terms of the GNU General Public License as published by
1324 +# the Free Software Foundation; either version 3 of the License, or
1325 +# (at your option) any later version.
1327 +# This program is distributed in the hope that it will be useful,
1328 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1329 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1330 +# GNU General Public License for more details.
1332 +# You should have received a copy of the GNU General Public License
1333 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1335 +set testfile vla-frame
1336 +set executable ${testfile}
1338 +if { [prepare_for_testing ${testfile}.exp ${executable}] } {
1346 +set test "continue"
1347 +gdb_test_multiple $test $test {
1348 + -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" {
1351 + -re "\r\n$gdb_prompt $" {
1352 + untested ${testfile}.exp
1357 +gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*"
1358 diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c
1359 new file mode 100644
1360 index 0000000000..c5d5ee0bb9
1362 +++ b/gdb/testsuite/gdb.base/vla-overflow.c
1364 +/* This testcase is part of GDB, the GNU debugger.
1366 + Copyright 2008 Free Software Foundation, Inc.
1368 + This program is free software; you can redistribute it and/or modify
1369 + it under the terms of the GNU General Public License as published by
1370 + the Free Software Foundation; either version 3 of the License, or
1371 + (at your option) any later version.
1373 + This program is distributed in the hope that it will be useful,
1374 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1375 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1376 + GNU General Public License for more details.
1378 + You should have received a copy of the GNU General Public License
1379 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1381 +#include <stdlib.h>
1384 +main (int argc, char **argv)
1388 + array[0] = array[0];
1394 diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp
1395 new file mode 100644
1396 index 0000000000..43a5825979
1398 +++ b/gdb/testsuite/gdb.base/vla-overflow.exp
1400 +# Copyright 2008 Free Software Foundation, Inc.
1402 +# This program is free software; you can redistribute it and/or modify
1403 +# it under the terms of the GNU General Public License as published by
1404 +# the Free Software Foundation; either version 3 of the License, or
1405 +# (at your option) any later version.
1407 +# This program is distributed in the hope that it will be useful,
1408 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1409 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1410 +# GNU General Public License for more details.
1412 +# You should have received a copy of the GNU General Public License
1413 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1415 +# We could crash in:
1416 +# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69
1417 +# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97
1418 +# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL));
1419 +# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496
1420 +# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156
1421 +# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206
1422 +# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430
1423 +# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840
1425 +# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
1427 +# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
1429 +set testfile vla-overflow
1430 +set shfile [standard_output_file ${testfile}-gdb.sh]
1431 +set srcfile ${testfile}.c
1432 +set binfile [standard_output_file ${testfile}]
1433 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
1434 + untested "Couldn't compile test program"
1438 +set f [open "|getconf PAGESIZE" "r"]
1444 +gdb_reinitialize_dir $srcdir/$subdir
1445 +gdb_load ${binfile}
1447 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
1449 +if { [runto_main] < 0 } {
1450 + untested vla-overflow
1454 +# Get the GDB memory size when we stay at main.
1456 +proc memory_v_pages_get {} {
1457 + global pid_of_gdb pagesize
1458 + set fd [open "/proc/$pid_of_gdb/statm"]
1461 + # number of pages of virtual memory
1462 + scan $line "%d" drs
1466 +set pages_found [memory_v_pages_get]
1468 +# s390x with glibc-debuginfo.s390x installed used approx. 16MB.
1470 +verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve"
1471 +set kb_found [expr $pages_found * $pagesize / 1024]
1472 +set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024]
1473 +verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
1475 +# Create the ulimit wrapper.
1476 +set f [open $shfile "w"]
1477 +puts $f "#! /bin/sh"
1478 +puts $f "ulimit -v $kb_permit"
1479 +puts $f "exec $GDB \"\$@\""
1481 +remote_exec host "chmod +x $shfile"
1489 +gdb_reinitialize_dir $srcdir/$subdir
1490 +gdb_load ${binfile}
1492 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
1494 +# Check the size again after the second run.
1495 +# We must not stop in main as it would cache `array' and never crash later.
1499 +verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
1501 +gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
1503 +verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
1505 +# `abort' can get expressed as `*__GI_abort'.
1506 +gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
1508 +verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
1509 diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c
1510 new file mode 100644
1511 index 0000000000..e1f3ed1780
1513 +++ b/gdb/testsuite/gdb.base/vla.c
1515 +/* This testcase is part of GDB, the GNU debugger.
1517 + Copyright 2008 Free Software Foundation, Inc.
1519 + This program is free software; you can redistribute it and/or modify
1520 + it under the terms of the GNU General Public License as published by
1521 + the Free Software Foundation; either version 3 of the License, or
1522 + (at your option) any later version.
1524 + This program is distributed in the hope that it will be useful,
1525 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1526 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1527 + GNU General Public License for more details.
1529 + You should have received a copy of the GNU General Public License
1530 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1532 +#include <string.h>
1540 +bar (char *a, char *b, char *c, int size)
1542 + memset (a, '1', size);
1543 + memset (b, '2', size);
1544 + memset (c, '3', 48);
1553 + temp1[size - 1] = '\0';
1557 + bar (temp1, temp2, temp3, size);
1559 + marker (); /* break-here */
1570 diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp
1571 new file mode 100644
1572 index 0000000000..71fe637272
1574 +++ b/gdb/testsuite/gdb.base/vla.exp
1576 +# Copyright 2008 Free Software Foundation, Inc.
1578 +# This program is free software; you can redistribute it and/or modify
1579 +# it under the terms of the GNU General Public License as published by
1580 +# the Free Software Foundation; either version 3 of the License, or
1581 +# (at your option) any later version.
1583 +# This program is distributed in the hope that it will be useful,
1584 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1585 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1586 +# GNU General Public License for more details.
1588 +# You should have received a copy of the GNU General Public License
1589 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1592 +set srcfile ${testfile}.c
1593 +set binfile [standard_output_file ${testfile}]
1594 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
1595 + untested "Couldn't compile test program"
1601 +gdb_reinitialize_dir $srcdir/$subdir
1602 +gdb_load ${binfile}
1609 +gdb_breakpoint [gdb_get_line_number "break-here"]
1611 +gdb_continue_to_breakpoint "break-here"
1613 +gdb_test "whatis temp1" "type = char \\\[26\\\]" "first: whatis temp1"
1614 +gdb_test "whatis temp2" "type = char \\\[26\\\]" "first: whatis temp2"
1615 +gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
1617 +gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
1618 +gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
1619 +gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
1621 +gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
1622 +gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
1623 +gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
1625 +gdb_continue_to_breakpoint "break-here"
1627 +gdb_test "whatis temp1" "type = char \\\[78\\\]" "second: whatis temp1"
1628 +gdb_test "whatis temp2" "type = char \\\[78\\\]" "second: whatis temp2"
1629 +gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
1631 +gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
1632 +gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
1633 +gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
1635 +gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
1636 +gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
1637 +gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
1638 diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc
1639 new file mode 100644
1640 index 0000000000..783c9622a8
1642 +++ b/gdb/testsuite/gdb.cp/gdb9593.cc
1644 +/* This testcase is part of GDB, the GNU debugger.
1646 + Copyright 2008, 2009 Free Software Foundation, Inc.
1648 + This program is free software; you can redistribute it and/or modify
1649 + it under the terms of the GNU General Public License as published by
1650 + the Free Software Foundation; either version 3 of the License, or
1651 + (at your option) any later version.
1653 + This program is distributed in the hope that it will be useful,
1654 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1655 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1656 + GNU General Public License for more details.
1658 + You should have received a copy of the GNU General Public License
1659 + along with this program. If not, see <http://www.gnu.org/licenses/>.
1661 +#include <iostream>
1663 +using namespace std;
1665 +class NextOverThrowDerivates
1671 + // Single throw an exception in this function.
1677 + // Throw an exception in another function.
1683 + // Throw an exception in another function, but handle it
1694 + cout << "Caught and handled function1 exception" << endl;
1713 + // We use this to test that a "finish" here does not end up in
1714 + // this frame, but in the one above.
1722 + function1 (); // marker for until
1728 + function1 (); // until here
1732 +NextOverThrowDerivates next_cases;
1739 + next_cases.function1 ();
1748 + next_cases.function2 ();
1757 + // This is duplicated so we can next over one but step into
1759 + next_cases.function2 ();
1766 + next_cases.function3 ();
1770 + next_cases.rethrow ();
1779 + // Another duplicate so we can test "finish".
1780 + next_cases.function2 ();
1787 + // Another test for "finish".
1790 + next_cases.finish ();
1796 + // Test of "until".
1799 + next_cases.finish ();
1805 + // Test of "until" with an argument.
1808 + next_cases.until ();
1814 + // Test of "advance".
1817 + next_cases.until ();
1824 diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp
1825 new file mode 100644
1826 index 0000000000..ef40424402
1828 +++ b/gdb/testsuite/gdb.cp/gdb9593.exp
1830 +# Copyright 2008, 2009 Free Software Foundation, Inc.
1832 +# This program is free software; you can redistribute it and/or modify
1833 +# it under the terms of the GNU General Public License as published by
1834 +# the Free Software Foundation; either version 3 of the License, or
1835 +# (at your option) any later version.
1837 +# This program is distributed in the hope that it will be useful,
1838 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1839 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1840 +# GNU General Public License for more details.
1842 +# You should have received a copy of the GNU General Public License
1843 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1846 +if $tracelevel then {
1847 + strace $tracelevel
1850 +if { [skip_cplus_tests] } { continue }
1852 +set testfile "gdb9593"
1853 +set srcfile ${testfile}.cc
1854 +set binfile [standard_output_file $testfile]
1856 +# Create and source the file that provides information about the compiler
1857 +# used to compile the test case.
1858 +if [get_compiler_info "c++"] {
1859 + untested gdb9593.exp
1863 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
1864 + untested gdb9593.exp
1868 +# Some targets can't do function calls, so don't even bother with this
1870 +if [target_info exists gdb,cannot_call_functions] {
1871 + setup_xfail "*-*-*" 9593
1872 + fail "This target can not call functions"
1878 +gdb_reinitialize_dir $srcdir/$subdir
1879 +gdb_load ${binfile}
1881 +if ![runto_main] then {
1882 + perror "couldn't run to main"
1886 +# See whether we have the needed unwinder hooks.
1888 +gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
1889 + -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
1890 + pass "check for unwinder hook"
1892 + -re "No symbol .* in current context.\r\n$gdb_prompt $" {
1893 + # Pass the test so we don't get bogus fails in the results.
1894 + pass "check for unwinder hook"
1899 + untested gdb9593.exp
1903 +# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
1906 + ".*catch (...).*" \
1907 + "next over a throw 1"
1910 + ".*next_cases.function2.*" \
1911 + "next past catch 1"
1914 + ".*catch (...).*" \
1915 + "next over a throw 2"
1918 + ".*next_cases.function2.*" \
1919 + "next past catch 2"
1922 + ".*function1().*" \
1923 + "step into function2 1"
1926 + ".*catch (...).*" \
1927 + "next over a throw 3"
1930 + ".*next_cases.function3.*" \
1931 + "next past catch 3"
1934 + ".*next_cases.rethrow.*" \
1935 + "next over a throw 4"
1938 + ".*catch (...).*" \
1939 + "next over a rethrow"
1942 + ".*next_cases.function2.*" \
1943 + "next after a rethrow"
1946 + ".*function1().*" \
1947 + "step into function2 2"
1949 +gdb_test "finish" \
1950 + ".*catch (...).*" \
1954 + ".*next_cases.finish ().*" \
1955 + "next past catch 4"
1958 + ".*function1 ().*" \
1959 + "step into finish method"
1961 +gdb_test "finish" \
1962 + ".*catch (...).*" \
1966 + ".*next_cases.finish ().*" \
1967 + "next past catch 5"
1970 + ".*function1 ().*" \
1971 + "step into finish, for until"
1974 + ".*function1 ().*" \
1975 + "until with no argument 1"
1977 +set line [gdb_get_line_number "marker for until" $testfile.cc]
1979 +gdb_test "until $line" \
1980 + ".*function1 ().*" \
1981 + "next past catch 6"
1984 + ".*catch (...).*" \
1985 + "until with no argument 2"
1987 +set line [gdb_get_line_number "until here" $testfile.cc]
1990 + ".*next_cases.until ().*" \
1991 + "next past catch 6"
1994 + ".*function1 ().*" \
1997 +gdb_test "until $line" \
1998 + ".*catch (...).*" \
1999 + "until-over-throw"
2002 + ".*next_cases.until ().*" \
2003 + "next past catch 7"
2006 + ".*function1 ().*" \
2007 + "step into until, for advance"
2009 +gdb_test "advance $line" \
2010 + ".*catch (...).*" \
2011 + "advance-over-throw"
2012 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
2013 new file mode 100644
2014 index 0000000000..aac3baad8a
2016 +++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
2018 +/* This testcase is part of GDB, the GNU debugger.
2020 + Copyright 2010 Free Software Foundation, Inc.
2022 + This program is free software; you can redistribute it and/or modify
2023 + it under the terms of the GNU General Public License as published by
2024 + the Free Software Foundation; either version 3 of the License, or
2025 + (at your option) any later version.
2027 + This program is distributed in the hope that it will be useful,
2028 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2029 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2030 + GNU General Public License for more details.
2032 + You should have received a copy of the GNU General Public License
2033 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
2035 +/* Debug information */
2037 +/* We will `break *main' at the very first instruction. */
2038 +#define main_length 1
2042 + /* See DW_OP_lit3 + 1 (0-based). */
2043 + .string "seennotseen"
2045 + .section .debug_info
2047 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2049 + .2byte 2 /* DWARF version number */
2050 + .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
2051 + .byte 4 /* Pointer Size (in bytes) */
2054 + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2055 + .4byte .Lproducer /* DW_AT_producer */
2056 + /* Use C++ to exploit a bug in parsing DW_AT_name "". */
2057 + .byte 4 /* DW_AT_language (C++) - */
2058 + .4byte main /* DW_AT_low_pc */
2059 + .byte main_length /* DW_AT_high_pc */
2062 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
2063 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
2065 + .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
2066 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2067 + .byte 0 /* DW_AT_lower_bound */
2068 + .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */
2069 + .byte 0 /* End of children of die */
2071 + /* DW_AT_upper_bound is referencing an optimized-out variable. */
2073 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
2074 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
2076 + .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
2077 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2078 + .byte 0 /* DW_AT_lower_bound */
2079 + .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */
2080 + .byte 0 /* End of children of die */
2082 + /* DW_AT_upper_bound is referencing register. */
2084 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
2085 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
2087 + .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */
2088 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2089 + .byte 0 /* DW_AT_lower_bound */
2090 + .byte 2f - 1f /* DW_AT_upper_bound */
2091 +1: .byte 0x50 /* DW_OP_reg0 */
2093 + .byte 0 /* End of children of die */
2096 + .uleb128 4 /* Abbrev: DW_TAG_base_type */
2097 + .4byte .Luint_str /* DW_AT_name */
2098 + .byte 4 /* DW_AT_byte_size */
2099 + .byte 7 /* DW_AT_encoding */
2102 + .uleb128 4 /* Abbrev: DW_TAG_base_type */
2103 + .4byte .Lchar_str /* DW_AT_name */
2104 + .byte 1 /* DW_AT_byte_size */
2105 + .byte 6 /* DW_AT_encoding */
2108 + .uleb128 5 /* Abbrev: DW_TAG_variable artificial */
2109 + .byte 1 /* DW_AT_artificial */
2110 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2111 + .4byte .Llen_loclist-.Lloclist /* DW_AT_location */
2113 + /* optimized-out variable for b_string. */
2115 + .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */
2116 + .byte 1 /* DW_AT_artificial */
2117 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2119 + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2120 + .string "a_string" /* DW_AT_name */
2121 + .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
2122 + .byte 2f - 1f /* DW_AT_location */
2123 +1: .byte 3 /* DW_OP_addr */
2124 + .4byte vardata /* <addr> */
2127 + /* DW_AT_upper_bound is referencing an optimized-out variable. */
2128 + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2129 + .string "b_string" /* DW_AT_name */
2130 + .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */
2131 + .byte 2f - 1f /* DW_AT_location */
2132 +1: .byte 3 /* DW_OP_addr */
2133 + .4byte vardata /* <addr> */
2136 + /* DW_AT_upper_bound is referencing register. */
2137 + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2138 + .string "reg_string" /* DW_AT_name */
2139 + .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */
2140 + .byte 2f - 1f /* DW_AT_location */
2141 +1: .byte 3 /* DW_OP_addr */
2142 + .4byte vardata /* <addr> */
2145 + .byte 0 /* End of children of CU */
2148 + .section .debug_loc
2151 + .4byte 0 # Location list begin address
2152 + .4byte main_length # Location list end address
2153 + .value 2f-1f # Location expression size
2154 +1: .byte 0x33 # DW_OP_lit3
2155 + .byte 0x9f # DW_OP_stack_value
2157 + .quad 0x0 # Location list terminator begin (*.LLST2)
2158 + .quad 0x0 # Location list terminator end (*.LLST2)
2160 + .section .debug_abbrev
2162 + .uleb128 1 /* Abbrev code */
2163 + .uleb128 0x11 /* DW_TAG_compile_unit */
2164 + .byte 0x1 /* has_children */
2165 + .uleb128 0x25 /* DW_AT_producer */
2166 + .uleb128 0xe /* DW_FORM_strp */
2167 + .uleb128 0x13 /* DW_AT_language */
2168 + .uleb128 0xb /* DW_FORM_data1 */
2169 + .uleb128 0x11 /* DW_AT_low_pc */
2170 + .uleb128 0x1 /* DW_FORM_addr */
2171 + .uleb128 0x12 /* DW_AT_high_pc */
2172 + .uleb128 0xb /* DW_FORM_data1 */
2173 + .byte 0x0 /* Terminator */
2174 + .byte 0x0 /* Terminator */
2176 + .uleb128 2 /* Abbrev code */
2177 + .uleb128 0x1 /* TAG: DW_TAG_array_type */
2178 + .byte 0x1 /* DW_children_yes */
2179 + .uleb128 0x49 /* DW_AT_type */
2180 + .uleb128 0x13 /* DW_FORM_ref4 */
2181 + .byte 0x0 /* Terminator */
2182 + .byte 0x0 /* Terminator */
2184 + .uleb128 3 /* Abbrev code */
2185 + .uleb128 0x21 /* DW_TAG_subrange_type */
2186 + .byte 0x0 /* no children */
2187 + .uleb128 0x49 /* DW_AT_type */
2188 + .uleb128 0x13 /* DW_FORM_ref4 */
2189 + .uleb128 0x22 /* DW_AT_lower_bound */
2190 + .uleb128 0xb /* DW_FORM_data1 */
2191 + .uleb128 0x2f /* DW_AT_upper_bound */
2192 + .uleb128 0x13 /* DW_FORM_ref4 */
2193 + .byte 0x0 /* Terminator */
2194 + .byte 0x0 /* Terminator */
2196 + .uleb128 4 /* Abbrev code */
2197 + .uleb128 0x24 /* DW_TAG_base_type */
2198 + .byte 0x0 /* no_children */
2199 + .uleb128 0x3 /* DW_AT_name */
2200 + .uleb128 0xe /* DW_FORM_strp */
2201 + .uleb128 0xb /* DW_AT_byte_size */
2202 + .uleb128 0xb /* DW_FORM_data1 */
2203 + .uleb128 0x3e /* DW_AT_encoding */
2204 + .uleb128 0xb /* DW_FORM_data1 */
2205 + .byte 0x0 /* Terminator */
2206 + .byte 0x0 /* Terminator */
2208 + .uleb128 5 /* Abbrev code */
2209 + .uleb128 0x34 /* DW_TAG_variable */
2210 + .byte 0x0 /* no_children */
2211 + .uleb128 0x34 /* DW_AT_artificial */
2212 + .uleb128 0x0c /* DW_FORM_flag */
2213 + .uleb128 0x49 /* DW_AT_type */
2214 + .uleb128 0x13 /* DW_FORM_ref4 */
2215 + .uleb128 0x02 /* DW_AT_location */
2216 + .uleb128 0x06 /* DW_FORM_data4 */
2217 + .byte 0x0 /* Terminator */
2218 + .byte 0x0 /* Terminator */
2220 + .uleb128 6 /* Abbrev code */
2221 + .uleb128 0x34 /* DW_TAG_variable */
2222 + .byte 0x0 /* no_children */
2223 + .uleb128 0x3 /* DW_AT_name */
2224 + .uleb128 0x8 /* DW_FORM_string */
2225 + .uleb128 0x49 /* DW_AT_type */
2226 + .uleb128 0x13 /* DW_FORM_ref4 */
2227 + .uleb128 0x2 /* DW_AT_location */
2228 + .uleb128 0xa /* DW_FORM_block1 */
2229 + .byte 0x0 /* Terminator */
2230 + .byte 0x0 /* Terminator */
2232 + .uleb128 7 /* Abbrev code */
2233 + .uleb128 0x34 /* DW_TAG_variable */
2234 + .byte 0x0 /* no_children */
2235 + .uleb128 0x34 /* DW_AT_artificial */
2236 + .uleb128 0x0c /* DW_FORM_flag */
2237 + .uleb128 0x49 /* DW_AT_type */
2238 + .uleb128 0x13 /* DW_FORM_ref4 */
2239 + .byte 0x0 /* Terminator */
2240 + .byte 0x0 /* Terminator */
2242 + .uleb128 8 /* Abbrev code */
2243 + .uleb128 0x21 /* DW_TAG_subrange_type with block */
2244 + .byte 0x0 /* no children */
2245 + .uleb128 0x49 /* DW_AT_type */
2246 + .uleb128 0x13 /* DW_FORM_ref4 */
2247 + .uleb128 0x22 /* DW_AT_lower_bound */
2248 + .uleb128 0xb /* DW_FORM_data1 */
2249 + .uleb128 0x2f /* DW_AT_upper_bound */
2250 + .uleb128 0xa /* DW_FORM_block1 */
2251 + .byte 0x0 /* Terminator */
2252 + .byte 0x0 /* Terminator */
2254 + .byte 0x0 /* Terminator */
2257 + .section .debug_str
2259 + .string "GNU C 3.3.3"
2263 + .string "unsigned int"
2264 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
2265 new file mode 100644
2266 index 0000000000..39e69b470f
2268 +++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
2270 +# Copyright 2010 Free Software Foundation, Inc.
2272 +# This program is free software; you can redistribute it and/or modify
2273 +# it under the terms of the GNU General Public License as published by
2274 +# the Free Software Foundation; either version 3 of the License, or
2275 +# (at your option) any later version.
2277 +# This program is distributed in the hope that it will be useful,
2278 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2279 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2280 +# GNU General Public License for more details.
2282 +# You should have received a copy of the GNU General Public License
2283 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2285 +# Test printing variable with dynamic bounds which reference a different
2286 +# (artificial in the GCC case) variable containing loclist as its location.
2287 +# This testcase uses value (not address) of the referenced variable:
2288 +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
2290 +# This test can only be run on targets which support DWARF-2 and use gas.
2291 +# For now pick a sampling of likely targets.
2292 +if {![istarget *-*-linux*]
2293 + && ![istarget *-*-gnu*]
2294 + && ![istarget *-*-elf*]
2295 + && ![istarget *-*-openbsd*]
2296 + && ![istarget arm-*-eabi*]
2297 + && ![istarget powerpc-*-eabi*]} {
2301 +set testfile dw2-bound-loclist
2302 +if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
2306 +# Verify it behaves at least as an unbound array without inferior.
2308 +# FIXME: FSF GDB crashes due to !has_stack_frames ().
2309 +# But in practice that should not happen.
2310 +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
2311 +#set test "p a_string"
2312 +#gdb_test_multiple $test $test {
2313 +# -re " = 0x\[0-9a-f\]+ \"seennotseen\"\r\n$gdb_prompt $" {
2316 +# -re "No registers\\.\r\n$gdb_prompt $" {
2317 +# kfail "vlaregression" $test
2321 +#gdb_test "ptype a_string" {type = char \[variable length\]}
2323 +# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
2324 +if ![runto "*main"] {
2328 +gdb_test "p a_string" { = "seen"}
2329 +gdb_test "ptype a_string" {type = char \[4\]}
2331 +gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
2332 +gdb_test "ptype b_string" {type = char \[\]}
2334 +# The register contains unpredictable value - the array size.
2335 +gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]}
2336 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
2337 new file mode 100644
2338 index 0000000000..1f02d90eeb
2340 +++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
2342 +/* This testcase is part of GDB, the GNU debugger.
2344 + Copyright 2004 Free Software Foundation, Inc.
2346 + This program is free software; you can redistribute it and/or modify
2347 + it under the terms of the GNU General Public License as published by
2348 + the Free Software Foundation; either version 2 of the License, or
2349 + (at your option) any later version.
2351 + This program is distributed in the hope that it will be useful,
2352 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2353 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2354 + GNU General Public License for more details.
2356 + You should have received a copy of the GNU General Public License
2357 + along with this program; if not, write to the Free Software
2358 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2362 +/* The function `func1' traced into must have debug info on offset > 0;
2363 + (DW_UNSND (attr)). This is the reason of `func0' existence. */
2366 +func0(int a, int b)
2370 +/* `func1' being traced into must have some arguments to dump. */
2373 +func1(int a, int b)
2384 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
2385 new file mode 100644
2386 index 0000000000..9336e03157
2388 +++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
2390 +# Copyright 2006 Free Software Foundation, Inc.
2392 +# This program is free software; you can redistribute it and/or modify
2393 +# it under the terms of the GNU General Public License as published by
2394 +# the Free Software Foundation; either version 2 of the License, or
2395 +# (at your option) any later version.
2397 +# This program is distributed in the hope that it will be useful,
2398 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2399 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2400 +# GNU General Public License for more details.
2402 +# You should have received a copy of the GNU General Public License
2403 +# along with this program; if not, write to the Free Software
2404 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2406 +# Minimal DWARF-2 unit test
2408 +# This test can only be run on targets which support DWARF-2.
2409 +# For now pick a sampling of likely targets.
2410 +if {![istarget *-*-linux*]
2411 + && ![istarget *-*-gnu*]
2412 + && ![istarget *-*-elf*]
2413 + && ![istarget *-*-openbsd*]
2414 + && ![istarget arm-*-eabi*]
2415 + && ![istarget powerpc-*-eabi*]} {
2419 +set testfile "dw2-stripped"
2420 +set srcfile ${testfile}.c
2421 +set binfile [standard_output_file ${testfile}.x]
2423 +remote_exec build "rm -f ${binfile}"
2425 +# get the value of gcc_compiled
2426 +if [get_compiler_info ${binfile}] {
2430 +# This test can only be run on gcc as we use additional_flags=FIXME
2431 +if {$gcc_compiled == 0} {
2435 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
2439 +remote_exec build "objcopy -R .debug_loc ${binfile}"
2440 +set strip_output [remote_exec build "objdump -h ${binfile}"]
2442 +set test "stripping test file preservation"
2443 +if [ regexp ".debug_info " $strip_output] {
2444 + pass "$test (.debug_info preserved)"
2446 + fail "$test (.debug_info got also stripped)"
2449 +set test "stripping test file functionality"
2450 +if [ regexp ".debug_loc " $strip_output] {
2451 + fail "$test (.debug_loc still present)"
2453 + pass "$test (.debug_loc stripped)"
2458 +gdb_reinitialize_dir $srcdir/$subdir
2459 +gdb_load ${binfile}
2461 +# For C programs, "start" should stop in main().
2464 + ".*main \\(\\) at .*" \
2467 + "func.* \\(.*\\) at .*" \
2469 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
2470 new file mode 100644
2471 index 0000000000..5fcdd84986
2473 +++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
2475 +/* This testcase is part of GDB, the GNU debugger.
2477 + Copyright 2009 Free Software Foundation, Inc.
2479 + This program is free software; you can redistribute it and/or modify
2480 + it under the terms of the GNU General Public License as published by
2481 + the Free Software Foundation; either version 3 of the License, or
2482 + (at your option) any later version.
2484 + This program is distributed in the hope that it will be useful,
2485 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2486 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2487 + GNU General Public License for more details.
2489 + You should have received a copy of the GNU General Public License
2490 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
2492 +/* Debug information */
2494 + .section .debug_info
2497 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2499 + .2byte 2 /* DWARF Version */
2500 + .4byte .Labbrev1_begin /* Offset into abbrev section */
2501 + .byte 4 /* Pointer size */
2504 + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2505 + .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */
2506 + .ascii "GNU C 4.3.2\0" /* DW_AT_producer */
2507 + .byte 1 /* DW_AT_language (C) */
2510 + .uleb128 2 /* Abbrev: DW_TAG_structure_type */
2511 + .ascii "some_struct\0" /* DW_AT_name */
2513 + .uleb128 3 /* Abbrev: DW_TAG_member */
2514 + .ascii "field\0" /* DW_AT_name */
2515 + .byte 0 /* DW_AT_data_member_location */
2517 + .byte 0 /* End of children of some_struct */
2519 + .byte 0 /* End of children of CU */
2524 + .section .debug_abbrev
2526 + .uleb128 1 /* Abbrev code */
2527 + .uleb128 0x11 /* DW_TAG_compile_unit */
2528 + .byte 1 /* has_children */
2529 + .uleb128 0x3 /* DW_AT_name */
2530 + .uleb128 0x8 /* DW_FORM_string */
2531 + .uleb128 0x25 /* DW_AT_producer */
2532 + .uleb128 0x8 /* DW_FORM_string */
2533 + .uleb128 0x13 /* DW_AT_language */
2534 + .uleb128 0xb /* DW_FORM_data1 */
2535 + .byte 0x0 /* Terminator */
2536 + .byte 0x0 /* Terminator */
2538 + .uleb128 2 /* Abbrev code */
2539 + .uleb128 0x13 /* DW_TAG_structure_type */
2540 + .byte 1 /* has_children */
2541 + .uleb128 0x3 /* DW_AT_name */
2542 + .uleb128 0x8 /* DW_FORM_string */
2543 + .byte 0x0 /* Terminator */
2544 + .byte 0x0 /* Terminator */
2546 + .uleb128 3 /* Abbrev code */
2547 + .uleb128 0x0d /* DW_TAG_member */
2548 + .byte 0 /* has_children */
2549 + .uleb128 0x3 /* DW_AT_name */
2550 + .uleb128 0x8 /* DW_FORM_string */
2551 + .uleb128 0x38 /* DW_AT_data_member_location */
2552 + .uleb128 0x0b /* DW_FORM_data1 */
2553 + .byte 0x0 /* Terminator */
2554 + .byte 0x0 /* Terminator */
2556 + .byte 0x0 /* Terminator */
2557 + .byte 0x0 /* Terminator */
2558 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
2559 new file mode 100644
2560 index 0000000000..bc35209fe5
2562 +++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
2564 +# Copyright 2009 Free Software Foundation, Inc.
2566 +# This program is free software; you can redistribute it and/or modify
2567 +# it under the terms of the GNU General Public License as published by
2568 +# the Free Software Foundation; either version 3 of the License, or
2569 +# (at your option) any later version.
2571 +# This program is distributed in the hope that it will be useful,
2572 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2573 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2574 +# GNU General Public License for more details.
2576 +# You should have received a copy of the GNU General Public License
2577 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2579 +# This test can only be run on targets which support DWARF-2 and use gas.
2580 +# For now pick a sampling of likely targets.
2581 +if {![istarget *-*-linux*]
2582 + && ![istarget *-*-gnu*]
2583 + && ![istarget *-*-elf*]
2584 + && ![istarget *-*-openbsd*]
2585 + && ![istarget arm-*-eabi*]
2586 + && ![istarget powerpc-*-eabi*]} {
2590 +set testfile "dw2-struct-member-data-location"
2591 +set srcfile ${testfile}.S
2592 +set binfile ${testfile}.x
2594 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "[standard_output_file ${binfile}]" object {nodebug}] != "" } {
2598 +clean_restart $binfile
2600 +gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
2601 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
2602 new file mode 100644
2603 index 0000000000..9dbbf3c3e1
2605 +++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
2607 +/* This testcase is part of GDB, the GNU debugger.
2609 + Copyright 2012 Free Software Foundation, Inc.
2611 + This program is free software; you can redistribute it and/or modify
2612 + it under the terms of the GNU General Public License as published by
2613 + the Free Software Foundation; either version 3 of the License, or
2614 + (at your option) any later version.
2616 + This program is distributed in the hope that it will be useful,
2617 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2618 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2619 + GNU General Public License for more details.
2621 + You should have received a copy of the GNU General Public License
2622 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
2624 +/* Debug information */
2633 + .section .debug_info
2635 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2637 + .2byte 2 /* DWARF version number */
2638 + .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
2639 + .byte 4 /* Pointer Size (in bytes) */
2642 + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2643 + .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
2644 + .byte 2 /* DW_AT_language (C) - */
2647 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
2648 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
2650 + .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */
2651 + .byte 0 /* DW_AT_lower_bound */
2652 + .byte 128 /* DW_AT_upper_bound */
2654 + .byte 0 /* End of children of die */
2657 + .uleb128 4 /* Abbrev: DW_TAG_base_type */
2658 + .ascii "char\0" /* DW_AT_name */
2659 + .byte 1 /* DW_AT_byte_size */
2660 + .byte 6 /* DW_AT_encoding */
2662 + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2663 + .ascii "notype_string\0" /* DW_AT_name */
2664 + .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
2665 + .byte 2f - 1f /* DW_AT_location */
2666 +1: .byte 3 /* DW_OP_addr */
2667 + .4byte vardata /* <addr> */
2670 + .byte 0 /* End of children of CU */
2673 + .section .debug_abbrev
2675 + .uleb128 1 /* Abbrev code */
2676 + .uleb128 0x11 /* DW_TAG_compile_unit */
2677 + .byte 0x1 /* has_children */
2678 + .uleb128 0x25 /* DW_AT_producer */
2679 + .uleb128 0x8 /* DW_FORM_string */
2680 + .uleb128 0x13 /* DW_AT_language */
2681 + .uleb128 0xb /* DW_FORM_data1 */
2682 + .byte 0x0 /* Terminator */
2683 + .byte 0x0 /* Terminator */
2685 + .uleb128 2 /* Abbrev code */
2686 + .uleb128 0x1 /* TAG: DW_TAG_array_type */
2687 + .byte 0x1 /* DW_children_yes */
2688 + .uleb128 0x49 /* DW_AT_type */
2689 + .uleb128 0x13 /* DW_FORM_ref4 */
2690 + .byte 0x0 /* Terminator */
2691 + .byte 0x0 /* Terminator */
2693 + .uleb128 4 /* Abbrev code */
2694 + .uleb128 0x24 /* DW_TAG_base_type */
2695 + .byte 0x0 /* no_children */
2696 + .uleb128 0x3 /* DW_AT_name */
2697 + .uleb128 0x8 /* DW_FORM_string */
2698 + .uleb128 0xb /* DW_AT_byte_size */
2699 + .uleb128 0xb /* DW_FORM_data1 */
2700 + .uleb128 0x3e /* DW_AT_encoding */
2701 + .uleb128 0xb /* DW_FORM_data1 */
2702 + .byte 0x0 /* Terminator */
2703 + .byte 0x0 /* Terminator */
2705 + .uleb128 6 /* Abbrev code */
2706 + .uleb128 0x34 /* DW_TAG_variable */
2707 + .byte 0x0 /* no_children */
2708 + .uleb128 0x3 /* DW_AT_name */
2709 + .uleb128 0x8 /* DW_FORM_string */
2710 + .uleb128 0x49 /* DW_AT_type */
2711 + .uleb128 0x13 /* DW_FORM_ref4 */
2712 + .uleb128 0x2 /* DW_AT_location */
2713 + .uleb128 0xa /* DW_FORM_block1 */
2714 + .byte 0x0 /* Terminator */
2715 + .byte 0x0 /* Terminator */
2717 + .uleb128 8 /* Abbrev code */
2718 + .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */
2719 + .byte 0x0 /* no children */
2720 + .uleb128 0x22 /* DW_AT_lower_bound */
2721 + .uleb128 0xb /* DW_FORM_data1 */
2722 + .uleb128 0x2f /* DW_AT_upper_bound */
2723 + .uleb128 0xb /* DW_FORM_data1 */
2724 + .byte 0x0 /* Terminator */
2725 + .byte 0x0 /* Terminator */
2727 + .byte 0x0 /* Terminator */
2728 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
2729 new file mode 100644
2730 index 0000000000..cec673cd39
2732 +++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
2734 +# Copyright 2012 Free Software Foundation, Inc.
2736 +# This program is free software; you can redistribute it and/or modify
2737 +# it under the terms of the GNU General Public License as published by
2738 +# the Free Software Foundation; either version 3 of the License, or
2739 +# (at your option) any later version.
2741 +# This program is distributed in the hope that it will be useful,
2742 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2743 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2744 +# GNU General Public License for more details.
2746 +# You should have received a copy of the GNU General Public License
2747 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2750 +# https://bugzilla.redhat.com/show_bug.cgi?id=806920
2751 +# read_subrange_type <TYPE_CODE (base_type) == TYPE_CODE_VOID> reinitialization
2752 +# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without
2753 +# specified DW_AT_type, present only in XLF produced code.
2755 +# This test can only be run on targets which support DWARF-2 and use gas.
2756 +if {![dwarf2_support]} {
2760 +set testfile dw2-subrange-no-type
2761 +set srcfile ${testfile}.S
2762 +set executable ${testfile}.x
2763 +set binfile [standard_output_file ${executable}]
2765 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
2769 +clean_restart $executable
2771 +gdb_test "ptype notype_string" {type = char \[129\]}
2772 +gdb_test "p notype_string" " = 'x' <repeats 129 times>"
2773 diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
2774 new file mode 100644
2775 index 0000000000..d7b8bea8db
2777 +++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
2779 +# Copyright 2009 Free Software Foundation, Inc.
2781 +# This program is free software; you can redistribute it and/or modify
2782 +# it under the terms of the GNU General Public License as published by
2783 +# the Free Software Foundation; either version 2 of the License, or
2784 +# (at your option) any later version.
2786 +# This program is distributed in the hope that it will be useful,
2787 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2788 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2789 +# GNU General Public License for more details.
2791 +# You should have received a copy of the GNU General Public License
2792 +# along with this program; if not, write to the Free Software
2793 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2795 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2797 +# This file is part of the gdb testsuite. Array element stride must not be
2798 +# specified in the number of elements but in a number of bytes instead.
2799 +# Original problem:
2801 +# $1 = '0-hello', ' ' <repeats 33 times>
2803 +# warning: Fortran array stride not divisible by the element size
2805 +set testfile dwarf-stride
2806 +set srcfile ${testfile}.f90
2808 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
2812 +if ![runto MAIN__] then {
2813 + perror "couldn't run to breakpoint MAIN__"
2817 +gdb_breakpoint [gdb_get_line_number "break-here"]
2818 +gdb_continue_to_breakpoint "break-here" ".*break-here.*"
2819 +gdb_test "p c40pt(1)" " = '0-hello.*"
2820 +gdb_test "p c40pt(2)" " = '1-hello.*"
2821 diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
2822 new file mode 100644
2823 index 0000000000..e492b3af42
2825 +++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
2827 +! Copyright 2009 Free Software Foundation, Inc.
2829 +! This program is free software; you can redistribute it and/or modify
2830 +! it under the terms of the GNU General Public License as published by
2831 +! the Free Software Foundation; either version 2 of the License, or
2832 +! (at your option) any later version.
2834 +! This program is distributed in the hope that it will be useful,
2835 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
2836 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2837 +! GNU General Public License for more details.
2839 +! You should have received a copy of the GNU General Public License
2840 +! along with this program; if not, write to the Free Software
2841 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2843 +! File written by Alan Matsuoka.
2848 + character*40 long_string
2850 + end type small_stride
2852 + type(small_stride), dimension (20), target :: unpleasant
2853 + character*40, pointer, dimension(:):: c40pt
2858 + unpleasant(i+1)%small_pad = i+1
2859 + unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
2862 + c40pt => unpleasant%long_string
2864 + print *, c40pt ! break-here
2867 diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
2868 new file mode 100644
2869 index 0000000000..37d435f799
2871 +++ b/gdb/testsuite/gdb.fortran/dynamic.exp
2873 +# Copyright 2007 Free Software Foundation, Inc.
2875 +# This program is free software; you can redistribute it and/or modify
2876 +# it under the terms of the GNU General Public License as published by
2877 +# the Free Software Foundation; either version 2 of the License, or
2878 +# (at your option) any later version.
2880 +# This program is distributed in the hope that it will be useful,
2881 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2882 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2883 +# GNU General Public License for more details.
2885 +# You should have received a copy of the GNU General Public License
2886 +# along with this program; if not, write to the Free Software
2887 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2889 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2891 +# This file is part of the gdb testsuite. It contains tests for dynamically
2892 +# allocated Fortran arrays.
2893 +# It depends on the GCC dynamic Fortran arrays DWARF support:
2894 +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
2896 +set testfile "dynamic"
2897 +set srcfile ${testfile}.f90
2898 +set binfile [standard_output_file ${testfile}]
2900 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
2901 + untested "Couldn't compile ${srcfile}"
2907 +gdb_reinitialize_dir $srcdir/$subdir
2908 +gdb_load ${binfile}
2910 +if ![runto MAIN__] then {
2911 + perror "couldn't run to breakpoint MAIN__"
2915 +gdb_breakpoint [gdb_get_line_number "varx-init"]
2916 +gdb_continue_to_breakpoint "varx-init"
2918 +# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
2919 +# Do not: gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx unallocated"
2920 +# Do not: gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx unallocated"
2921 +# Do not: gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) unallocated"
2922 +# Do not: gdb_test "p varx(1,5,17)=1" {no such vector element \(vector not allocated\)} "p varx(1,5,17)=1 unallocated"
2923 +# Do not: gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) unallocated"
2925 +gdb_breakpoint [gdb_get_line_number "varx-allocated"]
2926 +gdb_continue_to_breakpoint "varx-allocated"
2927 +# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
2928 +gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated"
2929 +# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
2930 +gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
2932 +gdb_breakpoint [gdb_get_line_number "varx-filled"]
2933 +gdb_continue_to_breakpoint "varx-filled"
2934 +gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
2935 +gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
2936 +gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
2937 +gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
2938 +# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
2939 +# Do not: gdb_test "p varv" "\\$\[0-9\]* = <not associated>" "p varv unassociated"
2940 +# Do not: gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv unassociated"
2942 +set test "output varx"
2943 +gdb_test_multiple $test $test {
2944 + -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" {
2949 +gdb_breakpoint [gdb_get_line_number "varv-associated"]
2950 +gdb_continue_to_breakpoint "varv-associated"
2951 +gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
2952 +gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
2953 +# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
2954 +gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
2955 +gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated"
2956 +# Intel Fortran Compiler 10.1.008 uses the pointer type.
2957 +gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
2959 +gdb_breakpoint [gdb_get_line_number "varv-filled"]
2960 +gdb_continue_to_breakpoint "varv-filled"
2961 +gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
2962 +gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
2964 +gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
2965 +gdb_continue_to_breakpoint "varv-deassociated"
2966 +# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
2967 +gdb_test "p varv" "\\$\[0-9\]* = (<not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated"
2968 +gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv deassociated"
2969 +gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
2970 +gdb_test "p varv(1,5,17)" {no such vector element \(vector not associated\)}
2971 +gdb_test "ptype varv(1,5,17)" {no such vector element \(vector not associated\)}
2973 +gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
2974 +gdb_continue_to_breakpoint "varx-deallocated"
2975 +gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx deallocated"
2976 +gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx deallocated"
2977 +gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
2978 +gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) deallocated"
2979 +gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) deallocated"
2981 +gdb_breakpoint [gdb_get_line_number "vary-passed"]
2982 +gdb_continue_to_breakpoint "vary-passed"
2983 +# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
2984 +gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
2986 +gdb_breakpoint [gdb_get_line_number "vary-filled"]
2987 +gdb_continue_to_breakpoint "vary-filled"
2988 +gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
2989 +gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
2990 +gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
2991 +gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
2992 +# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
2993 +gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
2995 +gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
2996 +gdb_continue_to_breakpoint "varw-almostfilled"
2997 +gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
2998 +gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
2999 +# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
3000 +gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
3001 +# "up" works with GCC but other Fortran compilers may copy the values into the
3002 +# outer function only on the exit of the inner function.
3003 +# We need both variants as depending on the arch we optionally may still be
3004 +# executing the caller line or not after `finish'.
3005 +gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))"
3006 +gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
3007 +gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
3008 +gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
3009 +gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
3011 +gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
3012 +gdb_continue_to_breakpoint "varz-almostfilled"
3013 +# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
3014 +gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
3015 +# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
3016 +# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
3017 +gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
3018 +gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
3019 +gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
3020 +gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
3021 +# maps to foo::vary(1,1)
3022 +gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
3023 +# maps to foo::vary(2,2)
3024 +gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
3025 +# maps to foo::vary(1,3)
3026 +gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
3027 diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
3028 new file mode 100644
3029 index 0000000000..0f43564378
3031 +++ b/gdb/testsuite/gdb.fortran/dynamic.f90
3033 +! Copyright 2007 Free Software Foundation, Inc.
3035 +! This program is free software; you can redistribute it and/or modify
3036 +! it under the terms of the GNU General Public License as published by
3037 +! the Free Software Foundation; either version 2 of the License, or
3038 +! (at your option) any later version.
3040 +! This program is distributed in the hope that it will be useful,
3041 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
3042 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3043 +! GNU General Public License for more details.
3045 +! You should have received a copy of the GNU General Public License
3046 +! along with this program; if not, write to the Free Software
3047 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3049 +! Ihis file is the Fortran source file for dynamic.exp.
3050 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
3051 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3054 + real, target, allocatable :: varx (:, :, :)
3055 + real, pointer :: varv (:, :, :)
3056 + real, target :: varu (1, 2, 3)
3058 + allocate (varx (1:6, 5:15, 17:28)) ! varx-init
3059 + l = allocated (varx)
3060 + varx(:, :, :) = 6 ! varx-allocated
3061 + varx(1, 5, 17) = 7
3062 + varx(2, 6, 18) = 8
3063 + varx(6, 15, 28) = 9
3064 + varv => varx ! varx-filled
3065 + l = associated (varv)
3066 + varv(3, 7, 19) = 10 ! varv-associated
3067 + varv => null () ! varv-filled
3068 + l = associated (varv)
3069 + deallocate (varx) ! varv-deassociated
3070 + l = allocated (varx)
3071 + varu(:, :, :) = 10 ! varx-deallocated
3072 + allocate (varv (1:6, 5:15, 17:28))
3073 + l = associated (varv)
3075 + varv(1, 5, 17) = 7
3076 + varv(2, 6, 18) = 8
3077 + varv(6, 15, 28) = 9
3079 + l = associated (varv)
3083 + l = associated (varv)
3085 +subroutine foo (vary, varw)
3086 + real :: vary (:, :)
3087 + real :: varw (:, :, :)
3088 + vary(:, :) = 4 ! vary-passed
3092 + varw(:, :, :) = 5 ! vary-filled
3094 + varw(2, 2, 2) = 7 ! varw-almostfilled
3096 +subroutine bar (varz, vart)
3098 + real :: vart (2:11, 7:*)
3100 + varz(2) = 5 ! varz-almostfilled
3101 + vart(2,7) = vart(2,7)
3105 + subroutine foo (vary, varw)
3106 + real :: vary (:, :)
3107 + real :: varw (:, :, :)
3111 + subroutine bar (varz, vart)
3113 + real :: vart (2:11, 7:*)
3116 + real :: x (10, 10), y (5), z(8, 8, 8)
3121 + call foo (x, z(2:6, 4:7, 6:8))
3123 + if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
3124 + if (x (1, 3) .ne. 10) call abort
3125 + if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
3126 + if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
3127 + call foo (transpose (x), z)
3128 + if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
3129 + if (x (3, 1) .ne. 10) call abort
3131 diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
3132 new file mode 100644
3133 index 0000000000..1b7c0dbf73
3135 +++ b/gdb/testsuite/gdb.fortran/string.exp
3137 +# Copyright 2008 Free Software Foundation, Inc.
3139 +# This program is free software; you can redistribute it and/or modify
3140 +# it under the terms of the GNU General Public License as published by
3141 +# the Free Software Foundation; either version 2 of the License, or
3142 +# (at your option) any later version.
3144 +# This program is distributed in the hope that it will be useful,
3145 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3146 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3147 +# GNU General Public License for more details.
3149 +# You should have received a copy of the GNU General Public License
3150 +# along with this program; if not, write to the Free Software
3151 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3153 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
3155 +# This file is part of the gdb testsuite. It contains tests for Fortran
3156 +# strings with dynamic length.
3158 +set testfile "string"
3159 +set srcfile ${testfile}.f90
3160 +set binfile [standard_output_file ${testfile}]
3162 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
3163 + untested "Couldn't compile ${srcfile}"
3169 +gdb_reinitialize_dir $srcdir/$subdir
3170 +gdb_load ${binfile}
3172 +if ![runto MAIN__] then {
3173 + perror "couldn't run to breakpoint MAIN__"
3177 +gdb_breakpoint [gdb_get_line_number "var-init"]
3178 +gdb_continue_to_breakpoint "var-init"
3179 +gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
3180 +gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
3181 +gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
3182 +gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
3183 +gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
3184 +gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
3185 +gdb_test "p c" "\\$\[0-9\]* = 'c'"
3186 +gdb_test "p d" "\\$\[0-9\]* = 'd '"
3187 +gdb_test "p e" "\\$\[0-9\]* = 'g '"
3188 +gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)"
3189 +gdb_test "p *e" "Attempt to take contents of a non-pointer value."
3190 +gdb_test "p *f" "Attempt to take contents of a non-pointer value."
3192 +gdb_breakpoint [gdb_get_line_number "var-finish"]
3193 +gdb_continue_to_breakpoint "var-finish"
3194 +gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set"
3195 +gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set"
3196 diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
3197 new file mode 100644
3198 index 0000000000..226dc5d0ff
3200 +++ b/gdb/testsuite/gdb.fortran/string.f90
3202 +! Copyright 2008 Free Software Foundation, Inc.
3204 +! This program is free software; you can redistribute it and/or modify
3205 +! it under the terms of the GNU General Public License as published by
3206 +! the Free Software Foundation; either version 2 of the License, or
3207 +! (at your option) any later version.
3209 +! This program is distributed in the hope that it will be useful,
3210 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
3211 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3212 +! GNU General Public License for more details.
3214 +! You should have received a copy of the GNU General Public License
3215 +! along with this program; if not, write to the Free Software
3216 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3218 +! Ihis file is the Fortran source file for dynamic.exp.
3219 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
3220 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3222 +subroutine foo (e, f)
3223 + character (len=1) :: c
3224 + character (len=8) :: d
3225 + character (len=*) :: e
3226 + character (len=*) :: f (1:7, 8:10)
3229 + e = 'e' ! var-init
3232 + c = 'c' ! var-finish
3234 + character (len=4) :: g, h (1:7, 8:10)
3239 diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp
3240 new file mode 100644
3241 index 0000000000..c121ab9751
3243 +++ b/gdb/testsuite/gdb.fortran/subrange.exp
3245 +# Copyright 2011 Free Software Foundation, Inc.
3247 +# This program is free software; you can redistribute it and/or modify
3248 +# it under the terms of the GNU General Public License as published by
3249 +# the Free Software Foundation; either version 3 of the License, or
3250 +# (at your option) any later version.
3252 +# This program is distributed in the hope that it will be useful,
3253 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3254 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3255 +# GNU General Public License for more details.
3257 +# You should have received a copy of the GNU General Public License
3258 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
3260 +if { [skip_fortran_tests] } { return -1 }
3262 +set testfile "subrange"
3263 +set srcfile ${testfile}.f90
3264 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
3268 +if ![runto MAIN__] {
3269 + perror "Couldn't run to MAIN__"
3273 +# Depending on the compiler version being used, the name of the 4-byte integer
3274 +# and real types can be printed differently. For instance, gfortran-4.1 uses
3275 +# "int4" whereas gfortran-4.3 uses "int(kind=4)".
3276 +set int4 "(int4|integer\\(kind=4\\))"
3278 +gdb_breakpoint [gdb_get_line_number "break-static"]
3279 +gdb_continue_to_breakpoint "break-static" ".*break-static.*"
3281 +foreach var {a alloc ptr} {
3283 + set old_prefix $pf_prefix
3284 + lappend pf_prefix "$var:"
3286 + setup_kfail "*-*-*" "vlaregression/9999"
3287 + gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
3288 + setup_kfail "*-*-*" "vlaregression/9999"
3289 + gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
3290 + setup_kfail "*-*-*" "vlaregression/9999"
3291 + gdb_test "p $var (1, 2:)" { = \(21, 31\)}
3292 + setup_kfail "*-*-*" "vlaregression/9999"
3293 + gdb_test "p $var (2, :2)" { = \(12, 22\)}
3294 + setup_kfail "*-*-*" "vlaregression/9999"
3295 + gdb_test "p $var (3, 2:2)" { = \(23\)}
3296 + setup_kfail "*-*-*" "vlaregression/9999"
3297 + gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
3298 + setup_kfail "*-*-*" "vlaregression/9999"
3299 + gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
3300 + setup_kfail "*-*-*" "vlaregression/9999"
3301 + gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
3302 + setup_kfail "*-*-*" "vlaregression/9999"
3303 + gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
3304 + setup_kfail "*-*-*" "vlaregression/9999"
3305 + gdb_test "p $var (:)" "Wrong number of subscripts"
3306 + setup_kfail "*-*-*" "vlaregression/9999"
3307 + gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
3309 + set pf_prefix $old_prefix
3312 +gdb_test_no_output {set $a=a}
3315 +setup_kfail "*-*-*" "vlaregression/9999"
3316 +gdb_test {p $a (3, 2:2)} { = \(23\)}
3317 diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90
3318 new file mode 100644
3319 index 0000000000..4747ea9746
3321 +++ b/gdb/testsuite/gdb.fortran/subrange.f90
3323 +! Copyright 2011 Free Software Foundation, Inc.
3325 +! This program is free software; you can redistribute it and/or modify
3326 +! it under the terms of the GNU General Public License as published by
3327 +! the Free Software Foundation; either version 3 of the License, or
3328 +! (at your option) any later version.
3330 +! This program is distributed in the hope that it will be useful,
3331 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
3332 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3333 +! GNU General Public License for more details.
3335 +! You should have received a copy of the GNU General Public License
3336 +! along with this program. If not, see <http://www.gnu.org/licenses/>.
3339 + integer, target :: a (4, 3)
3340 + integer, allocatable :: alloc (:, :)
3341 + integer, pointer :: ptr (:, :)
3344 + a (i, j) = j * 10 + i
3346 + allocate (alloc (4, 3))
3349 + write (*,*) a ! break-static
3351 diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
3352 new file mode 100644
3353 index 0000000000..ebced3c042
3355 +++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
3357 +/* Copyright 2011 Free Software Foundation, Inc.
3359 + This file is part of GDB.
3361 + This program is free software; you can redistribute it and/or modify
3362 + it under the terms of the GNU General Public License as published by
3363 + the Free Software Foundation; either version 3 of the License, or
3364 + (at your option) any later version.
3366 + This program is distributed in the hope that it will be useful,
3367 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3368 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3369 + GNU General Public License for more details.
3371 + You should have received a copy of the GNU General Public License
3372 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
3375 +main (int argc, char **argv)
3379 + vla[0] = 0; /* break-here */
3383 diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
3384 new file mode 100644
3385 index 0000000000..88326c0390
3387 +++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
3389 +# Copyright 2011 Free Software Foundation, Inc.
3391 +# This program is free software; you can redistribute it and/or modify
3392 +# it under the terms of the GNU General Public License as published by
3393 +# the Free Software Foundation; either version 3 of the License, or
3394 +# (at your option) any later version.
3396 +# This program is distributed in the hope that it will be useful,
3397 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3398 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3399 +# GNU General Public License for more details.
3401 +# You should have received a copy of the GNU General Public License
3402 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
3404 +load_lib mi-support.exp
3405 +set MIFLAGS "-i=mi2"
3408 +if [mi_gdb_start] {
3412 +set testfile "mi2-var-stale-type"
3413 +set srcfile ${testfile}.c
3414 +set binfile [standard_output_file ${testfile}]
3415 +if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
3419 +mi_delete_breakpoints
3420 +mi_gdb_reinitialize_dir $srcdir/$subdir
3421 +mi_gdb_load ${binfile}
3423 +mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
3425 + "maintenance set internal-error quit yes"
3427 +mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
3429 + "maintenance set internal-error corefile yes"
3431 +set line [gdb_get_line_number "break-here"]
3434 +mi_gdb_test "-break-insert -t $srcfile:$line" \
3435 + "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",fullname=\".*\",line=\"$line\",\[^\r\n\]*,original-location=\".*\"\}" \
3436 + "breakpoint at $func"
3438 +if { [mi_run_cmd] < 0 } {
3441 +mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
3443 +mi_create_varobj "vla" "vla" "create local variable vla"
3445 +mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *"
3446 diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
3447 new file mode 100644
3448 index 0000000000..729f457c82
3450 +++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
3452 +/* This file is part of GDB, the GNU debugger.
3454 + Copyright 2009 Free Software Foundation, Inc.
3456 + This program is free software; you can redistribute it and/or modify
3457 + it under the terms of the GNU General Public License as published by
3458 + the Free Software Foundation; either version 3 of the License, or
3459 + (at your option) any later version.
3461 + This program is distributed in the hope that it will be useful,
3462 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3463 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3464 + GNU General Public License for more details.
3466 + You should have received a copy of the GNU General Public License
3467 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
3474 diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
3475 new file mode 100644
3476 index 0000000000..3090e7e631
3478 +++ b/gdb/testsuite/gdb.opt/array-from-register.c
3480 +/* This file is part of GDB, the GNU debugger.
3482 + Copyright 2009 Free Software Foundation, Inc.
3484 + This program is free software; you can redistribute it and/or modify
3485 + it under the terms of the GNU General Public License as published by
3486 + the Free Software Foundation; either version 3 of the License, or
3487 + (at your option) any later version.
3489 + This program is distributed in the hope that it will be useful,
3490 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3491 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3492 + GNU General Public License for more details.
3494 + You should have received a copy of the GNU General Public License
3495 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
3497 +extern int func (int *arr);
3502 + int arr[] = { 42 };
3508 diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
3509 new file mode 100644
3510 index 0000000000..f2de718bc3
3512 +++ b/gdb/testsuite/gdb.opt/array-from-register.exp
3514 +# Copyright 2009 Free Software Foundation, Inc.
3516 +# This program is free software; you can redistribute it and/or modify
3517 +# it under the terms of the GNU General Public License as published by
3518 +# the Free Software Foundation; either version 2 of the License, or
3519 +# (at your option) any later version.
3521 +# This program is distributed in the hope that it will be useful,
3522 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3523 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3524 +# GNU General Public License for more details.
3526 +# You should have received a copy of the GNU General Public License
3527 +# along with this program; if not, write to the Free Software
3528 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3530 +# This file is part of the gdb testsuite.
3532 +if { [prepare_for_testing array-from-register.exp "array-from-register" \
3533 + {array-from-register.c array-from-register-func.c} \
3534 + {debug optimize=-O2}] } {
3538 +if ![runto func] then {
3542 +gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
3545 +# Address requested for identifier "arr" which is in register $rdi
3546 +gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
3547 diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp
3548 new file mode 100644
3549 index 0000000000..90a2bdf212
3551 +++ b/gdb/testsuite/gdb.opt/fortran-string.exp
3553 +# Copyright 2009 Free Software Foundation, Inc.
3555 +# This program is free software; you can redistribute it and/or modify
3556 +# it under the terms of the GNU General Public License as published by
3557 +# the Free Software Foundation; either version 2 of the License, or
3558 +# (at your option) any later version.
3560 +# This program is distributed in the hope that it will be useful,
3561 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3562 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3563 +# GNU General Public License for more details.
3565 +# You should have received a copy of the GNU General Public License
3566 +# along with this program; if not, write to the Free Software
3567 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3569 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
3571 +# Test GDB can cope with Fortran strings having their length present in a CPU
3572 +# register. With -O0 the string length is passed on the stack. To make this
3573 +# test meaningful the follow assertion should pass. It is not being checked
3574 +# here as the "_s" symbol is compiler dependent:
3575 +# (gdb) info address _s
3576 +# Symbol "_s" is a variable in register XX.
3578 +set test fortran-string
3579 +set srcfile ${test}.f90
3580 +if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f90 additional_flags=-O2}] } {
3584 +if ![runto $srcfile:[gdb_get_line_number "s = s"]] then {
3585 + perror "couldn't run to breakpoint MAIN__"
3589 +gdb_test "frame" ".*s='foo'.*"
3590 +gdb_test "ptype s" "type = character\\*3"
3591 +gdb_test "p s" "\\$\[0-9\]* = 'foo'"
3592 diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90
3593 new file mode 100644
3594 index 0000000000..e48d520085
3596 +++ b/gdb/testsuite/gdb.opt/fortran-string.f90
3598 +! Copyright 2009 Free Software Foundation, Inc.
3600 +! This program is free software; you can redistribute it and/or modify
3601 +! it under the terms of the GNU General Public License as published by
3602 +! the Free Software Foundation; either version 2 of the License, or
3603 +! (at your option) any later version.
3605 +! This program is distributed in the hope that it will be useful,
3606 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
3607 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3608 +! GNU General Public License for more details.
3610 +! You should have received a copy of the GNU General Public License
3611 +! along with this program; if not, write to the Free Software
3612 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3614 +! Ihis file is the Fortran source file for dynamic.exp.
3615 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
3616 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3626 diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp
3627 new file mode 100644
3628 index 0000000000..22acdb86d8
3630 +++ b/gdb/testsuite/gdb.pascal/arrays.exp
3632 +# Copyright 2008, 2009 Free Software Foundation, Inc.
3634 +# This program is free software; you can redistribute it and/or modify
3635 +# it under the terms of the GNU General Public License as published by
3636 +# the Free Software Foundation; either version 3 of the License, or
3637 +# (at your option) any later version.
3639 +# This program is distributed in the hope that it will be useful,
3640 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3641 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3642 +# GNU General Public License for more details.
3644 +# You should have received a copy of the GNU General Public License
3645 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
3647 +if $tracelevel then {
3648 + strace $tracelevel
3651 +load_lib "pascal.exp"
3653 +set testfile "arrays"
3654 +set srcfile ${testfile}.pas
3655 +set binfile [standard_output_file ${testfile}$EXEEXT]
3657 +# These tests only work with fpc, using the -gw3 compile-option
3659 +if { $pascal_compiler_is_fpc != 1 } {
3663 +# Detect if the fpc version is below 2.3.0
3664 +set fpc_generates_dwarf_for_dynamic_arrays 1
3665 +if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} {
3666 + set fpc_generates_dwarf_for_dynamic_arrays 0
3670 +if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
3676 +gdb_reinitialize_dir $srcdir/$subdir
3677 +gdb_load ${binfile}
3678 +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
3679 +set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
3682 +if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
3683 + pass "setting breakpoint 1"
3685 +if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
3686 + pass "setting breakpoint 2"
3689 +# Verify that "start" lands inside the right procedure.
3690 +if { [gdb_start_cmd] < 0 } {
3695 +gdb_test "" ".* at .*${srcfile}.*" "start"
3697 +gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
3699 +gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type"
3700 +gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer"
3702 +gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
3704 +gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char"
3705 +gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer"
3707 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3708 + setup_xfail "*-*-*"
3710 +gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type"
3711 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3712 + setup_xfail "*-*-*"
3714 +gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
3716 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3717 + setup_xfail "*-*-*"
3719 +gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
3721 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3722 + setup_xfail "*-*-*"
3724 +gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
3726 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3727 + setup_xfail "*-*-*"
3729 +gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
3731 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3732 + setup_xfail "*-*-*"
3734 +gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
3736 diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas
3737 new file mode 100644
3738 index 0000000000..295602d68c
3740 +++ b/gdb/testsuite/gdb.pascal/arrays.pas
3743 + Copyright 2008, 2009 Free Software Foundation, Inc.
3745 + This program is free software; you can redistribute it and/or modify
3746 + it under the terms of the GNU General Public License as published by
3747 + the Free Software Foundation; either version 3 of the License, or
3748 + (at your option) any later version.
3750 + This program is distributed in the hope that it will be useful,
3751 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3752 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3753 + GNU General Public License for more details.
3755 + You should have received a copy of the GNU General Public License
3756 + along with this program. If not, see <http://www.gnu.org/licenses/>.
3761 +{$mode objfpc}{$h+}
3765 +type TStatArrInt= array[0..11] of integer;
3766 + TDynArrInt= array of integer;
3767 + TStatArrStr= array[0..12] of string;
3768 + TDynArrStr= array of string;
3769 + TDynArrChar = array of char;
3770 + TStatArrChar = array [0..11] of char;
3772 + TStat2dArrInt = array[0..11,0..4] of integer;
3774 +var StatArrInt: TStatArrInt;
3775 + StatArrInt_: Array[0..11] of integer;
3776 + DynArrInt: TDynArrInt;
3777 + DynArrInt_: Array of integer;
3778 + StatArrStr: TStatArrStr;
3779 + DynArrStr: TDynArrStr;
3780 + StatArrChar: TStatArrChar;
3781 + DynArrChar: TDynArrChar;
3783 + Stat2dArrInt: TStat2dArrInt;
3790 + for i := 0 to 11 do
3792 + StatArrInt[i]:= i+50;
3793 + StatArrInt_[i]:= i+50;
3794 + StatArrChar[i]:= chr(ord('a')+i);
3795 + for j := 0 to 4 do
3796 + Stat2dArrInt[i,j]:=i+j;
3798 + writeln(StatArrInt_[0]);
3799 + writeln(StatArrInt[0]); { set breakpoint 1 here }
3800 + writeln(StatArrChar[0]);
3801 + writeln(Stat2dArrInt[0,0]);
3803 + setlength(DynArrInt,13);
3804 + setlength(DynArrInt_,13);
3805 + setlength(DynArrStr,13);
3806 + setlength(DynArrChar,13);
3807 + for i := 0 to 12 do
3809 + DynArrInt[i]:= i+50;
3810 + DynArrInt_[i]:= i+50;
3811 + DynArrChar[i]:= chr(ord('a')+i);
3812 + StatArrStr[i]:='str'+inttostr(i);
3813 + DynArrStr[i]:='dstr'+inttostr(i);
3815 + writeln(DynArrInt_[1]);
3816 + writeln(DynArrInt[1]);
3817 + writeln(DynArrStr[1]);
3818 + writeln(StatArrStr[1]);
3819 + writeln(DynArrChar[1]);
3821 + s := 'test'#0'string';
3822 + writeln(s); { set breakpoint 2 here }
3824 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
3825 index a165bf0938..a13aaf7869 100644
3826 --- a/gdb/testsuite/lib/gdb.exp
3827 +++ b/gdb/testsuite/lib/gdb.exp
3828 @@ -169,6 +169,11 @@ proc gdb_unload {} {
3832 + -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
3834 + verbose "\t\tUnloading symbols for program being debugged"
3837 -re "Discard symbol table from .*y or n.*$" {
3840 diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp
3841 index 03d1b1bc06..9f9e143dff 100644
3842 --- a/gdb/testsuite/lib/pascal.exp
3843 +++ b/gdb/testsuite/lib/pascal.exp
3844 @@ -37,6 +37,9 @@ proc pascal_init {} {
3845 global pascal_compiler_is_fpc
3848 + global fpcversion_major
3849 + global fpcversion_minor
3850 + global fpcversion_release
3853 if { $pascal_init_done == 1 } {
3854 @@ -64,6 +67,20 @@ proc pascal_init {} {
3855 set pascal_compiler_is_fpc 1
3856 verbose -log "Free Pascal compiler found"
3859 + # Detect the fpc-version
3860 + if { $pascal_compiler_is_fpc == 1 } {
3861 + set fpcversion_major 1
3862 + set fpcversion_minor 0
3863 + set fpcversion_release 0
3864 + set fpcversion [ remote_exec host $fpc_compiler "-iV" ]
3865 + if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] {
3866 + regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major
3867 + regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor
3868 + regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release
3870 + verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
3873 set pascal_init_done 1