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
8 diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp
9 --- a/gdb/testsuite/gdb.ada/packed_array.exp
10 +++ b/gdb/testsuite/gdb.ada/packed_array.exp
11 @@ -56,5 +56,11 @@ gdb_test_multiple "$test" "$test" {
12 # are. Observed with (FSF GNU Ada 4.5.3 20110124).
15 + -re "= \\(\\)\[\r\n\]+$gdb_prompt $" {
16 + # archer-jankratochvil-vla resolves it as a dynamic type resolved as an
17 + # empty array [0..-1].
18 + # DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref)
23 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
26 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
28 + .file "x86_64-vla-pointer.c"
32 + .type foo, @function
35 + .file 1 "gdb.arch/x86_64-vla-pointer.c"
36 + # gdb.arch/x86_64-vla-pointer.c:22
40 +# PRED: ENTRY (FALLTHRU)
42 + .cfi_def_cfa_offset 16
45 + .cfi_def_cfa_register 6
49 + movl %edi, -52(%rbp)
50 + # gdb.arch/x86_64-vla-pointer.c:22
54 + # gdb.arch/x86_64-vla-pointer.c:23
56 + movl -52(%rbp), %eax
59 + movq %rdx, -32(%rbp)
63 + # gdb.arch/x86_64-vla-pointer.c:24
75 + imulq $16, %rax, %rax
79 + movq %rax, -40(%rbp)
80 + # gdb.arch/x86_64-vla-pointer.c:27
88 + # gdb.arch/x86_64-vla-pointer.c:28
89 + .loc 1 28 0 discriminator 3
90 + movl -20(%rbp), %eax
92 + movq -40(%rbp), %rdx
93 + movl -20(%rbp), %eax
95 + movb %cl, (%rdx,%rax)
96 +# SUCC: 4 (FALLTHRU,DFS_BACK)
97 + # gdb.arch/x86_64-vla-pointer.c:27
98 + .loc 1 27 0 discriminator 3
101 +# PRED: 3 (FALLTHRU,DFS_BACK) 2 [100.0%]
103 + # gdb.arch/x86_64-vla-pointer.c:27
104 + .loc 1 27 0 is_stmt 0 discriminator 1
105 + movl -20(%rbp), %eax
106 + cmpl -52(%rbp), %eax
107 +# SUCC: 3 5 (FALLTHRU)
110 +# PRED: 4 (FALLTHRU)
111 + # gdb.arch/x86_64-vla-pointer.c:30
112 + .loc 1 30 0 is_stmt 1
113 + movq -40(%rbp), %rax
116 + # gdb.arch/x86_64-vla-pointer.c:31
119 + movq -8(%rbp), %rbx
122 +# SUCC: EXIT [100.0%]
128 + .section .debug_info,"",@progbits
130 + .long 0xa5 # Length of Compilation Unit Info
131 + .value 0x4 # DWARF version number
132 + .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
133 + .byte 0x8 # Pointer Size (in bytes)
134 + .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
135 + .long .LASF3 # DW_AT_producer: "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
136 + .byte 0xc # DW_AT_language
137 + .long .LASF4 # DW_AT_name: "gdb.arch/x86_64-vla-pointer.c"
138 + .long .LASF5 # DW_AT_comp_dir: "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
139 + .quad .Ltext0 # DW_AT_low_pc
140 + .quad .Letext0-.Ltext0 # DW_AT_high_pc
141 + .long .Ldebug_line0 # DW_AT_stmt_list
142 + .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
144 + .ascii "foo\0" # DW_AT_name
145 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
146 + .byte 0x15 # DW_AT_decl_line
148 + .quad .LFB0 # DW_AT_low_pc
149 + .quad .LFE0-.LFB0 # DW_AT_high_pc
150 + .uleb128 0x1 # DW_AT_frame_base
151 + .byte 0x9c # DW_OP_call_frame_cfa
152 + # DW_AT_GNU_all_call_sites
153 + .long 0x80 # DW_AT_sibling
154 + .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter)
155 + .long .LASF6 # DW_AT_name: "size"
156 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
157 + .byte 0x15 # DW_AT_decl_line
158 + .long 0x80 # DW_AT_type
159 + .uleb128 0x3 # DW_AT_location
160 + .byte 0x91 # DW_OP_fbreg
162 + .uleb128 0x4 # (DIE (0x59) DW_TAG_typedef)
163 + .long .LASF7 # DW_AT_name: "array_t"
164 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
165 + .byte 0x17 # DW_AT_decl_line
166 + .long 0x87 # DW_AT_type
167 + .uleb128 0x5 # (DIE (0x64) DW_TAG_variable)
168 + .long .LASF0 # DW_AT_name: "array"
169 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
170 + .byte 0x18 # DW_AT_decl_line
171 + .long 0x59 # DW_AT_type
172 + .uleb128 0x3 # DW_AT_location
173 + .byte 0x91 # DW_OP_fbreg
175 + .byte 0x6 # DW_OP_deref
176 + .uleb128 0x6 # (DIE (0x73) DW_TAG_variable)
177 + .ascii "i\0" # DW_AT_name
178 + .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
179 + .byte 0x19 # DW_AT_decl_line
180 + .long 0x80 # DW_AT_type
181 + .uleb128 0x2 # DW_AT_location
182 + .byte 0x91 # DW_OP_fbreg
184 + .byte 0 # end of children of DIE 0x2d
185 + .uleb128 0x7 # (DIE (0x80) DW_TAG_base_type)
186 + .byte 0x4 # DW_AT_byte_size
187 + .byte 0x5 # DW_AT_encoding
188 + .ascii "int\0" # DW_AT_name
189 + .uleb128 0x8 # (DIE (0x87) DW_TAG_array_type)
190 + .long 0xa1 # DW_AT_type
191 + .long 0x9a # DW_AT_sibling
192 + .uleb128 0x9 # (DIE (0x90) DW_TAG_subrange_type)
193 + .long 0x9a # DW_AT_type
194 + .uleb128 0x3 # DW_AT_upper_bound
195 + .byte 0x91 # DW_OP_fbreg
197 + .byte 0x6 # DW_OP_deref
198 + .byte 0 # end of children of DIE 0x87
199 + .uleb128 0xa # (DIE (0x9a) DW_TAG_base_type)
200 + .byte 0x8 # DW_AT_byte_size
201 + .byte 0x7 # DW_AT_encoding
202 + .long .LASF1 # DW_AT_name: "sizetype"
203 + .uleb128 0xa # (DIE (0xa1) DW_TAG_base_type)
204 + .byte 0x1 # DW_AT_byte_size
205 + .byte 0x6 # DW_AT_encoding
206 + .long .LASF2 # DW_AT_name: "char"
207 + .byte 0 # end of children of DIE 0xb
208 + .section .debug_abbrev,"",@progbits
210 + .uleb128 0x1 # (abbrev code)
211 + .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
212 + .byte 0x1 # DW_children_yes
213 + .uleb128 0x25 # (DW_AT_producer)
214 + .uleb128 0xe # (DW_FORM_strp)
215 + .uleb128 0x13 # (DW_AT_language)
216 + .uleb128 0xb # (DW_FORM_data1)
217 + .uleb128 0x3 # (DW_AT_name)
218 + .uleb128 0xe # (DW_FORM_strp)
219 + .uleb128 0x1b # (DW_AT_comp_dir)
220 + .uleb128 0xe # (DW_FORM_strp)
221 + .uleb128 0x11 # (DW_AT_low_pc)
222 + .uleb128 0x1 # (DW_FORM_addr)
223 + .uleb128 0x12 # (DW_AT_high_pc)
224 + .uleb128 0x7 # (DW_FORM_data8)
225 + .uleb128 0x10 # (DW_AT_stmt_list)
226 + .uleb128 0x17 # (DW_FORM_sec_offset)
229 + .uleb128 0x2 # (abbrev code)
230 + .uleb128 0x2e # (TAG: DW_TAG_subprogram)
231 + .byte 0x1 # DW_children_yes
232 + .uleb128 0x3f # (DW_AT_external)
233 + .uleb128 0x19 # (DW_FORM_flag_present)
234 + .uleb128 0x3 # (DW_AT_name)
235 + .uleb128 0x8 # (DW_FORM_string)
236 + .uleb128 0x3a # (DW_AT_decl_file)
237 + .uleb128 0xb # (DW_FORM_data1)
238 + .uleb128 0x3b # (DW_AT_decl_line)
239 + .uleb128 0xb # (DW_FORM_data1)
240 + .uleb128 0x27 # (DW_AT_prototyped)
241 + .uleb128 0x19 # (DW_FORM_flag_present)
242 + .uleb128 0x11 # (DW_AT_low_pc)
243 + .uleb128 0x1 # (DW_FORM_addr)
244 + .uleb128 0x12 # (DW_AT_high_pc)
245 + .uleb128 0x7 # (DW_FORM_data8)
246 + .uleb128 0x40 # (DW_AT_frame_base)
247 + .uleb128 0x18 # (DW_FORM_exprloc)
248 + .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
249 + .uleb128 0x19 # (DW_FORM_flag_present)
250 + .uleb128 0x1 # (DW_AT_sibling)
251 + .uleb128 0x13 # (DW_FORM_ref4)
254 + .uleb128 0x3 # (abbrev code)
255 + .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
256 + .byte 0 # DW_children_no
257 + .uleb128 0x3 # (DW_AT_name)
258 + .uleb128 0xe # (DW_FORM_strp)
259 + .uleb128 0x3a # (DW_AT_decl_file)
260 + .uleb128 0xb # (DW_FORM_data1)
261 + .uleb128 0x3b # (DW_AT_decl_line)
262 + .uleb128 0xb # (DW_FORM_data1)
263 + .uleb128 0x49 # (DW_AT_type)
264 + .uleb128 0x13 # (DW_FORM_ref4)
265 + .uleb128 0x2 # (DW_AT_location)
266 + .uleb128 0x18 # (DW_FORM_exprloc)
269 + .uleb128 0x4 # (abbrev code)
270 + .uleb128 0x16 # (TAG: DW_TAG_typedef)
271 + .byte 0 # DW_children_no
272 + .uleb128 0x3 # (DW_AT_name)
273 + .uleb128 0xe # (DW_FORM_strp)
274 + .uleb128 0x3a # (DW_AT_decl_file)
275 + .uleb128 0xb # (DW_FORM_data1)
276 + .uleb128 0x3b # (DW_AT_decl_line)
277 + .uleb128 0xb # (DW_FORM_data1)
278 + .uleb128 0x49 # (DW_AT_type)
279 + .uleb128 0x13 # (DW_FORM_ref4)
282 + .uleb128 0x5 # (abbrev code)
283 + .uleb128 0x34 # (TAG: DW_TAG_variable)
284 + .byte 0 # DW_children_no
285 + .uleb128 0x3 # (DW_AT_name)
286 + .uleb128 0xe # (DW_FORM_strp)
287 + .uleb128 0x3a # (DW_AT_decl_file)
288 + .uleb128 0xb # (DW_FORM_data1)
289 + .uleb128 0x3b # (DW_AT_decl_line)
290 + .uleb128 0xb # (DW_FORM_data1)
291 + .uleb128 0x49 # (DW_AT_type)
292 + .uleb128 0x13 # (DW_FORM_ref4)
293 + .uleb128 0x2 # (DW_AT_location)
294 + .uleb128 0x18 # (DW_FORM_exprloc)
297 + .uleb128 0x6 # (abbrev code)
298 + .uleb128 0x34 # (TAG: DW_TAG_variable)
299 + .byte 0 # DW_children_no
300 + .uleb128 0x3 # (DW_AT_name)
301 + .uleb128 0x8 # (DW_FORM_string)
302 + .uleb128 0x3a # (DW_AT_decl_file)
303 + .uleb128 0xb # (DW_FORM_data1)
304 + .uleb128 0x3b # (DW_AT_decl_line)
305 + .uleb128 0xb # (DW_FORM_data1)
306 + .uleb128 0x49 # (DW_AT_type)
307 + .uleb128 0x13 # (DW_FORM_ref4)
308 + .uleb128 0x2 # (DW_AT_location)
309 + .uleb128 0x18 # (DW_FORM_exprloc)
312 + .uleb128 0x7 # (abbrev code)
313 + .uleb128 0x24 # (TAG: DW_TAG_base_type)
314 + .byte 0 # DW_children_no
315 + .uleb128 0xb # (DW_AT_byte_size)
316 + .uleb128 0xb # (DW_FORM_data1)
317 + .uleb128 0x3e # (DW_AT_encoding)
318 + .uleb128 0xb # (DW_FORM_data1)
319 + .uleb128 0x3 # (DW_AT_name)
320 + .uleb128 0x8 # (DW_FORM_string)
323 + .uleb128 0x8 # (abbrev code)
324 + .uleb128 0x1 # (TAG: DW_TAG_array_type)
325 + .byte 0x1 # DW_children_yes
326 + .uleb128 0x49 # (DW_AT_type)
327 + .uleb128 0x13 # (DW_FORM_ref4)
328 + .uleb128 0x1 # (DW_AT_sibling)
329 + .uleb128 0x13 # (DW_FORM_ref4)
332 + .uleb128 0x9 # (abbrev code)
333 + .uleb128 0x21 # (TAG: DW_TAG_subrange_type)
334 + .byte 0 # DW_children_no
335 + .uleb128 0x49 # (DW_AT_type)
336 + .uleb128 0x13 # (DW_FORM_ref4)
337 + .uleb128 0x2f # (DW_AT_upper_bound)
338 + .uleb128 0x18 # (DW_FORM_exprloc)
341 + .uleb128 0xa # (abbrev code)
342 + .uleb128 0x24 # (TAG: DW_TAG_base_type)
343 + .byte 0 # DW_children_no
344 + .uleb128 0xb # (DW_AT_byte_size)
345 + .uleb128 0xb # (DW_FORM_data1)
346 + .uleb128 0x3e # (DW_AT_encoding)
347 + .uleb128 0xb # (DW_FORM_data1)
348 + .uleb128 0x3 # (DW_AT_name)
349 + .uleb128 0xe # (DW_FORM_strp)
353 + .section .debug_aranges,"",@progbits
354 + .long 0x2c # Length of Address Ranges Info
355 + .value 0x2 # DWARF Version
356 + .long .Ldebug_info0 # Offset of Compilation Unit Info
357 + .byte 0x8 # Size of Address
358 + .byte 0 # Size of Segment Descriptor
359 + .value 0 # Pad to 16 byte boundary
361 + .quad .Ltext0 # Address
362 + .quad .Letext0-.Ltext0 # Length
365 + .section .debug_line,"",@progbits
367 + .section .debug_str,"MS",@progbits,1
369 + .string "gdb.arch/x86_64-vla-pointer.c"
373 + .string "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
379 + .string "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
384 + .ident "GCC: (GNU) 6.2.1 20160916 (Red Hat 6.2.1-2)"
385 + .section .note.GNU-stack,"",@progbits
386 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
389 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
391 +/* This testcase is part of GDB, the GNU debugger.
393 + Copyright 2009 Free Software Foundation, Inc.
395 + This program is free software; you can redistribute it and/or modify
396 + it under the terms of the GNU General Public License as published by
397 + the Free Software Foundation; either version 3 of the License, or
398 + (at your option) any later version.
400 + This program is distributed in the hope that it will be useful,
401 + but WITHOUT ANY WARRANTY; without even the implied warranty of
402 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
403 + GNU General Public License for more details.
405 + You should have received a copy of the GNU General Public License
406 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
413 + typedef char array_t[size];
417 + for (i = 0; i < size; i++)
420 + array[0] = 0; /* break-here */
425 +void foo (int size);
436 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
439 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
441 +# Copyright 2009 Free Software Foundation, Inc.
443 +# This program is free software; you can redistribute it and/or modify
444 +# it under the terms of the GNU General Public License as published by
445 +# the Free Software Foundation; either version 3 of the License, or
446 +# (at your option) any later version.
448 +# This program is distributed in the hope that it will be useful,
449 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
450 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
451 +# GNU General Public License for more details.
453 +# You should have received a copy of the GNU General Public License
454 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
456 +if ![istarget "x86_64-*-*"] then {
457 + verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64."
461 +set testfile x86_64-vla-pointer
462 +set srcasmfile ${testfile}-foo.S
463 +set srcfile ${testfile}.c
464 +set binfile [standard_output_file ${testfile}]
465 +set binobjfile [standard_output_file ${testfile}-foo.o]
466 +if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
467 + untested "Couldn't compile test program"
470 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {}] != "" } {
471 + untested "Couldn't compile test program"
477 +gdb_reinitialize_dir $srcdir/$subdir
481 + untested x86_64-vla-pointer
485 +gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
487 +gdb_continue_to_breakpoint "break-here"
489 +gdb_test "whatis array" "type = array_t" "first: whatis array"
490 +gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "first: whatis array_t"
491 +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
493 +gdb_test "whatis *array" "type = char" "first: whatis *array"
494 +gdb_test "ptype *array" "type = char" "first: ptype *array"
496 +gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
497 +gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
498 +gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
499 +gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
501 +gdb_continue_to_breakpoint "break_here"
503 +gdb_test "whatis array" "type = array_t" "second: whatis array"
504 +gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "second: whatis array_t"
505 +gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
506 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
509 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
511 + .file "x86_64-vla-typedef.c"
512 + .section .debug_abbrev,"",@progbits
514 + .section .debug_info,"",@progbits
516 + .section .debug_line,"",@progbits
521 + .type foo, @function
524 + .file 1 "x86_64-vla-typedef.c"
532 + movl %edi, -36(%rbp)
535 + movq %rax, -48(%rbp)
537 + movl -36(%rbp), %edx
540 + movq %rax, -24(%rbp)
548 + movq %rsp, -56(%rbp)
549 + movq -56(%rbp), %rax
553 + movq %rax, -56(%rbp)
554 + movq -56(%rbp), %rax
555 + movq %rax, -16(%rbp)
561 + movl -4(%rbp), %esi
562 + movl -4(%rbp), %eax
564 + movq -16(%rbp), %rdx
566 + movb %cl, (%rdx,%rax)
570 + movl -4(%rbp), %eax
571 + cmpl -36(%rbp), %eax
576 + movq -16(%rbp), %rax
578 + movq -48(%rbp), %rsp
584 + .section .debug_frame,"",@progbits
586 + .long .LECIE0-.LSCIE0
602 + .long .LEFDE0-.LASFDE0
614 + .long .LCFI1-.LCFI0
619 + .section .eh_frame,"a",@progbits
621 + .long .LECIE1-.LSCIE1
639 + .long .LEFDE1-.LASFDE1
641 + .long .LASFDE1-.Lframe1
652 + .long .LCFI1-.LCFI0
659 + .section .debug_loc,"",@progbits
662 + .quad .LFB2-.Ltext0
663 + .quad .LCFI0-.Ltext0
667 + .quad .LCFI0-.Ltext0
668 + .quad .LCFI1-.Ltext0
672 + .quad .LCFI1-.Ltext0
673 + .quad .LFE2-.Ltext0
679 + .section .debug_info
680 + .long .Ldebug_end - .Ldebug_start
683 + .long .Ldebug_abbrev0
692 + .long .Ldebug_line0
716 + .long .Ltag_array_type - .debug_info
717 + .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */
722 + .long .Ltag_typedef - .debug_info
724 + /* Debugging only: Skip the typedef indirection. */
725 + .long .Ltag_array_type - .debug_info
727 + /* DW_AT_location: DW_FORM_block1: start */
732 + .byte 0x6 /* DW_OP_deref */
734 + .byte 0x96 /* DW_OP_nop */
736 + /* DW_AT_location: DW_FORM_block1: end */
751 + .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
752 + .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */
753 + .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */
754 +1: /* DW_AT_data_location: DW_FORM_block1: start */
755 + .byte 2f - 3f /* length */
757 + .byte 0x97 /* DW_OP_push_object_address */
758 + .byte 0x6 /* DW_OP_deref */
759 +2: /* DW_AT_data_location: DW_FORM_block1: end */
761 + .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */
776 + .section .debug_abbrev
888 + .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
891 + .uleb128 0x49 /* DW_AT_type */
892 + .uleb128 0x13 /* DW_FORM_ref4 */
893 + .uleb128 0x1 /* DW_AT_sibling */
894 + .uleb128 0x13 /* DW_FORM_ref4 */
895 + .uleb128 0x50 /* DW_AT_data_location */
896 + .uleb128 0xa /* DW_FORM_block1 */
902 + .uleb128 0x49 /* DW_AT_type */
903 + .uleb128 0x13 /* DW_FORM_ref4 */
929 + .section .debug_pubnames,"",@progbits
932 + .long .Ldebug_info0
937 + .section .debug_aranges,"",@progbits
940 + .long .Ldebug_info0
946 + .quad .Letext0-.Ltext0
949 + .section .debug_str,"MS",@progbits,1
955 + .string "x86_64-vla-typedef.c"
963 + .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
964 + .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
965 + .section .note.GNU-stack,"",@progbits
966 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
969 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
971 +/* This testcase is part of GDB, the GNU debugger.
973 + Copyright 2008 Free Software Foundation, Inc.
975 + This program is free software; you can redistribute it and/or modify
976 + it under the terms of the GNU General Public License as published by
977 + the Free Software Foundation; either version 3 of the License, or
978 + (at your option) any later version.
980 + This program is distributed in the hope that it will be useful,
981 + but WITHOUT ANY WARRANTY; without even the implied warranty of
982 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
983 + GNU General Public License for more details.
985 + You should have received a copy of the GNU General Public License
986 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
993 + typedef char array_t[size];
997 + for (i = 0; i < size; i++)
1000 + array[0] = 0; /* break-here */
1005 +void foo (int size);
1016 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
1017 new file mode 100644
1019 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
1021 +# Copyright 2009 Free Software Foundation, Inc.
1023 +# This program is free software; you can redistribute it and/or modify
1024 +# it under the terms of the GNU General Public License as published by
1025 +# the Free Software Foundation; either version 3 of the License, or
1026 +# (at your option) any later version.
1028 +# This program is distributed in the hope that it will be useful,
1029 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1030 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1031 +# GNU General Public License for more details.
1033 +# You should have received a copy of the GNU General Public License
1034 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1036 +# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
1038 +if ![istarget "x86_64-*-*"] then {
1039 + verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
1043 +set testfile x86_64-vla-typedef
1044 +set srcasmfile ${testfile}-foo.S
1045 +set srcfile ${testfile}.c
1046 +set binfile [standard_output_file ${testfile}]
1047 +set binobjfile [standard_output_file ${testfile}-foo.o]
1048 +if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
1049 + untested "Couldn't compile test program"
1052 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
1053 + untested "Couldn't compile test program"
1059 +gdb_reinitialize_dir $srcdir/$subdir
1060 +gdb_load ${binfile}
1063 + untested x86_64-vla-typedef
1067 +gdb_breakpoint "break_here"
1069 +gdb_continue_to_breakpoint "break_here"
1071 +gdb_test "whatis array" "type = array_t" "first: whatis array"
1073 +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
1075 +gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
1076 +gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
1077 +gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
1078 +gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
1080 +gdb_continue_to_breakpoint "break_here"
1082 +gdb_test "whatis array" "type = array_t" "second: whatis array"
1084 +gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
1085 diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c
1086 --- a/gdb/testsuite/gdb.base/arrayidx.c
1087 +++ b/gdb/testsuite/gdb.base/arrayidx.c
1090 int array[] = {1, 2, 3, 4};
1102 diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
1103 --- a/gdb/testsuite/gdb.base/arrayidx.exp
1104 +++ b/gdb/testsuite/gdb.base/arrayidx.exp
1105 @@ -49,4 +49,12 @@ gdb_test "print array" \
1106 "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
1107 "print array with array-indexes on"
1110 +set test "p unbound.a == &unbound.a\[0\]"
1111 +gdb_test_multiple $test $test {
1112 + -re " = 1\r\n$gdb_prompt $" {
1115 + -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
1116 + unsupported "$test (no GCC)"
1119 diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c
1120 new file mode 100644
1122 +++ b/gdb/testsuite/gdb.base/internal-var-field-address.c
1124 +/* This testcase is part of GDB, the GNU debugger.
1126 + Copyright 2009 Free Software Foundation, Inc.
1128 + This program is free software; you can redistribute it and/or modify
1129 + it under the terms of the GNU General Public License as published by
1130 + the Free Software Foundation; either version 3 of the License, or
1131 + (at your option) any later version.
1133 + This program is distributed in the hope that it will be useful,
1134 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1135 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1136 + GNU General Public License for more details.
1138 + You should have received a copy of the GNU General Public License
1139 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1143 +} staticstruct = { 1 };
1144 diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp
1145 new file mode 100644
1147 +++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp
1149 +# Copyright 2009 Free Software Foundation, Inc.
1151 +# This program is free software; you can redistribute it and/or modify
1152 +# it under the terms of the GNU General Public License as published by
1153 +# the Free Software Foundation; either version 3 of the License, or
1154 +# (at your option) any later version.
1156 +# This program is distributed in the hope that it will be useful,
1157 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1158 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1159 +# GNU General Public License for more details.
1161 +# You should have received a copy of the GNU General Public License
1162 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1164 +set test internal-var-field-address
1165 +set binfile ${test}.x
1166 +if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "[standard_output_file ${binfile}]" object {debug}] != "" } {
1167 + untested "Couldn't compile test program"
1171 +clean_restart $binfile
1173 +gdb_test {set $varstruct = staticstruct}
1174 +gdb_test {p $varstruct.field} " = 1"
1175 diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c
1176 new file mode 100644
1178 +++ b/gdb/testsuite/gdb.base/vla-frame.c
1180 +/* This testcase is part of GDB, the GNU debugger.
1182 + Copyright 2011 Free Software Foundation, Inc.
1184 + This program is free software; you can redistribute it and/or modify
1185 + it under the terms of the GNU General Public License as published by
1186 + the Free Software Foundation; either version 3 of the License, or
1187 + (at your option) any later version.
1189 + This program is distributed in the hope that it will be useful,
1190 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1191 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1192 + GNU General Public License for more details.
1194 + You should have received a copy of the GNU General Public License
1195 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1197 +#include <string.h>
1200 +main (int argc, char **argv)
1203 + void (*f) (char *) = 0;
1205 + memset (s, 0, sizeof (s));
1211 diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp
1212 new file mode 100644
1214 +++ b/gdb/testsuite/gdb.base/vla-frame.exp
1216 +# Copyright 2011 Free Software Foundation, Inc.
1218 +# This program is free software; you can redistribute it and/or modify
1219 +# it under the terms of the GNU General Public License as published by
1220 +# the Free Software Foundation; either version 3 of the License, or
1221 +# (at your option) any later version.
1223 +# This program is distributed in the hope that it will be useful,
1224 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1225 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1226 +# GNU General Public License for more details.
1228 +# You should have received a copy of the GNU General Public License
1229 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1231 +set testfile vla-frame
1232 +set executable ${testfile}
1234 +if { [prepare_for_testing ${testfile}.exp ${executable}] } {
1242 +set test "continue"
1243 +gdb_test_multiple $test $test {
1244 + -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" {
1247 + -re "\r\n$gdb_prompt $" {
1248 + untested ${testfile}.exp
1253 +gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*"
1254 diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c
1255 new file mode 100644
1257 +++ b/gdb/testsuite/gdb.base/vla-overflow.c
1259 +/* This testcase is part of GDB, the GNU debugger.
1261 + Copyright 2008 Free Software Foundation, Inc.
1263 + This program is free software; you can redistribute it and/or modify
1264 + it under the terms of the GNU General Public License as published by
1265 + the Free Software Foundation; either version 3 of the License, or
1266 + (at your option) any later version.
1268 + This program is distributed in the hope that it will be useful,
1269 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1270 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1271 + GNU General Public License for more details.
1273 + You should have received a copy of the GNU General Public License
1274 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1276 +#include <stdlib.h>
1279 +main (int argc, char **argv)
1283 + array[0] = array[0];
1289 diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp
1290 new file mode 100644
1292 +++ b/gdb/testsuite/gdb.base/vla-overflow.exp
1294 +# Copyright 2008 Free Software Foundation, Inc.
1296 +# This program is free software; you can redistribute it and/or modify
1297 +# it under the terms of the GNU General Public License as published by
1298 +# the Free Software Foundation; either version 3 of the License, or
1299 +# (at your option) any later version.
1301 +# This program is distributed in the hope that it will be useful,
1302 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1303 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1304 +# GNU General Public License for more details.
1306 +# You should have received a copy of the GNU General Public License
1307 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1309 +# We could crash in:
1310 +# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69
1311 +# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97
1312 +# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL));
1313 +# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496
1314 +# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156
1315 +# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206
1316 +# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430
1317 +# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840
1319 +# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
1321 +# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
1323 +set testfile vla-overflow
1324 +set shfile [standard_output_file ${testfile}-gdb.sh]
1325 +set srcfile ${testfile}.c
1326 +set binfile [standard_output_file ${testfile}]
1327 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
1328 + untested "Couldn't compile test program"
1332 +set f [open "|getconf PAGESIZE" "r"]
1338 +gdb_reinitialize_dir $srcdir/$subdir
1339 +gdb_load ${binfile}
1341 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
1343 +if { [runto_main] < 0 } {
1344 + untested vla-overflow
1348 +# Get the GDB memory size when we stay at main.
1350 +proc memory_v_pages_get {} {
1351 + global pid_of_gdb pagesize
1352 + set fd [open "/proc/$pid_of_gdb/statm"]
1355 + # number of pages of virtual memory
1356 + scan $line "%d" drs
1360 +set pages_found [memory_v_pages_get]
1362 +# s390x with glibc-debuginfo.s390x installed used approx. 16MB.
1364 +verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve"
1365 +set kb_found [expr $pages_found * $pagesize / 1024]
1366 +set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024]
1367 +verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
1369 +# Create the ulimit wrapper.
1370 +set f [open $shfile "w"]
1371 +puts $f "#! /bin/sh"
1372 +puts $f "ulimit -v $kb_permit"
1373 +puts $f "exec $GDB \"\$@\""
1375 +remote_exec host "chmod +x $shfile"
1383 +gdb_reinitialize_dir $srcdir/$subdir
1384 +gdb_load ${binfile}
1386 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
1388 +# Check the size again after the second run.
1389 +# We must not stop in main as it would cache `array' and never crash later.
1393 +verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
1395 +gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
1397 +verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
1399 +# `abort' can get expressed as `*__GI_abort'.
1400 +gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
1402 +verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
1403 diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c
1404 new file mode 100644
1406 +++ b/gdb/testsuite/gdb.base/vla.c
1408 +/* This testcase is part of GDB, the GNU debugger.
1410 + Copyright 2008 Free Software Foundation, Inc.
1412 + This program is free software; you can redistribute it and/or modify
1413 + it under the terms of the GNU General Public License as published by
1414 + the Free Software Foundation; either version 3 of the License, or
1415 + (at your option) any later version.
1417 + This program is distributed in the hope that it will be useful,
1418 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1419 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1420 + GNU General Public License for more details.
1422 + You should have received a copy of the GNU General Public License
1423 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1425 +#include <string.h>
1433 +bar (char *a, char *b, char *c, int size)
1435 + memset (a, '1', size);
1436 + memset (b, '2', size);
1437 + memset (c, '3', 48);
1446 + temp1[size - 1] = '\0';
1450 + bar (temp1, temp2, temp3, size);
1452 + marker (); /* break-here */
1463 diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp
1464 new file mode 100644
1466 +++ b/gdb/testsuite/gdb.base/vla.exp
1468 +# Copyright 2008 Free Software Foundation, Inc.
1470 +# This program is free software; you can redistribute it and/or modify
1471 +# it under the terms of the GNU General Public License as published by
1472 +# the Free Software Foundation; either version 3 of the License, or
1473 +# (at your option) any later version.
1475 +# This program is distributed in the hope that it will be useful,
1476 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1477 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1478 +# GNU General Public License for more details.
1480 +# You should have received a copy of the GNU General Public License
1481 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1484 +set srcfile ${testfile}.c
1485 +set binfile [standard_output_file ${testfile}]
1486 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
1487 + untested "Couldn't compile test program"
1493 +gdb_reinitialize_dir $srcdir/$subdir
1494 +gdb_load ${binfile}
1501 +gdb_breakpoint [gdb_get_line_number "break-here"]
1503 +gdb_continue_to_breakpoint "break-here"
1505 +gdb_test "whatis temp1" "type = char \\\[26\\\]" "first: whatis temp1"
1506 +gdb_test "whatis temp2" "type = char \\\[26\\\]" "first: whatis temp2"
1507 +gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
1509 +gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
1510 +gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
1511 +gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
1513 +gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
1514 +gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
1515 +gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
1517 +gdb_continue_to_breakpoint "break-here"
1519 +gdb_test "whatis temp1" "type = char \\\[78\\\]" "second: whatis temp1"
1520 +gdb_test "whatis temp2" "type = char \\\[78\\\]" "second: whatis temp2"
1521 +gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
1523 +gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
1524 +gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
1525 +gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
1527 +gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
1528 +gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
1529 +gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
1530 diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc
1531 new file mode 100644
1533 +++ b/gdb/testsuite/gdb.cp/gdb9593.cc
1535 +/* This testcase is part of GDB, the GNU debugger.
1537 + Copyright 2008, 2009 Free Software Foundation, Inc.
1539 + This program is free software; you can redistribute it and/or modify
1540 + it under the terms of the GNU General Public License as published by
1541 + the Free Software Foundation; either version 3 of the License, or
1542 + (at your option) any later version.
1544 + This program is distributed in the hope that it will be useful,
1545 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1546 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1547 + GNU General Public License for more details.
1549 + You should have received a copy of the GNU General Public License
1550 + along with this program. If not, see <http://www.gnu.org/licenses/>.
1552 +#include <iostream>
1554 +using namespace std;
1556 +class NextOverThrowDerivates
1562 + // Single throw an exception in this function.
1568 + // Throw an exception in another function.
1574 + // Throw an exception in another function, but handle it
1585 + cout << "Caught and handled function1 exception" << endl;
1604 + // We use this to test that a "finish" here does not end up in
1605 + // this frame, but in the one above.
1613 + function1 (); // marker for until
1619 + function1 (); // until here
1623 +NextOverThrowDerivates next_cases;
1630 + next_cases.function1 ();
1639 + next_cases.function2 ();
1648 + // This is duplicated so we can next over one but step into
1650 + next_cases.function2 ();
1657 + next_cases.function3 ();
1661 + next_cases.rethrow ();
1670 + // Another duplicate so we can test "finish".
1671 + next_cases.function2 ();
1678 + // Another test for "finish".
1681 + next_cases.finish ();
1687 + // Test of "until".
1690 + next_cases.finish ();
1696 + // Test of "until" with an argument.
1699 + next_cases.until ();
1705 + // Test of "advance".
1708 + next_cases.until ();
1715 diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp
1716 new file mode 100644
1718 +++ b/gdb/testsuite/gdb.cp/gdb9593.exp
1720 +# Copyright 2008, 2009 Free Software Foundation, Inc.
1722 +# This program is free software; you can redistribute it and/or modify
1723 +# it under the terms of the GNU General Public License as published by
1724 +# the Free Software Foundation; either version 3 of the License, or
1725 +# (at your option) any later version.
1727 +# This program is distributed in the hope that it will be useful,
1728 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1729 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1730 +# GNU General Public License for more details.
1732 +# You should have received a copy of the GNU General Public License
1733 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1736 +if $tracelevel then {
1737 + strace $tracelevel
1740 +if { [skip_cplus_tests] } { continue }
1742 +set testfile "gdb9593"
1743 +set srcfile ${testfile}.cc
1744 +set binfile [standard_output_file $testfile]
1746 +# Create and source the file that provides information about the compiler
1747 +# used to compile the test case.
1748 +if [get_compiler_info "c++"] {
1749 + untested gdb9593.exp
1753 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
1754 + untested gdb9593.exp
1758 +# Some targets can't do function calls, so don't even bother with this
1760 +if [target_info exists gdb,cannot_call_functions] {
1761 + setup_xfail "*-*-*" 9593
1762 + fail "This target can not call functions"
1768 +gdb_reinitialize_dir $srcdir/$subdir
1769 +gdb_load ${binfile}
1771 +if ![runto_main] then {
1772 + perror "couldn't run to main"
1776 +# See whether we have the needed unwinder hooks.
1778 +gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
1779 + -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
1780 + pass "check for unwinder hook"
1782 + -re "No symbol .* in current context.\r\n$gdb_prompt $" {
1783 + # Pass the test so we don't get bogus fails in the results.
1784 + pass "check for unwinder hook"
1789 + untested gdb9593.exp
1793 +# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
1796 + ".*catch (...).*" \
1797 + "next over a throw 1"
1800 + ".*next_cases.function2.*" \
1801 + "next past catch 1"
1804 + ".*catch (...).*" \
1805 + "next over a throw 2"
1808 + ".*next_cases.function2.*" \
1809 + "next past catch 2"
1812 + ".*function1().*" \
1813 + "step into function2 1"
1816 + ".*catch (...).*" \
1817 + "next over a throw 3"
1820 + ".*next_cases.function3.*" \
1821 + "next past catch 3"
1824 + ".*next_cases.rethrow.*" \
1825 + "next over a throw 4"
1828 + ".*catch (...).*" \
1829 + "next over a rethrow"
1832 + ".*next_cases.function2.*" \
1833 + "next after a rethrow"
1836 + ".*function1().*" \
1837 + "step into function2 2"
1839 +gdb_test "finish" \
1840 + ".*catch (...).*" \
1844 + ".*next_cases.finish ().*" \
1845 + "next past catch 4"
1848 + ".*function1 ().*" \
1849 + "step into finish method"
1851 +gdb_test "finish" \
1852 + ".*catch (...).*" \
1856 + ".*next_cases.finish ().*" \
1857 + "next past catch 5"
1860 + ".*function1 ().*" \
1861 + "step into finish, for until"
1864 + ".*function1 ().*" \
1865 + "until with no argument 1"
1867 +set line [gdb_get_line_number "marker for until" $testfile.cc]
1869 +gdb_test "until $line" \
1870 + ".*function1 ().*" \
1871 + "next past catch 6"
1874 + ".*catch (...).*" \
1875 + "until with no argument 2"
1877 +set line [gdb_get_line_number "until here" $testfile.cc]
1880 + ".*next_cases.until ().*" \
1881 + "next past catch 6"
1884 + ".*function1 ().*" \
1887 +gdb_test "until $line" \
1888 + ".*catch (...).*" \
1889 + "until-over-throw"
1892 + ".*next_cases.until ().*" \
1893 + "next past catch 7"
1896 + ".*function1 ().*" \
1897 + "step into until, for advance"
1899 +gdb_test "advance $line" \
1900 + ".*catch (...).*" \
1901 + "advance-over-throw"
1902 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
1903 new file mode 100644
1905 +++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
1907 +/* This testcase is part of GDB, the GNU debugger.
1909 + Copyright 2010 Free Software Foundation, Inc.
1911 + This program is free software; you can redistribute it and/or modify
1912 + it under the terms of the GNU General Public License as published by
1913 + the Free Software Foundation; either version 3 of the License, or
1914 + (at your option) any later version.
1916 + This program is distributed in the hope that it will be useful,
1917 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1918 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1919 + GNU General Public License for more details.
1921 + You should have received a copy of the GNU General Public License
1922 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
1924 +/* Debug information */
1926 +/* We will `break *main' at the very first instruction. */
1927 +#define main_length 1
1931 + /* See DW_OP_lit3 + 1 (0-based). */
1932 + .string "seennotseen"
1934 + .section .debug_info
1936 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
1938 + .2byte 2 /* DWARF version number */
1939 + .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
1940 + .byte 4 /* Pointer Size (in bytes) */
1943 + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
1944 + .4byte .Lproducer /* DW_AT_producer */
1945 + /* Use C++ to exploit a bug in parsing DW_AT_name "". */
1946 + .byte 4 /* DW_AT_language (C++) - */
1947 + .4byte main /* DW_AT_low_pc */
1948 + .byte main_length /* DW_AT_high_pc */
1951 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
1952 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1954 + .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
1955 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1956 + .byte 0 /* DW_AT_lower_bound */
1957 + .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */
1958 + .byte 0 /* End of children of die */
1960 + /* DW_AT_upper_bound is referencing an optimized-out variable. */
1962 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
1963 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1965 + .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
1966 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1967 + .byte 0 /* DW_AT_lower_bound */
1968 + .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */
1969 + .byte 0 /* End of children of die */
1971 + /* DW_AT_upper_bound is referencing register. */
1973 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
1974 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1976 + .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */
1977 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1978 + .byte 0 /* DW_AT_lower_bound */
1979 + .byte 2f - 1f /* DW_AT_upper_bound */
1980 +1: .byte 0x50 /* DW_OP_reg0 */
1982 + .byte 0 /* End of children of die */
1985 + .uleb128 4 /* Abbrev: DW_TAG_base_type */
1986 + .4byte .Luint_str /* DW_AT_name */
1987 + .byte 4 /* DW_AT_byte_size */
1988 + .byte 7 /* DW_AT_encoding */
1991 + .uleb128 4 /* Abbrev: DW_TAG_base_type */
1992 + .4byte .Lchar_str /* DW_AT_name */
1993 + .byte 1 /* DW_AT_byte_size */
1994 + .byte 6 /* DW_AT_encoding */
1997 + .uleb128 5 /* Abbrev: DW_TAG_variable artificial */
1998 + .byte 1 /* DW_AT_artificial */
1999 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2000 + .4byte .Llen_loclist-.Lloclist /* DW_AT_location */
2002 + /* optimized-out variable for b_string. */
2004 + .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */
2005 + .byte 1 /* DW_AT_artificial */
2006 + .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2008 + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2009 + .string "a_string" /* DW_AT_name */
2010 + .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
2011 + .byte 2f - 1f /* DW_AT_location */
2012 +1: .byte 3 /* DW_OP_addr */
2013 + .4byte vardata /* <addr> */
2016 + /* DW_AT_upper_bound is referencing an optimized-out variable. */
2017 + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2018 + .string "b_string" /* DW_AT_name */
2019 + .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */
2020 + .byte 2f - 1f /* DW_AT_location */
2021 +1: .byte 3 /* DW_OP_addr */
2022 + .4byte vardata /* <addr> */
2025 + /* DW_AT_upper_bound is referencing register. */
2026 + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2027 + .string "reg_string" /* DW_AT_name */
2028 + .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */
2029 + .byte 2f - 1f /* DW_AT_location */
2030 +1: .byte 3 /* DW_OP_addr */
2031 + .4byte vardata /* <addr> */
2034 + .byte 0 /* End of children of CU */
2037 + .section .debug_loc
2040 + .4byte 0 # Location list begin address
2041 + .4byte main_length # Location list end address
2042 + .value 2f-1f # Location expression size
2043 +1: .byte 0x33 # DW_OP_lit3
2044 + .byte 0x9f # DW_OP_stack_value
2046 + .quad 0x0 # Location list terminator begin (*.LLST2)
2047 + .quad 0x0 # Location list terminator end (*.LLST2)
2049 + .section .debug_abbrev
2051 + .uleb128 1 /* Abbrev code */
2052 + .uleb128 0x11 /* DW_TAG_compile_unit */
2053 + .byte 0x1 /* has_children */
2054 + .uleb128 0x25 /* DW_AT_producer */
2055 + .uleb128 0xe /* DW_FORM_strp */
2056 + .uleb128 0x13 /* DW_AT_language */
2057 + .uleb128 0xb /* DW_FORM_data1 */
2058 + .uleb128 0x11 /* DW_AT_low_pc */
2059 + .uleb128 0x1 /* DW_FORM_addr */
2060 + .uleb128 0x12 /* DW_AT_high_pc */
2061 + .uleb128 0xb /* DW_FORM_data1 */
2062 + .byte 0x0 /* Terminator */
2063 + .byte 0x0 /* Terminator */
2065 + .uleb128 2 /* Abbrev code */
2066 + .uleb128 0x1 /* TAG: DW_TAG_array_type */
2067 + .byte 0x1 /* DW_children_yes */
2068 + .uleb128 0x49 /* DW_AT_type */
2069 + .uleb128 0x13 /* DW_FORM_ref4 */
2070 + .byte 0x0 /* Terminator */
2071 + .byte 0x0 /* Terminator */
2073 + .uleb128 3 /* Abbrev code */
2074 + .uleb128 0x21 /* DW_TAG_subrange_type */
2075 + .byte 0x0 /* no children */
2076 + .uleb128 0x49 /* DW_AT_type */
2077 + .uleb128 0x13 /* DW_FORM_ref4 */
2078 + .uleb128 0x22 /* DW_AT_lower_bound */
2079 + .uleb128 0xb /* DW_FORM_data1 */
2080 + .uleb128 0x2f /* DW_AT_upper_bound */
2081 + .uleb128 0x13 /* DW_FORM_ref4 */
2082 + .byte 0x0 /* Terminator */
2083 + .byte 0x0 /* Terminator */
2085 + .uleb128 4 /* Abbrev code */
2086 + .uleb128 0x24 /* DW_TAG_base_type */
2087 + .byte 0x0 /* no_children */
2088 + .uleb128 0x3 /* DW_AT_name */
2089 + .uleb128 0xe /* DW_FORM_strp */
2090 + .uleb128 0xb /* DW_AT_byte_size */
2091 + .uleb128 0xb /* DW_FORM_data1 */
2092 + .uleb128 0x3e /* DW_AT_encoding */
2093 + .uleb128 0xb /* DW_FORM_data1 */
2094 + .byte 0x0 /* Terminator */
2095 + .byte 0x0 /* Terminator */
2097 + .uleb128 5 /* Abbrev code */
2098 + .uleb128 0x34 /* DW_TAG_variable */
2099 + .byte 0x0 /* no_children */
2100 + .uleb128 0x34 /* DW_AT_artificial */
2101 + .uleb128 0x0c /* DW_FORM_flag */
2102 + .uleb128 0x49 /* DW_AT_type */
2103 + .uleb128 0x13 /* DW_FORM_ref4 */
2104 + .uleb128 0x02 /* DW_AT_location */
2105 + .uleb128 0x06 /* DW_FORM_data4 */
2106 + .byte 0x0 /* Terminator */
2107 + .byte 0x0 /* Terminator */
2109 + .uleb128 6 /* Abbrev code */
2110 + .uleb128 0x34 /* DW_TAG_variable */
2111 + .byte 0x0 /* no_children */
2112 + .uleb128 0x3 /* DW_AT_name */
2113 + .uleb128 0x8 /* DW_FORM_string */
2114 + .uleb128 0x49 /* DW_AT_type */
2115 + .uleb128 0x13 /* DW_FORM_ref4 */
2116 + .uleb128 0x2 /* DW_AT_location */
2117 + .uleb128 0xa /* DW_FORM_block1 */
2118 + .byte 0x0 /* Terminator */
2119 + .byte 0x0 /* Terminator */
2121 + .uleb128 7 /* Abbrev code */
2122 + .uleb128 0x34 /* DW_TAG_variable */
2123 + .byte 0x0 /* no_children */
2124 + .uleb128 0x34 /* DW_AT_artificial */
2125 + .uleb128 0x0c /* DW_FORM_flag */
2126 + .uleb128 0x49 /* DW_AT_type */
2127 + .uleb128 0x13 /* DW_FORM_ref4 */
2128 + .byte 0x0 /* Terminator */
2129 + .byte 0x0 /* Terminator */
2131 + .uleb128 8 /* Abbrev code */
2132 + .uleb128 0x21 /* DW_TAG_subrange_type with block */
2133 + .byte 0x0 /* no children */
2134 + .uleb128 0x49 /* DW_AT_type */
2135 + .uleb128 0x13 /* DW_FORM_ref4 */
2136 + .uleb128 0x22 /* DW_AT_lower_bound */
2137 + .uleb128 0xb /* DW_FORM_data1 */
2138 + .uleb128 0x2f /* DW_AT_upper_bound */
2139 + .uleb128 0xa /* DW_FORM_block1 */
2140 + .byte 0x0 /* Terminator */
2141 + .byte 0x0 /* Terminator */
2143 + .byte 0x0 /* Terminator */
2146 + .section .debug_str
2148 + .string "GNU C 3.3.3"
2152 + .string "unsigned int"
2153 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
2154 new file mode 100644
2156 +++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
2158 +# Copyright 2010 Free Software Foundation, Inc.
2160 +# This program is free software; you can redistribute it and/or modify
2161 +# it under the terms of the GNU General Public License as published by
2162 +# the Free Software Foundation; either version 3 of the License, or
2163 +# (at your option) any later version.
2165 +# This program is distributed in the hope that it will be useful,
2166 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2167 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2168 +# GNU General Public License for more details.
2170 +# You should have received a copy of the GNU General Public License
2171 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2173 +# Test printing variable with dynamic bounds which reference a different
2174 +# (artificial in the GCC case) variable containing loclist as its location.
2175 +# This testcase uses value (not address) of the referenced variable:
2176 +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
2178 +# This test can only be run on targets which support DWARF-2 and use gas.
2179 +# For now pick a sampling of likely targets.
2180 +if {![istarget *-*-linux*]
2181 + && ![istarget *-*-gnu*]
2182 + && ![istarget *-*-elf*]
2183 + && ![istarget *-*-openbsd*]
2184 + && ![istarget arm-*-eabi*]
2185 + && ![istarget powerpc-*-eabi*]} {
2189 +set testfile dw2-bound-loclist
2190 +if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
2194 +# Verify it behaves at least as an unbound array without inferior.
2196 +# FIXME: FSF GDB crashes due to !has_stack_frames ().
2197 +# But in practice that should not happen.
2198 +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
2199 +#set test "p a_string"
2200 +#gdb_test_multiple $test $test {
2201 +# -re " = 0x\[0-9a-f\]+ \"seennotseen\"\r\n$gdb_prompt $" {
2204 +# -re "No registers\\.\r\n$gdb_prompt $" {
2205 +# kfail "vlaregression" $test
2209 +#gdb_test "ptype a_string" {type = char \[variable length\]}
2211 +# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
2212 +if ![runto "*main"] {
2216 +gdb_test "p a_string" { = "seen"}
2217 +gdb_test "ptype a_string" {type = char \[4\]}
2219 +gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
2220 +gdb_test "ptype b_string" {type = char \[\]}
2222 +# The register contains unpredictable value - the array size.
2223 +gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]}
2224 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
2225 new file mode 100644
2227 +++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
2229 +/* This testcase is part of GDB, the GNU debugger.
2231 + Copyright 2004 Free Software Foundation, Inc.
2233 + This program is free software; you can redistribute it and/or modify
2234 + it under the terms of the GNU General Public License as published by
2235 + the Free Software Foundation; either version 2 of the License, or
2236 + (at your option) any later version.
2238 + This program is distributed in the hope that it will be useful,
2239 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2240 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2241 + GNU General Public License for more details.
2243 + You should have received a copy of the GNU General Public License
2244 + along with this program; if not, write to the Free Software
2245 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2249 +/* The function `func1' traced into must have debug info on offset > 0;
2250 + (DW_UNSND (attr)). This is the reason of `func0' existence. */
2253 +func0(int a, int b)
2257 +/* `func1' being traced into must have some arguments to dump. */
2260 +func1(int a, int b)
2271 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
2272 new file mode 100644
2274 +++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
2276 +# Copyright 2006 Free Software Foundation, Inc.
2278 +# This program is free software; you can redistribute it and/or modify
2279 +# it under the terms of the GNU General Public License as published by
2280 +# the Free Software Foundation; either version 2 of the License, or
2281 +# (at your option) any later version.
2283 +# This program is distributed in the hope that it will be useful,
2284 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2285 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2286 +# GNU General Public License for more details.
2288 +# You should have received a copy of the GNU General Public License
2289 +# along with this program; if not, write to the Free Software
2290 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2292 +# Minimal DWARF-2 unit test
2294 +# This test can only be run on targets which support DWARF-2.
2295 +# For now pick a sampling of likely targets.
2296 +if {![istarget *-*-linux*]
2297 + && ![istarget *-*-gnu*]
2298 + && ![istarget *-*-elf*]
2299 + && ![istarget *-*-openbsd*]
2300 + && ![istarget arm-*-eabi*]
2301 + && ![istarget powerpc-*-eabi*]} {
2305 +set testfile "dw2-stripped"
2306 +set srcfile ${testfile}.c
2307 +set binfile [standard_output_file ${testfile}.x]
2309 +remote_exec build "rm -f ${binfile}"
2311 +# get the value of gcc_compiled
2312 +if [get_compiler_info ${binfile}] {
2316 +# This test can only be run on gcc as we use additional_flags=FIXME
2317 +if {$gcc_compiled == 0} {
2321 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
2325 +remote_exec build "objcopy -R .debug_loc ${binfile}"
2326 +set strip_output [remote_exec build "objdump -h ${binfile}"]
2328 +set test "stripping test file preservation"
2329 +if [ regexp ".debug_info " $strip_output] {
2330 + pass "$test (.debug_info preserved)"
2332 + fail "$test (.debug_info got also stripped)"
2335 +set test "stripping test file functionality"
2336 +if [ regexp ".debug_loc " $strip_output] {
2337 + fail "$test (.debug_loc still present)"
2339 + pass "$test (.debug_loc stripped)"
2344 +gdb_reinitialize_dir $srcdir/$subdir
2345 +gdb_load ${binfile}
2347 +# For C programs, "start" should stop in main().
2350 + ".*main \\(\\) at .*" \
2353 + "func.* \\(.*\\) at .*" \
2355 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
2356 new file mode 100644
2358 +++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
2360 +/* This testcase is part of GDB, the GNU debugger.
2362 + Copyright 2009 Free Software Foundation, Inc.
2364 + This program is free software; you can redistribute it and/or modify
2365 + it under the terms of the GNU General Public License as published by
2366 + the Free Software Foundation; either version 3 of the License, or
2367 + (at your option) any later version.
2369 + This program is distributed in the hope that it will be useful,
2370 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2371 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2372 + GNU General Public License for more details.
2374 + You should have received a copy of the GNU General Public License
2375 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
2377 +/* Debug information */
2379 + .section .debug_info
2382 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2384 + .2byte 2 /* DWARF Version */
2385 + .4byte .Labbrev1_begin /* Offset into abbrev section */
2386 + .byte 4 /* Pointer size */
2389 + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2390 + .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */
2391 + .ascii "GNU C 4.3.2\0" /* DW_AT_producer */
2392 + .byte 1 /* DW_AT_language (C) */
2395 + .uleb128 2 /* Abbrev: DW_TAG_structure_type */
2396 + .ascii "some_struct\0" /* DW_AT_name */
2398 + .uleb128 3 /* Abbrev: DW_TAG_member */
2399 + .ascii "field\0" /* DW_AT_name */
2400 + .byte 0 /* DW_AT_data_member_location */
2402 + .byte 0 /* End of children of some_struct */
2404 + .byte 0 /* End of children of CU */
2409 + .section .debug_abbrev
2411 + .uleb128 1 /* Abbrev code */
2412 + .uleb128 0x11 /* DW_TAG_compile_unit */
2413 + .byte 1 /* has_children */
2414 + .uleb128 0x3 /* DW_AT_name */
2415 + .uleb128 0x8 /* DW_FORM_string */
2416 + .uleb128 0x25 /* DW_AT_producer */
2417 + .uleb128 0x8 /* DW_FORM_string */
2418 + .uleb128 0x13 /* DW_AT_language */
2419 + .uleb128 0xb /* DW_FORM_data1 */
2420 + .byte 0x0 /* Terminator */
2421 + .byte 0x0 /* Terminator */
2423 + .uleb128 2 /* Abbrev code */
2424 + .uleb128 0x13 /* DW_TAG_structure_type */
2425 + .byte 1 /* has_children */
2426 + .uleb128 0x3 /* DW_AT_name */
2427 + .uleb128 0x8 /* DW_FORM_string */
2428 + .byte 0x0 /* Terminator */
2429 + .byte 0x0 /* Terminator */
2431 + .uleb128 3 /* Abbrev code */
2432 + .uleb128 0x0d /* DW_TAG_member */
2433 + .byte 0 /* has_children */
2434 + .uleb128 0x3 /* DW_AT_name */
2435 + .uleb128 0x8 /* DW_FORM_string */
2436 + .uleb128 0x38 /* DW_AT_data_member_location */
2437 + .uleb128 0x0b /* DW_FORM_data1 */
2438 + .byte 0x0 /* Terminator */
2439 + .byte 0x0 /* Terminator */
2441 + .byte 0x0 /* Terminator */
2442 + .byte 0x0 /* Terminator */
2443 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
2444 new file mode 100644
2446 +++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
2448 +# Copyright 2009 Free Software Foundation, Inc.
2450 +# This program is free software; you can redistribute it and/or modify
2451 +# it under the terms of the GNU General Public License as published by
2452 +# the Free Software Foundation; either version 3 of the License, or
2453 +# (at your option) any later version.
2455 +# This program is distributed in the hope that it will be useful,
2456 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2457 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2458 +# GNU General Public License for more details.
2460 +# You should have received a copy of the GNU General Public License
2461 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2463 +# This test can only be run on targets which support DWARF-2 and use gas.
2464 +# For now pick a sampling of likely targets.
2465 +if {![istarget *-*-linux*]
2466 + && ![istarget *-*-gnu*]
2467 + && ![istarget *-*-elf*]
2468 + && ![istarget *-*-openbsd*]
2469 + && ![istarget arm-*-eabi*]
2470 + && ![istarget powerpc-*-eabi*]} {
2474 +set testfile "dw2-struct-member-data-location"
2475 +set srcfile ${testfile}.S
2476 +set binfile ${testfile}.x
2478 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "[standard_output_file ${binfile}]" object {nodebug}] != "" } {
2482 +clean_restart $binfile
2484 +gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
2485 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
2486 new file mode 100644
2488 +++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
2490 +/* This testcase is part of GDB, the GNU debugger.
2492 + Copyright 2012 Free Software Foundation, Inc.
2494 + This program is free software; you can redistribute it and/or modify
2495 + it under the terms of the GNU General Public License as published by
2496 + the Free Software Foundation; either version 3 of the License, or
2497 + (at your option) any later version.
2499 + This program is distributed in the hope that it will be useful,
2500 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2501 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2502 + GNU General Public License for more details.
2504 + You should have received a copy of the GNU General Public License
2505 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
2507 +/* Debug information */
2516 + .section .debug_info
2518 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2520 + .2byte 2 /* DWARF version number */
2521 + .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
2522 + .byte 4 /* Pointer Size (in bytes) */
2525 + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2526 + .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
2527 + .byte 2 /* DW_AT_language (C) - */
2530 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
2531 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
2533 + .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */
2534 + .byte 0 /* DW_AT_lower_bound */
2535 + .byte 128 /* DW_AT_upper_bound */
2537 + .byte 0 /* End of children of die */
2540 + .uleb128 4 /* Abbrev: DW_TAG_base_type */
2541 + .ascii "char\0" /* DW_AT_name */
2542 + .byte 1 /* DW_AT_byte_size */
2543 + .byte 6 /* DW_AT_encoding */
2545 + .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2546 + .ascii "notype_string\0" /* DW_AT_name */
2547 + .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
2548 + .byte 2f - 1f /* DW_AT_location */
2549 +1: .byte 3 /* DW_OP_addr */
2550 + .4byte vardata /* <addr> */
2553 + .byte 0 /* End of children of CU */
2556 + .section .debug_abbrev
2558 + .uleb128 1 /* Abbrev code */
2559 + .uleb128 0x11 /* DW_TAG_compile_unit */
2560 + .byte 0x1 /* has_children */
2561 + .uleb128 0x25 /* DW_AT_producer */
2562 + .uleb128 0x8 /* DW_FORM_string */
2563 + .uleb128 0x13 /* DW_AT_language */
2564 + .uleb128 0xb /* DW_FORM_data1 */
2565 + .byte 0x0 /* Terminator */
2566 + .byte 0x0 /* Terminator */
2568 + .uleb128 2 /* Abbrev code */
2569 + .uleb128 0x1 /* TAG: DW_TAG_array_type */
2570 + .byte 0x1 /* DW_children_yes */
2571 + .uleb128 0x49 /* DW_AT_type */
2572 + .uleb128 0x13 /* DW_FORM_ref4 */
2573 + .byte 0x0 /* Terminator */
2574 + .byte 0x0 /* Terminator */
2576 + .uleb128 4 /* Abbrev code */
2577 + .uleb128 0x24 /* DW_TAG_base_type */
2578 + .byte 0x0 /* no_children */
2579 + .uleb128 0x3 /* DW_AT_name */
2580 + .uleb128 0x8 /* DW_FORM_string */
2581 + .uleb128 0xb /* DW_AT_byte_size */
2582 + .uleb128 0xb /* DW_FORM_data1 */
2583 + .uleb128 0x3e /* DW_AT_encoding */
2584 + .uleb128 0xb /* DW_FORM_data1 */
2585 + .byte 0x0 /* Terminator */
2586 + .byte 0x0 /* Terminator */
2588 + .uleb128 6 /* Abbrev code */
2589 + .uleb128 0x34 /* DW_TAG_variable */
2590 + .byte 0x0 /* no_children */
2591 + .uleb128 0x3 /* DW_AT_name */
2592 + .uleb128 0x8 /* DW_FORM_string */
2593 + .uleb128 0x49 /* DW_AT_type */
2594 + .uleb128 0x13 /* DW_FORM_ref4 */
2595 + .uleb128 0x2 /* DW_AT_location */
2596 + .uleb128 0xa /* DW_FORM_block1 */
2597 + .byte 0x0 /* Terminator */
2598 + .byte 0x0 /* Terminator */
2600 + .uleb128 8 /* Abbrev code */
2601 + .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */
2602 + .byte 0x0 /* no children */
2603 + .uleb128 0x22 /* DW_AT_lower_bound */
2604 + .uleb128 0xb /* DW_FORM_data1 */
2605 + .uleb128 0x2f /* DW_AT_upper_bound */
2606 + .uleb128 0xb /* DW_FORM_data1 */
2607 + .byte 0x0 /* Terminator */
2608 + .byte 0x0 /* Terminator */
2610 + .byte 0x0 /* Terminator */
2611 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
2612 new file mode 100644
2614 +++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
2616 +# Copyright 2012 Free Software Foundation, Inc.
2618 +# This program is free software; you can redistribute it and/or modify
2619 +# it under the terms of the GNU General Public License as published by
2620 +# the Free Software Foundation; either version 3 of the License, or
2621 +# (at your option) any later version.
2623 +# This program is distributed in the hope that it will be useful,
2624 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2625 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2626 +# GNU General Public License for more details.
2628 +# You should have received a copy of the GNU General Public License
2629 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2632 +# https://bugzilla.redhat.com/show_bug.cgi?id=806920
2633 +# read_subrange_type <TYPE_CODE (base_type) == TYPE_CODE_VOID> reinitialization
2634 +# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without
2635 +# specified DW_AT_type, present only in XLF produced code.
2637 +# This test can only be run on targets which support DWARF-2 and use gas.
2638 +if {![dwarf2_support]} {
2642 +set testfile dw2-subrange-no-type
2643 +set srcfile ${testfile}.S
2644 +set executable ${testfile}.x
2645 +set binfile [standard_output_file ${executable}]
2647 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
2651 +clean_restart $executable
2653 +gdb_test "ptype notype_string" {type = char \[129\]}
2654 +gdb_test "p notype_string" " = 'x' <repeats 129 times>"
2655 diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
2656 new file mode 100644
2658 +++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
2660 +# Copyright 2009 Free Software Foundation, Inc.
2662 +# This program is free software; you can redistribute it and/or modify
2663 +# it under the terms of the GNU General Public License as published by
2664 +# the Free Software Foundation; either version 2 of the License, or
2665 +# (at your option) any later version.
2667 +# This program is distributed in the hope that it will be useful,
2668 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2669 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2670 +# GNU General Public License for more details.
2672 +# You should have received a copy of the GNU General Public License
2673 +# along with this program; if not, write to the Free Software
2674 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2676 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2678 +# This file is part of the gdb testsuite. Array element stride must not be
2679 +# specified in the number of elements but in a number of bytes instead.
2680 +# Original problem:
2682 +# $1 = '0-hello', ' ' <repeats 33 times>
2684 +# warning: Fortran array stride not divisible by the element size
2686 +set testfile dwarf-stride
2687 +set srcfile ${testfile}.f90
2689 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
2693 +if ![runto MAIN__] then {
2694 + perror "couldn't run to breakpoint MAIN__"
2698 +gdb_breakpoint [gdb_get_line_number "break-here"]
2699 +gdb_continue_to_breakpoint "break-here" ".*break-here.*"
2700 +gdb_test "p c40pt(1)" " = '0-hello.*"
2701 +gdb_test "p c40pt(2)" " = '1-hello.*"
2702 diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
2703 new file mode 100644
2705 +++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
2707 +! Copyright 2009 Free Software Foundation, Inc.
2709 +! This program is free software; you can redistribute it and/or modify
2710 +! it under the terms of the GNU General Public License as published by
2711 +! the Free Software Foundation; either version 2 of the License, or
2712 +! (at your option) any later version.
2714 +! This program is distributed in the hope that it will be useful,
2715 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
2716 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2717 +! GNU General Public License for more details.
2719 +! You should have received a copy of the GNU General Public License
2720 +! along with this program; if not, write to the Free Software
2721 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2723 +! File written by Alan Matsuoka.
2728 + character*40 long_string
2730 + end type small_stride
2732 + type(small_stride), dimension (20), target :: unpleasant
2733 + character*40, pointer, dimension(:):: c40pt
2738 + unpleasant(i+1)%small_pad = i+1
2739 + unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
2742 + c40pt => unpleasant%long_string
2744 + print *, c40pt ! break-here
2747 diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
2748 new file mode 100644
2750 +++ b/gdb/testsuite/gdb.fortran/dynamic.exp
2752 +# Copyright 2007 Free Software Foundation, Inc.
2754 +# This program is free software; you can redistribute it and/or modify
2755 +# it under the terms of the GNU General Public License as published by
2756 +# the Free Software Foundation; either version 2 of the License, or
2757 +# (at your option) any later version.
2759 +# This program is distributed in the hope that it will be useful,
2760 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2761 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2762 +# GNU General Public License for more details.
2764 +# You should have received a copy of the GNU General Public License
2765 +# along with this program; if not, write to the Free Software
2766 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2768 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2770 +# This file is part of the gdb testsuite. It contains tests for dynamically
2771 +# allocated Fortran arrays.
2772 +# It depends on the GCC dynamic Fortran arrays DWARF support:
2773 +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
2775 +set testfile "dynamic"
2776 +set srcfile ${testfile}.f90
2777 +set binfile [standard_output_file ${testfile}]
2779 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
2780 + untested "Couldn't compile ${srcfile}"
2786 +gdb_reinitialize_dir $srcdir/$subdir
2787 +gdb_load ${binfile}
2789 +if ![runto MAIN__] then {
2790 + perror "couldn't run to breakpoint MAIN__"
2794 +gdb_breakpoint [gdb_get_line_number "varx-init"]
2795 +gdb_continue_to_breakpoint "varx-init"
2797 +# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
2798 +# Do not: gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx unallocated"
2799 +# Do not: gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx unallocated"
2800 +# Do not: gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) unallocated"
2801 +# Do not: gdb_test "p varx(1,5,17)=1" {no such vector element \(vector not allocated\)} "p varx(1,5,17)=1 unallocated"
2802 +# Do not: gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) unallocated"
2804 +gdb_breakpoint [gdb_get_line_number "varx-allocated"]
2805 +gdb_continue_to_breakpoint "varx-allocated"
2806 +# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
2807 +gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated"
2808 +# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
2809 +gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
2811 +gdb_breakpoint [gdb_get_line_number "varx-filled"]
2812 +gdb_continue_to_breakpoint "varx-filled"
2813 +gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
2814 +gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
2815 +gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
2816 +gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
2817 +# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
2818 +# Do not: gdb_test "p varv" "\\$\[0-9\]* = <not associated>" "p varv unassociated"
2819 +# Do not: gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv unassociated"
2821 +set test "output varx"
2822 +gdb_test_multiple $test $test {
2823 + -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" {
2828 +gdb_breakpoint [gdb_get_line_number "varv-associated"]
2829 +gdb_continue_to_breakpoint "varv-associated"
2830 +gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
2831 +gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
2832 +# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
2833 +gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
2834 +gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated"
2835 +# Intel Fortran Compiler 10.1.008 uses the pointer type.
2836 +gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
2838 +gdb_breakpoint [gdb_get_line_number "varv-filled"]
2839 +gdb_continue_to_breakpoint "varv-filled"
2840 +gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
2841 +gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
2843 +gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
2844 +gdb_continue_to_breakpoint "varv-deassociated"
2845 +# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
2846 +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"
2847 +gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv deassociated"
2848 +gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
2849 +gdb_test "p varv(1,5,17)" {no such vector element \(vector not associated\)}
2850 +gdb_test "ptype varv(1,5,17)" {no such vector element \(vector not associated\)}
2852 +gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
2853 +gdb_continue_to_breakpoint "varx-deallocated"
2854 +gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx deallocated"
2855 +gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx deallocated"
2856 +gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
2857 +gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) deallocated"
2858 +gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) deallocated"
2860 +gdb_breakpoint [gdb_get_line_number "vary-passed"]
2861 +gdb_continue_to_breakpoint "vary-passed"
2862 +# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
2863 +gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
2865 +gdb_breakpoint [gdb_get_line_number "vary-filled"]
2866 +gdb_continue_to_breakpoint "vary-filled"
2867 +gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
2868 +gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
2869 +gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
2870 +gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
2871 +# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
2872 +gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
2874 +gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
2875 +gdb_continue_to_breakpoint "varw-almostfilled"
2876 +gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
2877 +gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
2878 +# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
2879 +gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
2880 +# "up" works with GCC but other Fortran compilers may copy the values into the
2881 +# outer function only on the exit of the inner function.
2882 +# We need both variants as depending on the arch we optionally may still be
2883 +# executing the caller line or not after `finish'.
2884 +gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))"
2885 +gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
2886 +gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
2887 +gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
2888 +gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
2890 +gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
2891 +gdb_continue_to_breakpoint "varz-almostfilled"
2892 +# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
2893 +gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
2894 +# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
2895 +# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
2896 +gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
2897 +gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
2898 +gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
2899 +gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
2900 +# maps to foo::vary(1,1)
2901 +gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
2902 +# maps to foo::vary(2,2)
2903 +gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
2904 +# maps to foo::vary(1,3)
2905 +gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
2906 diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
2907 new file mode 100644
2909 +++ b/gdb/testsuite/gdb.fortran/dynamic.f90
2911 +! Copyright 2007 Free Software Foundation, Inc.
2913 +! This program is free software; you can redistribute it and/or modify
2914 +! it under the terms of the GNU General Public License as published by
2915 +! the Free Software Foundation; either version 2 of the License, or
2916 +! (at your option) any later version.
2918 +! This program is distributed in the hope that it will be useful,
2919 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
2920 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2921 +! GNU General Public License for more details.
2923 +! You should have received a copy of the GNU General Public License
2924 +! along with this program; if not, write to the Free Software
2925 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2927 +! Ihis file is the Fortran source file for dynamic.exp.
2928 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
2929 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
2932 + real, target, allocatable :: varx (:, :, :)
2933 + real, pointer :: varv (:, :, :)
2934 + real, target :: varu (1, 2, 3)
2936 + allocate (varx (1:6, 5:15, 17:28)) ! varx-init
2937 + l = allocated (varx)
2938 + varx(:, :, :) = 6 ! varx-allocated
2939 + varx(1, 5, 17) = 7
2940 + varx(2, 6, 18) = 8
2941 + varx(6, 15, 28) = 9
2942 + varv => varx ! varx-filled
2943 + l = associated (varv)
2944 + varv(3, 7, 19) = 10 ! varv-associated
2945 + varv => null () ! varv-filled
2946 + l = associated (varv)
2947 + deallocate (varx) ! varv-deassociated
2948 + l = allocated (varx)
2949 + varu(:, :, :) = 10 ! varx-deallocated
2950 + allocate (varv (1:6, 5:15, 17:28))
2951 + l = associated (varv)
2953 + varv(1, 5, 17) = 7
2954 + varv(2, 6, 18) = 8
2955 + varv(6, 15, 28) = 9
2957 + l = associated (varv)
2961 + l = associated (varv)
2963 +subroutine foo (vary, varw)
2964 + real :: vary (:, :)
2965 + real :: varw (:, :, :)
2966 + vary(:, :) = 4 ! vary-passed
2970 + varw(:, :, :) = 5 ! vary-filled
2972 + varw(2, 2, 2) = 7 ! varw-almostfilled
2974 +subroutine bar (varz, vart)
2976 + real :: vart (2:11, 7:*)
2978 + varz(2) = 5 ! varz-almostfilled
2979 + vart(2,7) = vart(2,7)
2983 + subroutine foo (vary, varw)
2984 + real :: vary (:, :)
2985 + real :: varw (:, :, :)
2989 + subroutine bar (varz, vart)
2991 + real :: vart (2:11, 7:*)
2994 + real :: x (10, 10), y (5), z(8, 8, 8)
2999 + call foo (x, z(2:6, 4:7, 6:8))
3001 + if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
3002 + if (x (1, 3) .ne. 10) call abort
3003 + if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
3004 + if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
3005 + call foo (transpose (x), z)
3006 + if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
3007 + if (x (3, 1) .ne. 10) call abort
3009 diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
3010 new file mode 100644
3012 +++ b/gdb/testsuite/gdb.fortran/string.exp
3014 +# Copyright 2008 Free Software Foundation, Inc.
3016 +# This program is free software; you can redistribute it and/or modify
3017 +# it under the terms of the GNU General Public License as published by
3018 +# the Free Software Foundation; either version 2 of the License, or
3019 +# (at your option) any later version.
3021 +# This program is distributed in the hope that it will be useful,
3022 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3023 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3024 +# GNU General Public License for more details.
3026 +# You should have received a copy of the GNU General Public License
3027 +# along with this program; if not, write to the Free Software
3028 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3030 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
3032 +# This file is part of the gdb testsuite. It contains tests for Fortran
3033 +# strings with dynamic length.
3035 +set testfile "string"
3036 +set srcfile ${testfile}.f90
3037 +set binfile [standard_output_file ${testfile}]
3039 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
3040 + untested "Couldn't compile ${srcfile}"
3046 +gdb_reinitialize_dir $srcdir/$subdir
3047 +gdb_load ${binfile}
3049 +if ![runto MAIN__] then {
3050 + perror "couldn't run to breakpoint MAIN__"
3054 +gdb_breakpoint [gdb_get_line_number "var-init"]
3055 +gdb_continue_to_breakpoint "var-init"
3056 +gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
3057 +gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
3058 +gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
3059 +gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
3060 +gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
3061 +gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
3062 +gdb_test "p c" "\\$\[0-9\]* = 'c'"
3063 +gdb_test "p d" "\\$\[0-9\]* = 'd '"
3064 +gdb_test "p e" "\\$\[0-9\]* = 'g '"
3065 +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 '\\) \\)"
3066 +gdb_test "p *e" "Attempt to take contents of a non-pointer value."
3067 +gdb_test "p *f" "Attempt to take contents of a non-pointer value."
3069 +gdb_breakpoint [gdb_get_line_number "var-finish"]
3070 +gdb_continue_to_breakpoint "var-finish"
3071 +gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set"
3072 +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"
3073 diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
3074 new file mode 100644
3076 +++ b/gdb/testsuite/gdb.fortran/string.f90
3078 +! Copyright 2008 Free Software Foundation, Inc.
3080 +! This program is free software; you can redistribute it and/or modify
3081 +! it under the terms of the GNU General Public License as published by
3082 +! the Free Software Foundation; either version 2 of the License, or
3083 +! (at your option) any later version.
3085 +! This program is distributed in the hope that it will be useful,
3086 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
3087 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3088 +! GNU General Public License for more details.
3090 +! You should have received a copy of the GNU General Public License
3091 +! along with this program; if not, write to the Free Software
3092 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3094 +! Ihis file is the Fortran source file for dynamic.exp.
3095 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
3096 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3098 +subroutine foo (e, f)
3099 + character (len=1) :: c
3100 + character (len=8) :: d
3101 + character (len=*) :: e
3102 + character (len=*) :: f (1:7, 8:10)
3105 + e = 'e' ! var-init
3108 + c = 'c' ! var-finish
3110 + character (len=4) :: g, h (1:7, 8:10)
3115 diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp
3116 new file mode 100644
3118 +++ b/gdb/testsuite/gdb.fortran/subrange.exp
3120 +# Copyright 2011 Free Software Foundation, Inc.
3122 +# This program is free software; you can redistribute it and/or modify
3123 +# it under the terms of the GNU General Public License as published by
3124 +# the Free Software Foundation; either version 3 of the License, or
3125 +# (at your option) any later version.
3127 +# This program is distributed in the hope that it will be useful,
3128 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3129 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3130 +# GNU General Public License for more details.
3132 +# You should have received a copy of the GNU General Public License
3133 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
3135 +if { [skip_fortran_tests] } { return -1 }
3137 +set testfile "subrange"
3138 +set srcfile ${testfile}.f90
3139 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
3143 +if ![runto MAIN__] {
3144 + perror "Couldn't run to MAIN__"
3148 +# Depending on the compiler version being used, the name of the 4-byte integer
3149 +# and real types can be printed differently. For instance, gfortran-4.1 uses
3150 +# "int4" whereas gfortran-4.3 uses "int(kind=4)".
3151 +set int4 "(int4|integer\\(kind=4\\))"
3153 +gdb_breakpoint [gdb_get_line_number "break-static"]
3154 +gdb_continue_to_breakpoint "break-static" ".*break-static.*"
3156 +foreach var {a alloc ptr} {
3158 + set old_prefix $pf_prefix
3159 + lappend pf_prefix "$var:"
3161 + setup_kfail "*-*-*" "vlaregression/9999"
3162 + gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
3163 + setup_kfail "*-*-*" "vlaregression/9999"
3164 + gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
3165 + setup_kfail "*-*-*" "vlaregression/9999"
3166 + gdb_test "p $var (1, 2:)" { = \(21, 31\)}
3167 + setup_kfail "*-*-*" "vlaregression/9999"
3168 + gdb_test "p $var (2, :2)" { = \(12, 22\)}
3169 + setup_kfail "*-*-*" "vlaregression/9999"
3170 + gdb_test "p $var (3, 2:2)" { = \(23\)}
3171 + setup_kfail "*-*-*" "vlaregression/9999"
3172 + gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
3173 + setup_kfail "*-*-*" "vlaregression/9999"
3174 + gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
3175 + setup_kfail "*-*-*" "vlaregression/9999"
3176 + gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
3177 + setup_kfail "*-*-*" "vlaregression/9999"
3178 + gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
3179 + setup_kfail "*-*-*" "vlaregression/9999"
3180 + gdb_test "p $var (:)" "Wrong number of subscripts"
3181 + setup_kfail "*-*-*" "vlaregression/9999"
3182 + gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
3184 + set pf_prefix $old_prefix
3187 +gdb_test_no_output {set $a=a}
3190 +setup_kfail "*-*-*" "vlaregression/9999"
3191 +gdb_test {p $a (3, 2:2)} { = \(23\)}
3192 diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90
3193 new file mode 100644
3195 +++ b/gdb/testsuite/gdb.fortran/subrange.f90
3197 +! Copyright 2011 Free Software Foundation, Inc.
3199 +! This program is free software; you can redistribute it and/or modify
3200 +! it under the terms of the GNU General Public License as published by
3201 +! the Free Software Foundation; either version 3 of the License, or
3202 +! (at your option) any later version.
3204 +! This program is distributed in the hope that it will be useful,
3205 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
3206 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3207 +! GNU General Public License for more details.
3209 +! You should have received a copy of the GNU General Public License
3210 +! along with this program. If not, see <http://www.gnu.org/licenses/>.
3213 + integer, target :: a (4, 3)
3214 + integer, allocatable :: alloc (:, :)
3215 + integer, pointer :: ptr (:, :)
3218 + a (i, j) = j * 10 + i
3220 + allocate (alloc (4, 3))
3223 + write (*,*) a ! break-static
3225 diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
3226 new file mode 100644
3228 +++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
3230 +/* Copyright 2011 Free Software Foundation, Inc.
3232 + This file is part of GDB.
3234 + This program is free software; you can redistribute it and/or modify
3235 + it under the terms of the GNU General Public License as published by
3236 + the Free Software Foundation; either version 3 of the License, or
3237 + (at your option) any later version.
3239 + This program is distributed in the hope that it will be useful,
3240 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3241 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3242 + GNU General Public License for more details.
3244 + You should have received a copy of the GNU General Public License
3245 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
3248 +main (int argc, char **argv)
3252 + vla[0] = 0; /* break-here */
3256 diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
3257 new file mode 100644
3259 +++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
3261 +# Copyright 2011 Free Software Foundation, Inc.
3263 +# This program is free software; you can redistribute it and/or modify
3264 +# it under the terms of the GNU General Public License as published by
3265 +# the Free Software Foundation; either version 3 of the License, or
3266 +# (at your option) any later version.
3268 +# This program is distributed in the hope that it will be useful,
3269 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3270 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3271 +# GNU General Public License for more details.
3273 +# You should have received a copy of the GNU General Public License
3274 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
3276 +load_lib mi-support.exp
3277 +set MIFLAGS "-i=mi2"
3280 +if [mi_gdb_start] {
3284 +set testfile "mi2-var-stale-type"
3285 +set srcfile ${testfile}.c
3286 +set binfile [standard_output_file ${testfile}]
3287 +if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
3291 +mi_delete_breakpoints
3292 +mi_gdb_reinitialize_dir $srcdir/$subdir
3293 +mi_gdb_load ${binfile}
3295 +mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
3297 + "maintenance set internal-error quit yes"
3299 +mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
3301 + "maintenance set internal-error corefile yes"
3303 +set line [gdb_get_line_number "break-here"]
3306 +mi_gdb_test "-break-insert -t $srcfile:$line" \
3307 + "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",fullname=\".*\",line=\"$line\",\[^\r\n\]*,original-location=\".*\"\}" \
3308 + "breakpoint at $func"
3310 +if { [mi_run_cmd] < 0 } {
3313 +mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
3315 +mi_create_varobj "vla" "vla" "create local variable vla"
3317 +mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *"
3318 diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
3319 new file mode 100644
3321 +++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
3323 +/* This file is part of GDB, the GNU debugger.
3325 + Copyright 2009 Free Software Foundation, Inc.
3327 + This program is free software; you can redistribute it and/or modify
3328 + it under the terms of the GNU General Public License as published by
3329 + the Free Software Foundation; either version 3 of the License, or
3330 + (at your option) any later version.
3332 + This program is distributed in the hope that it will be useful,
3333 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3334 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3335 + GNU General Public License for more details.
3337 + You should have received a copy of the GNU General Public License
3338 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
3345 diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
3346 new file mode 100644
3348 +++ b/gdb/testsuite/gdb.opt/array-from-register.c
3350 +/* This file is part of GDB, the GNU debugger.
3352 + Copyright 2009 Free Software Foundation, Inc.
3354 + This program is free software; you can redistribute it and/or modify
3355 + it under the terms of the GNU General Public License as published by
3356 + the Free Software Foundation; either version 3 of the License, or
3357 + (at your option) any later version.
3359 + This program is distributed in the hope that it will be useful,
3360 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3361 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3362 + GNU General Public License for more details.
3364 + You should have received a copy of the GNU General Public License
3365 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
3367 +extern int func (int *arr);
3372 + int arr[] = { 42 };
3378 diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
3379 new file mode 100644
3381 +++ b/gdb/testsuite/gdb.opt/array-from-register.exp
3383 +# Copyright 2009 Free Software Foundation, Inc.
3385 +# This program is free software; you can redistribute it and/or modify
3386 +# it under the terms of the GNU General Public License as published by
3387 +# the Free Software Foundation; either version 2 of the License, or
3388 +# (at your option) any later version.
3390 +# This program is distributed in the hope that it will be useful,
3391 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3392 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3393 +# GNU General Public License for more details.
3395 +# You should have received a copy of the GNU General Public License
3396 +# along with this program; if not, write to the Free Software
3397 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3399 +# This file is part of the gdb testsuite.
3401 +if { [prepare_for_testing array-from-register.exp "array-from-register" \
3402 + {array-from-register.c array-from-register-func.c} \
3403 + {debug optimize=-O2}] } {
3407 +if ![runto func] then {
3411 +gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
3414 +# Address requested for identifier "arr" which is in register $rdi
3415 +gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
3416 diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp
3417 new file mode 100644
3419 +++ b/gdb/testsuite/gdb.opt/fortran-string.exp
3421 +# Copyright 2009 Free Software Foundation, Inc.
3423 +# This program is free software; you can redistribute it and/or modify
3424 +# it under the terms of the GNU General Public License as published by
3425 +# the Free Software Foundation; either version 2 of the License, or
3426 +# (at your option) any later version.
3428 +# This program is distributed in the hope that it will be useful,
3429 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3430 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3431 +# GNU General Public License for more details.
3433 +# You should have received a copy of the GNU General Public License
3434 +# along with this program; if not, write to the Free Software
3435 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3437 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
3439 +# Test GDB can cope with Fortran strings having their length present in a CPU
3440 +# register. With -O0 the string length is passed on the stack. To make this
3441 +# test meaningful the follow assertion should pass. It is not being checked
3442 +# here as the "_s" symbol is compiler dependent:
3443 +# (gdb) info address _s
3444 +# Symbol "_s" is a variable in register XX.
3446 +set test fortran-string
3447 +set srcfile ${test}.f90
3448 +if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f90 additional_flags=-O2}] } {
3452 +if ![runto $srcfile:[gdb_get_line_number "s = s"]] then {
3453 + perror "couldn't run to breakpoint MAIN__"
3457 +gdb_test "frame" ".*s='foo'.*"
3458 +gdb_test "ptype s" "type = character\\*3"
3459 +gdb_test "p s" "\\$\[0-9\]* = 'foo'"
3460 diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90
3461 new file mode 100644
3463 +++ b/gdb/testsuite/gdb.opt/fortran-string.f90
3465 +! Copyright 2009 Free Software Foundation, Inc.
3467 +! This program is free software; you can redistribute it and/or modify
3468 +! it under the terms of the GNU General Public License as published by
3469 +! the Free Software Foundation; either version 2 of the License, or
3470 +! (at your option) any later version.
3472 +! This program is distributed in the hope that it will be useful,
3473 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
3474 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3475 +! GNU General Public License for more details.
3477 +! You should have received a copy of the GNU General Public License
3478 +! along with this program; if not, write to the Free Software
3479 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3481 +! Ihis file is the Fortran source file for dynamic.exp.
3482 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
3483 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3493 diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp
3494 new file mode 100644
3496 +++ b/gdb/testsuite/gdb.pascal/arrays.exp
3498 +# Copyright 2008, 2009 Free Software Foundation, Inc.
3500 +# This program is free software; you can redistribute it and/or modify
3501 +# it under the terms of the GNU General Public License as published by
3502 +# the Free Software Foundation; either version 3 of the License, or
3503 +# (at your option) any later version.
3505 +# This program is distributed in the hope that it will be useful,
3506 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
3507 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3508 +# GNU General Public License for more details.
3510 +# You should have received a copy of the GNU General Public License
3511 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
3513 +if $tracelevel then {
3514 + strace $tracelevel
3517 +load_lib "pascal.exp"
3519 +set testfile "arrays"
3520 +set srcfile ${testfile}.pas
3521 +set binfile [standard_output_file ${testfile}$EXEEXT]
3523 +# These tests only work with fpc, using the -gw3 compile-option
3525 +if { $pascal_compiler_is_fpc != 1 } {
3529 +# Detect if the fpc version is below 2.3.0
3530 +set fpc_generates_dwarf_for_dynamic_arrays 1
3531 +if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} {
3532 + set fpc_generates_dwarf_for_dynamic_arrays 0
3536 +if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
3542 +gdb_reinitialize_dir $srcdir/$subdir
3543 +gdb_load ${binfile}
3544 +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
3545 +set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
3548 +if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
3549 + pass "setting breakpoint 1"
3551 +if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
3552 + pass "setting breakpoint 2"
3555 +# Verify that "start" lands inside the right procedure.
3556 +if { [gdb_start_cmd] < 0 } {
3561 +gdb_test "" ".* at .*${srcfile}.*" "start"
3563 +gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
3565 +gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type"
3566 +gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer"
3568 +gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
3570 +gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char"
3571 +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"
3573 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3574 + setup_xfail "*-*-*"
3576 +gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type"
3577 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3578 + setup_xfail "*-*-*"
3580 +gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
3582 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3583 + setup_xfail "*-*-*"
3585 +gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
3587 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3588 + setup_xfail "*-*-*"
3590 +gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
3592 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3593 + setup_xfail "*-*-*"
3595 +gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
3597 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3598 + setup_xfail "*-*-*"
3600 +gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
3602 diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas
3603 new file mode 100644
3605 +++ b/gdb/testsuite/gdb.pascal/arrays.pas
3608 + Copyright 2008, 2009 Free Software Foundation, Inc.
3610 + This program is free software; you can redistribute it and/or modify
3611 + it under the terms of the GNU General Public License as published by
3612 + the Free Software Foundation; either version 3 of the License, or
3613 + (at your option) any later version.
3615 + This program is distributed in the hope that it will be useful,
3616 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3617 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3618 + GNU General Public License for more details.
3620 + You should have received a copy of the GNU General Public License
3621 + along with this program. If not, see <http://www.gnu.org/licenses/>.
3626 +{$mode objfpc}{$h+}
3630 +type TStatArrInt= array[0..11] of integer;
3631 + TDynArrInt= array of integer;
3632 + TStatArrStr= array[0..12] of string;
3633 + TDynArrStr= array of string;
3634 + TDynArrChar = array of char;
3635 + TStatArrChar = array [0..11] of char;
3637 + TStat2dArrInt = array[0..11,0..4] of integer;
3639 +var StatArrInt: TStatArrInt;
3640 + StatArrInt_: Array[0..11] of integer;
3641 + DynArrInt: TDynArrInt;
3642 + DynArrInt_: Array of integer;
3643 + StatArrStr: TStatArrStr;
3644 + DynArrStr: TDynArrStr;
3645 + StatArrChar: TStatArrChar;
3646 + DynArrChar: TDynArrChar;
3648 + Stat2dArrInt: TStat2dArrInt;
3655 + for i := 0 to 11 do
3657 + StatArrInt[i]:= i+50;
3658 + StatArrInt_[i]:= i+50;
3659 + StatArrChar[i]:= chr(ord('a')+i);
3660 + for j := 0 to 4 do
3661 + Stat2dArrInt[i,j]:=i+j;
3663 + writeln(StatArrInt_[0]);
3664 + writeln(StatArrInt[0]); { set breakpoint 1 here }
3665 + writeln(StatArrChar[0]);
3666 + writeln(Stat2dArrInt[0,0]);
3668 + setlength(DynArrInt,13);
3669 + setlength(DynArrInt_,13);
3670 + setlength(DynArrStr,13);
3671 + setlength(DynArrChar,13);
3672 + for i := 0 to 12 do
3674 + DynArrInt[i]:= i+50;
3675 + DynArrInt_[i]:= i+50;
3676 + DynArrChar[i]:= chr(ord('a')+i);
3677 + StatArrStr[i]:='str'+inttostr(i);
3678 + DynArrStr[i]:='dstr'+inttostr(i);
3680 + writeln(DynArrInt_[1]);
3681 + writeln(DynArrInt[1]);
3682 + writeln(DynArrStr[1]);
3683 + writeln(StatArrStr[1]);
3684 + writeln(DynArrChar[1]);
3686 + s := 'test'#0'string';
3687 + writeln(s); { set breakpoint 2 here }
3689 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
3690 --- a/gdb/testsuite/lib/gdb.exp
3691 +++ b/gdb/testsuite/lib/gdb.exp
3692 @@ -170,6 +170,11 @@ proc gdb_unload {} {
3696 + -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
3698 + verbose "\t\tUnloading symbols for program being debugged"
3701 -re "Discard symbol table from .*y or n.*$" {
3704 diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp
3705 --- a/gdb/testsuite/lib/pascal.exp
3706 +++ b/gdb/testsuite/lib/pascal.exp
3707 @@ -37,6 +37,9 @@ proc pascal_init {} {
3708 global pascal_compiler_is_fpc
3711 + global fpcversion_major
3712 + global fpcversion_minor
3713 + global fpcversion_release
3716 if { $pascal_init_done == 1 } {
3717 @@ -64,6 +67,20 @@ proc pascal_init {} {
3718 set pascal_compiler_is_fpc 1
3719 verbose -log "Free Pascal compiler found"
3722 + # Detect the fpc-version
3723 + if { $pascal_compiler_is_fpc == 1 } {
3724 + set fpcversion_major 1
3725 + set fpcversion_minor 0
3726 + set fpcversion_release 0
3727 + set fpcversion [ remote_exec host $fpc_compiler "-iV" ]
3728 + if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] {
3729 + regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major
3730 + regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor
3731 + regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release
3733 + verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
3736 set pascal_init_done 1