Blame SOURCES/gdb-archer-vla-tests.patch

4c2ad1
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
4c2ad1
From: Fedora GDB patches <invalid@email.com>
4c2ad1
Date: Fri, 27 Oct 2017 21:07:50 +0200
4c2ad1
Subject: gdb-archer-vla-tests.patch
4c2ad1
4c2ad1
;;=fedoratest
4c2ad1
4c2ad1
diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp
4c2ad1
--- a/gdb/testsuite/gdb.ada/packed_array.exp
4c2ad1
+++ b/gdb/testsuite/gdb.ada/packed_array.exp
4c2ad1
@@ -56,5 +56,11 @@ gdb_test_multiple "$test" "$test" {
4c2ad1
         # are.  Observed with (FSF GNU Ada 4.5.3 20110124).
4c2ad1
         xfail $test
4c2ad1
     }
4c2ad1
+    -re "= \\(\\)\[\r\n\]+$gdb_prompt $" {
4c2ad1
+	# archer-jankratochvil-vla resolves it as a dynamic type resolved as an
4c2ad1
+	# empty array [0..-1].
4c2ad1
+	# DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref)
4c2ad1
+        xfail $test
4c2ad1
+    }
4c2ad1
 }
4c2ad1
 
4c2ad1
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
4c2ad1
@@ -0,0 +1,358 @@
4c2ad1
+	.file	"x86_64-vla-pointer.c"
4c2ad1
+	.text
4c2ad1
+.Ltext0:
4c2ad1
+	.globl	foo
4c2ad1
+	.type	foo, @function
4c2ad1
+foo:
4c2ad1
+.LFB0:
4c2ad1
+	.file 1 "gdb.arch/x86_64-vla-pointer.c"
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:22
4c2ad1
+	.loc 1 22 0
4c2ad1
+	.cfi_startproc
4c2ad1
+# BLOCK 2 seq:0
4c2ad1
+# PRED: ENTRY (FALLTHRU)
4c2ad1
+	pushq	%rbp
4c2ad1
+	.cfi_def_cfa_offset 16
4c2ad1
+	.cfi_offset 6, -16
4c2ad1
+	movq	%rsp, %rbp
4c2ad1
+	.cfi_def_cfa_register 6
4c2ad1
+	pushq	%rbx
4c2ad1
+	subq	$56, %rsp
4c2ad1
+	.cfi_offset 3, -24
4c2ad1
+	movl	%edi, -52(%rbp)
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:22
4c2ad1
+	.loc 1 22 0
4c2ad1
+	movq	%rsp, %rax
4c2ad1
+	movq	%rax, %rsi
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:23
4c2ad1
+	.loc 1 23 0
4c2ad1
+	movl	-52(%rbp), %eax
4c2ad1
+	movslq	%eax, %rdx
4c2ad1
+	subq	$1, %rdx
4c2ad1
+	movq	%rdx, -32(%rbp)
4c2ad1
+	movslq	%eax, %rdx
4c2ad1
+	movq	%rdx, %r8
4c2ad1
+	movl	$0, %r9d
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:24
4c2ad1
+	.loc 1 24 0
4c2ad1
+	movslq	%eax, %rdx
4c2ad1
+	movq	%rdx, %rcx
4c2ad1
+	movl	$0, %ebx
4c2ad1
+	cltq
4c2ad1
+	movl	$16, %edx
4c2ad1
+	subq	$1, %rdx
4c2ad1
+	addq	%rdx, %rax
4c2ad1
+	movl	$16, %ebx
4c2ad1
+	movl	$0, %edx
4c2ad1
+	divq	%rbx
4c2ad1
+	imulq	$16, %rax, %rax
4c2ad1
+	subq	%rax, %rsp
4c2ad1
+	movq	%rsp, %rax
4c2ad1
+	addq	$0, %rax
4c2ad1
+	movq	%rax, -40(%rbp)
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:27
4c2ad1
+	.loc 1 27 0
4c2ad1
+	movl	$0, -20(%rbp)
4c2ad1
+# SUCC: 4 [100.0%] 
4c2ad1
+	jmp	.L2
4c2ad1
+# BLOCK 3 seq:1
4c2ad1
+# PRED: 4
4c2ad1
+.L3:
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:28
4c2ad1
+	.loc 1 28 0 discriminator 3
4c2ad1
+	movl	-20(%rbp), %eax
4c2ad1
+	movl	%eax, %ecx
4c2ad1
+	movq	-40(%rbp), %rdx
4c2ad1
+	movl	-20(%rbp), %eax
4c2ad1
+	cltq
4c2ad1
+	movb	%cl, (%rdx,%rax)
4c2ad1
+# SUCC: 4 (FALLTHRU,DFS_BACK)
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:27
4c2ad1
+	.loc 1 27 0 discriminator 3
4c2ad1
+	addl	$1, -20(%rbp)
4c2ad1
+# BLOCK 4 seq:2
4c2ad1
+# PRED: 3 (FALLTHRU,DFS_BACK) 2 [100.0%] 
4c2ad1
+.L2:
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:27
4c2ad1
+	.loc 1 27 0 is_stmt 0 discriminator 1
4c2ad1
+	movl	-20(%rbp), %eax
4c2ad1
+	cmpl	-52(%rbp), %eax
4c2ad1
+# SUCC: 3 5 (FALLTHRU)
4c2ad1
+	jl	.L3
4c2ad1
+# BLOCK 5 seq:3
4c2ad1
+# PRED: 4 (FALLTHRU)
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:30
4c2ad1
+	.loc 1 30 0 is_stmt 1
4c2ad1
+	movq	-40(%rbp), %rax
4c2ad1
+	movb	$0, (%rax)
4c2ad1
+	movq	%rsi, %rsp
4c2ad1
+	# gdb.arch/x86_64-vla-pointer.c:31
4c2ad1
+	.loc 1 31 0
4c2ad1
+	nop
4c2ad1
+	movq	-8(%rbp), %rbx
4c2ad1
+	leave
4c2ad1
+	.cfi_def_cfa 7, 8
4c2ad1
+# SUCC: EXIT [100.0%] 
4c2ad1
+	ret
4c2ad1
+	.cfi_endproc
4c2ad1
+.LFE0:
4c2ad1
+	.size	foo, .-foo
4c2ad1
+.Letext0:
4c2ad1
+	.section	.debug_info,"",@progbits
4c2ad1
+.Ldebug_info0:
4c2ad1
+	.long	0xa5	# Length of Compilation Unit Info
4c2ad1
+	.value	0x4	# DWARF version number
4c2ad1
+	.long	.Ldebug_abbrev0	# Offset Into Abbrev. Section
4c2ad1
+	.byte	0x8	# Pointer Size (in bytes)
4c2ad1
+	.uleb128 0x1	# (DIE (0xb) DW_TAG_compile_unit)
4c2ad1
+	.long	.LASF3	# DW_AT_producer: "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
4c2ad1
+	.byte	0xc	# DW_AT_language
4c2ad1
+	.long	.LASF4	# DW_AT_name: "gdb.arch/x86_64-vla-pointer.c"
4c2ad1
+	.long	.LASF5	# DW_AT_comp_dir: "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
4c2ad1
+	.quad	.Ltext0	# DW_AT_low_pc
4c2ad1
+	.quad	.Letext0-.Ltext0	# DW_AT_high_pc
4c2ad1
+	.long	.Ldebug_line0	# DW_AT_stmt_list
4c2ad1
+	.uleb128 0x2	# (DIE (0x2d) DW_TAG_subprogram)
4c2ad1
+			# DW_AT_external
4c2ad1
+	.ascii "foo\0"	# DW_AT_name
4c2ad1
+	.byte	0x1	# DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
4c2ad1
+	.byte	0x15	# DW_AT_decl_line
4c2ad1
+			# DW_AT_prototyped
4c2ad1
+	.quad	.LFB0	# DW_AT_low_pc
4c2ad1
+	.quad	.LFE0-.LFB0	# DW_AT_high_pc
4c2ad1
+	.uleb128 0x1	# DW_AT_frame_base
4c2ad1
+	.byte	0x9c	# DW_OP_call_frame_cfa
4c2ad1
+			# DW_AT_GNU_all_call_sites
4c2ad1
+	.long	0x80	# DW_AT_sibling
4c2ad1
+	.uleb128 0x3	# (DIE (0x4a) DW_TAG_formal_parameter)
4c2ad1
+	.long	.LASF6	# DW_AT_name: "size"
4c2ad1
+	.byte	0x1	# DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
4c2ad1
+	.byte	0x15	# DW_AT_decl_line
4c2ad1
+	.long	0x80	# DW_AT_type
4c2ad1
+	.uleb128 0x3	# DW_AT_location
4c2ad1
+	.byte	0x91	# DW_OP_fbreg
4c2ad1
+	.sleb128 -68
4c2ad1
+	.uleb128 0x4	# (DIE (0x59) DW_TAG_typedef)
4c2ad1
+	.long	.LASF7	# DW_AT_name: "array_t"
4c2ad1
+	.byte	0x1	# DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
4c2ad1
+	.byte	0x17	# DW_AT_decl_line
4c2ad1
+	.long	0x87	# DW_AT_type
4c2ad1
+	.uleb128 0x5	# (DIE (0x64) DW_TAG_variable)
4c2ad1
+	.long	.LASF0	# DW_AT_name: "array"
4c2ad1
+	.byte	0x1	# DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
4c2ad1
+	.byte	0x18	# DW_AT_decl_line
4c2ad1
+	.long	0x59	# DW_AT_type
4c2ad1
+	.uleb128 0x3	# DW_AT_location
4c2ad1
+	.byte	0x91	# DW_OP_fbreg
4c2ad1
+	.sleb128 -56
4c2ad1
+	.byte	0x6	# DW_OP_deref
4c2ad1
+	.uleb128 0x6	# (DIE (0x73) DW_TAG_variable)
4c2ad1
+	.ascii "i\0"	# DW_AT_name
4c2ad1
+	.byte	0x1	# DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
4c2ad1
+	.byte	0x19	# DW_AT_decl_line
4c2ad1
+	.long	0x80	# DW_AT_type
4c2ad1
+	.uleb128 0x2	# DW_AT_location
4c2ad1
+	.byte	0x91	# DW_OP_fbreg
4c2ad1
+	.sleb128 -36
4c2ad1
+	.byte	0	# end of children of DIE 0x2d
4c2ad1
+	.uleb128 0x7	# (DIE (0x80) DW_TAG_base_type)
4c2ad1
+	.byte	0x4	# DW_AT_byte_size
4c2ad1
+	.byte	0x5	# DW_AT_encoding
4c2ad1
+	.ascii "int\0"	# DW_AT_name
4c2ad1
+	.uleb128 0x8	# (DIE (0x87) DW_TAG_array_type)
4c2ad1
+	.long	0xa1	# DW_AT_type
4c2ad1
+	.long	0x9a	# DW_AT_sibling
4c2ad1
+	.uleb128 0x9	# (DIE (0x90) DW_TAG_subrange_type)
4c2ad1
+	.long	0x9a	# DW_AT_type
4c2ad1
+	.uleb128 0x3	# DW_AT_upper_bound
4c2ad1
+	.byte	0x91	# DW_OP_fbreg
4c2ad1
+	.sleb128 -48
4c2ad1
+	.byte	0x6	# DW_OP_deref
4c2ad1
+	.byte	0	# end of children of DIE 0x87
4c2ad1
+	.uleb128 0xa	# (DIE (0x9a) DW_TAG_base_type)
4c2ad1
+	.byte	0x8	# DW_AT_byte_size
4c2ad1
+	.byte	0x7	# DW_AT_encoding
4c2ad1
+	.long	.LASF1	# DW_AT_name: "sizetype"
4c2ad1
+	.uleb128 0xa	# (DIE (0xa1) DW_TAG_base_type)
4c2ad1
+	.byte	0x1	# DW_AT_byte_size
4c2ad1
+	.byte	0x6	# DW_AT_encoding
4c2ad1
+	.long	.LASF2	# DW_AT_name: "char"
4c2ad1
+	.byte	0	# end of children of DIE 0xb
4c2ad1
+	.section	.debug_abbrev,"",@progbits
4c2ad1
+.Ldebug_abbrev0:
4c2ad1
+	.uleb128 0x1	# (abbrev code)
4c2ad1
+	.uleb128 0x11	# (TAG: DW_TAG_compile_unit)
4c2ad1
+	.byte	0x1	# DW_children_yes
4c2ad1
+	.uleb128 0x25	# (DW_AT_producer)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x13	# (DW_AT_language)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x1b	# (DW_AT_comp_dir)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x11	# (DW_AT_low_pc)
4c2ad1
+	.uleb128 0x1	# (DW_FORM_addr)
4c2ad1
+	.uleb128 0x12	# (DW_AT_high_pc)
4c2ad1
+	.uleb128 0x7	# (DW_FORM_data8)
4c2ad1
+	.uleb128 0x10	# (DW_AT_stmt_list)
4c2ad1
+	.uleb128 0x17	# (DW_FORM_sec_offset)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0x2	# (abbrev code)
4c2ad1
+	.uleb128 0x2e	# (TAG: DW_TAG_subprogram)
4c2ad1
+	.byte	0x1	# DW_children_yes
4c2ad1
+	.uleb128 0x3f	# (DW_AT_external)
4c2ad1
+	.uleb128 0x19	# (DW_FORM_flag_present)
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0x8	# (DW_FORM_string)
4c2ad1
+	.uleb128 0x3a	# (DW_AT_decl_file)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3b	# (DW_AT_decl_line)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x27	# (DW_AT_prototyped)
4c2ad1
+	.uleb128 0x19	# (DW_FORM_flag_present)
4c2ad1
+	.uleb128 0x11	# (DW_AT_low_pc)
4c2ad1
+	.uleb128 0x1	# (DW_FORM_addr)
4c2ad1
+	.uleb128 0x12	# (DW_AT_high_pc)
4c2ad1
+	.uleb128 0x7	# (DW_FORM_data8)
4c2ad1
+	.uleb128 0x40	# (DW_AT_frame_base)
4c2ad1
+	.uleb128 0x18	# (DW_FORM_exprloc)
4c2ad1
+	.uleb128 0x2117	# (DW_AT_GNU_all_call_sites)
4c2ad1
+	.uleb128 0x19	# (DW_FORM_flag_present)
4c2ad1
+	.uleb128 0x1	# (DW_AT_sibling)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0x3	# (abbrev code)
4c2ad1
+	.uleb128 0x5	# (TAG: DW_TAG_formal_parameter)
4c2ad1
+	.byte	0	# DW_children_no
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x3a	# (DW_AT_decl_file)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3b	# (DW_AT_decl_line)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x49	# (DW_AT_type)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.uleb128 0x2	# (DW_AT_location)
4c2ad1
+	.uleb128 0x18	# (DW_FORM_exprloc)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0x4	# (abbrev code)
4c2ad1
+	.uleb128 0x16	# (TAG: DW_TAG_typedef)
4c2ad1
+	.byte	0	# DW_children_no
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x3a	# (DW_AT_decl_file)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3b	# (DW_AT_decl_line)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x49	# (DW_AT_type)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0x5	# (abbrev code)
4c2ad1
+	.uleb128 0x34	# (TAG: DW_TAG_variable)
4c2ad1
+	.byte	0	# DW_children_no
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x3a	# (DW_AT_decl_file)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3b	# (DW_AT_decl_line)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x49	# (DW_AT_type)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.uleb128 0x2	# (DW_AT_location)
4c2ad1
+	.uleb128 0x18	# (DW_FORM_exprloc)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0x6	# (abbrev code)
4c2ad1
+	.uleb128 0x34	# (TAG: DW_TAG_variable)
4c2ad1
+	.byte	0	# DW_children_no
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0x8	# (DW_FORM_string)
4c2ad1
+	.uleb128 0x3a	# (DW_AT_decl_file)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3b	# (DW_AT_decl_line)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x49	# (DW_AT_type)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.uleb128 0x2	# (DW_AT_location)
4c2ad1
+	.uleb128 0x18	# (DW_FORM_exprloc)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0x7	# (abbrev code)
4c2ad1
+	.uleb128 0x24	# (TAG: DW_TAG_base_type)
4c2ad1
+	.byte	0	# DW_children_no
4c2ad1
+	.uleb128 0xb	# (DW_AT_byte_size)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3e	# (DW_AT_encoding)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0x8	# (DW_FORM_string)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0x8	# (abbrev code)
4c2ad1
+	.uleb128 0x1	# (TAG: DW_TAG_array_type)
4c2ad1
+	.byte	0x1	# DW_children_yes
4c2ad1
+	.uleb128 0x49	# (DW_AT_type)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.uleb128 0x1	# (DW_AT_sibling)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0x9	# (abbrev code)
4c2ad1
+	.uleb128 0x21	# (TAG: DW_TAG_subrange_type)
4c2ad1
+	.byte	0	# DW_children_no
4c2ad1
+	.uleb128 0x49	# (DW_AT_type)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.uleb128 0x2f	# (DW_AT_upper_bound)
4c2ad1
+	.uleb128 0x18	# (DW_FORM_exprloc)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.uleb128 0xa	# (abbrev code)
4c2ad1
+	.uleb128 0x24	# (TAG: DW_TAG_base_type)
4c2ad1
+	.byte	0	# DW_children_no
4c2ad1
+	.uleb128 0xb	# (DW_AT_byte_size)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3e	# (DW_AT_encoding)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.byte	0
4c2ad1
+	.section	.debug_aranges,"",@progbits
4c2ad1
+	.long	0x2c	# Length of Address Ranges Info
4c2ad1
+	.value	0x2	# DWARF Version
4c2ad1
+	.long	.Ldebug_info0	# Offset of Compilation Unit Info
4c2ad1
+	.byte	0x8	# Size of Address
4c2ad1
+	.byte	0	# Size of Segment Descriptor
4c2ad1
+	.value	0	# Pad to 16 byte boundary
4c2ad1
+	.value	0
4c2ad1
+	.quad	.Ltext0	# Address
4c2ad1
+	.quad	.Letext0-.Ltext0	# Length
4c2ad1
+	.quad	0
4c2ad1
+	.quad	0
4c2ad1
+	.section	.debug_line,"",@progbits
4c2ad1
+.Ldebug_line0:
4c2ad1
+	.section	.debug_str,"MS",@progbits,1
4c2ad1
+.LASF4:
4c2ad1
+	.string	"gdb.arch/x86_64-vla-pointer.c"
4c2ad1
+.LASF7:
4c2ad1
+	.string	"array_t"
4c2ad1
+.LASF3:
4c2ad1
+	.string	"GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
4c2ad1
+.LASF2:
4c2ad1
+	.string	"char"
4c2ad1
+.LASF1:
4c2ad1
+	.string	"sizetype"
4c2ad1
+.LASF5:
4c2ad1
+	.string	"/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
4c2ad1
+.LASF6:
4c2ad1
+	.string	"size"
4c2ad1
+.LASF0:
4c2ad1
+	.string	"array"
4c2ad1
+	.ident	"GCC: (GNU) 6.2.1 20160916 (Red Hat 6.2.1-2)"
4c2ad1
+	.section	.note.GNU-stack,"",@progbits
4c2ad1
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
4c2ad1
@@ -0,0 +1,45 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+#if 0
4c2ad1
+
4c2ad1
+void
4c2ad1
+foo (int size)
4c2ad1
+{
4c2ad1
+  typedef char array_t[size];
4c2ad1
+  array_t array;
4c2ad1
+  int i;
4c2ad1
+
4c2ad1
+  for (i = 0; i < size; i++)
4c2ad1
+    array[i] = i;
4c2ad1
+
4c2ad1
+  array[0] = 0;	/* break-here */
4c2ad1
+}
4c2ad1
+
4c2ad1
+#else
4c2ad1
+
4c2ad1
+void foo (int size);
4c2ad1
+
4c2ad1
+int
4c2ad1
+main (void)
4c2ad1
+{
4c2ad1
+  foo (26);
4c2ad1
+  foo (78);
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
+
4c2ad1
+#endif
4c2ad1
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
4c2ad1
@@ -0,0 +1,65 @@
4c2ad1
+# Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+if ![istarget "x86_64-*-*"] then {
4c2ad1
+    verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64."
4c2ad1
+    return
4c2ad1
+}
4c2ad1
+
4c2ad1
+set testfile x86_64-vla-pointer
4c2ad1
+set srcasmfile ${testfile}-foo.S
4c2ad1
+set srcfile ${testfile}.c
4c2ad1
+set binfile [standard_output_file ${testfile}]
4c2ad1
+set binobjfile [standard_output_file ${testfile}-foo.o]
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
4c2ad1
+    untested "Couldn't compile test program"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {}] != "" } {
4c2ad1
+    untested "Couldn't compile test program"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+if ![runto_main] {
4c2ad1
+    untested x86_64-vla-pointer
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
4c2ad1
+
4c2ad1
+gdb_continue_to_breakpoint "break-here"
4c2ad1
+
4c2ad1
+gdb_test "whatis array" "type = array_t" "first: whatis array"
4c2ad1
+gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "first: whatis array_t"
4c2ad1
+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
4c2ad1
+
4c2ad1
+gdb_test "whatis *array" "type = char" "first: whatis *array"
4c2ad1
+gdb_test "ptype *array" "type = char" "first: ptype *array"
4c2ad1
+
4c2ad1
+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
4c2ad1
+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
4c2ad1
+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
4c2ad1
+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
4c2ad1
+
4c2ad1
+gdb_continue_to_breakpoint "break_here"
4c2ad1
+
4c2ad1
+gdb_test "whatis array" "type = array_t" "second: whatis array"
4c2ad1
+gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "second: whatis array_t"
4c2ad1
+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
4c2ad1
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
4c2ad1
@@ -0,0 +1,455 @@
4c2ad1
+	.file	"x86_64-vla-typedef.c"
4c2ad1
+	.section	.debug_abbrev,"",@progbits
4c2ad1
+.Ldebug_abbrev0:
4c2ad1
+	.section	.debug_info,"",@progbits
4c2ad1
+.Ldebug_info0:
4c2ad1
+	.section	.debug_line,"",@progbits
4c2ad1
+.Ldebug_line0:
4c2ad1
+	.text
4c2ad1
+.Ltext0:
4c2ad1
+.globl foo
4c2ad1
+	.type	foo, @function
4c2ad1
+foo:
4c2ad1
+.LFB2:
4c2ad1
+	.file 1 "x86_64-vla-typedef.c"
4c2ad1
+	.loc 1 22 0
4c2ad1
+	pushq	%rbp
4c2ad1
+.LCFI0:
4c2ad1
+	movq	%rsp, %rbp
4c2ad1
+.LCFI1:
4c2ad1
+	subq	$64, %rsp
4c2ad1
+.LCFI2:
4c2ad1
+	movl	%edi, -36(%rbp)
4c2ad1
+	.loc 1 22 0
4c2ad1
+	movq	%rsp, %rax
4c2ad1
+	movq	%rax, -48(%rbp)
4c2ad1
+	.loc 1 23 0
4c2ad1
+	movl	-36(%rbp), %edx
4c2ad1
+	movslq	%edx,%rax
4c2ad1
+	subq	$1, %rax
4c2ad1
+	movq	%rax, -24(%rbp)
4c2ad1
+	.loc 1 24 0
4c2ad1
+	movslq	%edx,%rax
4c2ad1
+	addq	$15, %rax
4c2ad1
+	addq	$15, %rax
4c2ad1
+	shrq	$4, %rax
4c2ad1
+	salq	$4, %rax
4c2ad1
+	subq	%rax, %rsp
4c2ad1
+	movq	%rsp, -56(%rbp)
4c2ad1
+	movq	-56(%rbp), %rax
4c2ad1
+	addq	$15, %rax
4c2ad1
+	shrq	$4, %rax
4c2ad1
+	salq	$4, %rax
4c2ad1
+	movq	%rax, -56(%rbp)
4c2ad1
+	movq	-56(%rbp), %rax
4c2ad1
+	movq	%rax, -16(%rbp)
4c2ad1
+	.loc 1 27 0
4c2ad1
+	movl	$0, -4(%rbp)
4c2ad1
+	jmp	.L2
4c2ad1
+.L3:
4c2ad1
+	.loc 1 28 0
4c2ad1
+	movl	-4(%rbp), %esi
4c2ad1
+	movl	-4(%rbp), %eax
4c2ad1
+	movl	%eax, %ecx
4c2ad1
+	movq	-16(%rbp), %rdx
4c2ad1
+	movslq	%esi,%rax
4c2ad1
+	movb	%cl, (%rdx,%rax)
4c2ad1
+	.loc 1 27 0
4c2ad1
+	addl	$1, -4(%rbp)
4c2ad1
+.L2:
4c2ad1
+	movl	-4(%rbp), %eax
4c2ad1
+	cmpl	-36(%rbp), %eax
4c2ad1
+	jl	.L3
4c2ad1
+	.loc 1 30 0
4c2ad1
+	.globl	break_here
4c2ad1
+break_here:
4c2ad1
+	movq	-16(%rbp), %rax
4c2ad1
+	movb	$0, (%rax)
4c2ad1
+	movq	-48(%rbp), %rsp
4c2ad1
+	.loc 1 31 0
4c2ad1
+	leave
4c2ad1
+	ret
4c2ad1
+.LFE2:
4c2ad1
+	.size	foo, .-foo
4c2ad1
+	.section	.debug_frame,"",@progbits
4c2ad1
+.Lframe0:
4c2ad1
+	.long	.LECIE0-.LSCIE0
4c2ad1
+.LSCIE0:
4c2ad1
+	.long	0xffffffff
4c2ad1
+	.byte	0x1
4c2ad1
+	.string	""
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.sleb128 -8
4c2ad1
+	.byte	0x10
4c2ad1
+	.byte	0xc
4c2ad1
+	.uleb128 0x7
4c2ad1
+	.uleb128 0x8
4c2ad1
+	.byte	0x90
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.align 8
4c2ad1
+.LECIE0:
4c2ad1
+.LSFDE0:
4c2ad1
+	.long	.LEFDE0-.LASFDE0
4c2ad1
+.LASFDE0:
4c2ad1
+	.long	.Lframe0
4c2ad1
+	.quad	.LFB2
4c2ad1
+	.quad	.LFE2-.LFB2
4c2ad1
+	.byte	0x4
4c2ad1
+	.long	.LCFI0-.LFB2
4c2ad1
+	.byte	0xe
4c2ad1
+	.uleb128 0x10
4c2ad1
+	.byte	0x86
4c2ad1
+	.uleb128 0x2
4c2ad1
+	.byte	0x4
4c2ad1
+	.long	.LCFI1-.LCFI0
4c2ad1
+	.byte	0xd
4c2ad1
+	.uleb128 0x6
4c2ad1
+	.align 8
4c2ad1
+.LEFDE0:
4c2ad1
+	.section	.eh_frame,"a",@progbits
4c2ad1
+.Lframe1:
4c2ad1
+	.long	.LECIE1-.LSCIE1
4c2ad1
+.LSCIE1:
4c2ad1
+	.long	0x0
4c2ad1
+	.byte	0x1
4c2ad1
+	.string	"zR"
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.sleb128 -8
4c2ad1
+	.byte	0x10
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.byte	0x3
4c2ad1
+	.byte	0xc
4c2ad1
+	.uleb128 0x7
4c2ad1
+	.uleb128 0x8
4c2ad1
+	.byte	0x90
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.align 8
4c2ad1
+.LECIE1:
4c2ad1
+.LSFDE1:
4c2ad1
+	.long	.LEFDE1-.LASFDE1
4c2ad1
+.LASFDE1:
4c2ad1
+	.long	.LASFDE1-.Lframe1
4c2ad1
+	.long	.LFB2
4c2ad1
+	.long	.LFE2-.LFB2
4c2ad1
+	.uleb128 0x0
4c2ad1
+	.byte	0x4
4c2ad1
+	.long	.LCFI0-.LFB2
4c2ad1
+	.byte	0xe
4c2ad1
+	.uleb128 0x10
4c2ad1
+	.byte	0x86
4c2ad1
+	.uleb128 0x2
4c2ad1
+	.byte	0x4
4c2ad1
+	.long	.LCFI1-.LCFI0
4c2ad1
+	.byte	0xd
4c2ad1
+	.uleb128 0x6
4c2ad1
+	.align 8
4c2ad1
+.LEFDE1:
4c2ad1
+	.text
4c2ad1
+.Letext0:
4c2ad1
+	.section	.debug_loc,"",@progbits
4c2ad1
+.Ldebug_loc0:
4c2ad1
+.LLST0:
4c2ad1
+	.quad	.LFB2-.Ltext0
4c2ad1
+	.quad	.LCFI0-.Ltext0
4c2ad1
+	.value	0x2
4c2ad1
+	.byte	0x77
4c2ad1
+	.sleb128 8
4c2ad1
+	.quad	.LCFI0-.Ltext0
4c2ad1
+	.quad	.LCFI1-.Ltext0
4c2ad1
+	.value	0x2
4c2ad1
+	.byte	0x77
4c2ad1
+	.sleb128 16
4c2ad1
+	.quad	.LCFI1-.Ltext0
4c2ad1
+	.quad	.LFE2-.Ltext0
4c2ad1
+	.value	0x2
4c2ad1
+	.byte	0x76
4c2ad1
+	.sleb128 16
4c2ad1
+	.quad	0x0
4c2ad1
+	.quad	0x0
4c2ad1
+	.section	.debug_info
4c2ad1
+	.long	.Ldebug_end - .Ldebug_start
4c2ad1
+.Ldebug_start:
4c2ad1
+	.value	0x2
4c2ad1
+	.long	.Ldebug_abbrev0
4c2ad1
+	.byte	0x8
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.long	.LASF2
4c2ad1
+	.byte	0x1
4c2ad1
+	.long	.LASF3
4c2ad1
+	.long	.LASF4
4c2ad1
+	.quad	.Ltext0
4c2ad1
+	.quad	.Letext0
4c2ad1
+	.long	.Ldebug_line0
4c2ad1
+	.uleb128 0x2
4c2ad1
+	.byte	0x1
4c2ad1
+	.string	"foo"
4c2ad1
+	.byte	0x1
4c2ad1
+	.byte	0x16
4c2ad1
+	.byte	0x1
4c2ad1
+	.quad	.LFB2
4c2ad1
+	.quad	.LFE2
4c2ad1
+	.long	.LLST0
4c2ad1
+	.long	0x83
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.long	.LASF5
4c2ad1
+	.byte	0x1
4c2ad1
+	.byte	0x15
4c2ad1
+	.long	0x83
4c2ad1
+	.byte	0x2
4c2ad1
+	.byte	0x91
4c2ad1
+	.sleb128 -52
4c2ad1
+.Ltag_typedef:
4c2ad1
+	.uleb128 0x4
4c2ad1
+	.long	.LASF6
4c2ad1
+	.byte	0x1
4c2ad1
+	.byte	0x17
4c2ad1
+	.long	.Ltag_array_type - .debug_info
4c2ad1
+	.uleb128 0x5	/* Abbrev Number: 5 (DW_TAG_variable) */
4c2ad1
+	.long	.LASF0
4c2ad1
+	.byte	0x1
4c2ad1
+	.byte	0x18
4c2ad1
+#if 1
4c2ad1
+	.long	.Ltag_typedef - .debug_info
4c2ad1
+#else
4c2ad1
+	/* Debugging only: Skip the typedef indirection.  */
4c2ad1
+	.long	.Ltag_array_type - .debug_info
4c2ad1
+#endif
4c2ad1
+	/* DW_AT_location: DW_FORM_block1: start */
4c2ad1
+	.byte	0x3
4c2ad1
+	.byte	0x91
4c2ad1
+	.sleb128 -32
4c2ad1
+#if 0
4c2ad1
+	.byte	0x6	/* DW_OP_deref */
4c2ad1
+#else
4c2ad1
+	.byte	0x96	/* DW_OP_nop */
4c2ad1
+#endif
4c2ad1
+	/* DW_AT_location: DW_FORM_block1: end */
4c2ad1
+	.uleb128 0x6
4c2ad1
+	.string	"i"
4c2ad1
+	.byte	0x1
4c2ad1
+	.byte	0x19
4c2ad1
+	.long	0x83
4c2ad1
+	.byte	0x2
4c2ad1
+	.byte	0x91
4c2ad1
+	.sleb128 -20
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x7
4c2ad1
+	.byte	0x4
4c2ad1
+	.byte	0x5
4c2ad1
+	.string	"int"
4c2ad1
+.Ltag_array_type:
4c2ad1
+	.uleb128 0x8	/* Abbrev Number: 8 (DW_TAG_array_type) */
4c2ad1
+	.long	0xa0 + (2f - 1f)	/* DW_AT_type: DW_FORM_ref4 */
4c2ad1
+	.long	0x9d + (2f - 1f)	/* DW_AT_sibling: DW_FORM_ref4 */
4c2ad1
+1:	/* DW_AT_data_location: DW_FORM_block1: start */
4c2ad1
+	.byte	2f - 3f	/* length */
4c2ad1
+3:
4c2ad1
+	.byte	0x97	/* DW_OP_push_object_address */
4c2ad1
+	.byte	0x6	/* DW_OP_deref */
4c2ad1
+2:	/* DW_AT_data_location: DW_FORM_block1: end */
4c2ad1
+	.uleb128 0x9
4c2ad1
+	.long	0x9d + (2b - 1b)	/* DW_AT_type: DW_FORM_ref4 */
4c2ad1
+	.byte	0x3
4c2ad1
+	.byte	0x91
4c2ad1
+	.sleb128 -40
4c2ad1
+	.byte	0x6
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0xa
4c2ad1
+	.byte	0x8
4c2ad1
+	.byte	0x7
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.byte	0x1
4c2ad1
+	.byte	0x6
4c2ad1
+	.long	.LASF1
4c2ad1
+	.byte	0x0
4c2ad1
+.Ldebug_end:
4c2ad1
+	.section	.debug_abbrev
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.uleb128 0x11
4c2ad1
+	.byte	0x1
4c2ad1
+	.uleb128 0x25
4c2ad1
+	.uleb128 0xe
4c2ad1
+	.uleb128 0x13
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0xe
4c2ad1
+	.uleb128 0x1b
4c2ad1
+	.uleb128 0xe
4c2ad1
+	.uleb128 0x11
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.uleb128 0x12
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.uleb128 0x10
4c2ad1
+	.uleb128 0x6
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x2
4c2ad1
+	.uleb128 0x2e
4c2ad1
+	.byte	0x1
4c2ad1
+	.uleb128 0x3f
4c2ad1
+	.uleb128 0xc
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0x8
4c2ad1
+	.uleb128 0x3a
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3b
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x27
4c2ad1
+	.uleb128 0xc
4c2ad1
+	.uleb128 0x11
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.uleb128 0x12
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.uleb128 0x40
4c2ad1
+	.uleb128 0x6
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.uleb128 0x13
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0x5
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0xe
4c2ad1
+	.uleb128 0x3a
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3b
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x49
4c2ad1
+	.uleb128 0x13
4c2ad1
+	.uleb128 0x2
4c2ad1
+	.uleb128 0xa
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x4
4c2ad1
+	.uleb128 0x16
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0xe
4c2ad1
+	.uleb128 0x3a
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3b
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x49
4c2ad1
+	.uleb128 0x13
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x5
4c2ad1
+	.uleb128 0x34
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0xe
4c2ad1
+	.uleb128 0x3a
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3b
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x49
4c2ad1
+	.uleb128 0x13
4c2ad1
+	.uleb128 0x2
4c2ad1
+	.uleb128 0xa
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x6
4c2ad1
+	.uleb128 0x34
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0x8
4c2ad1
+	.uleb128 0x3a
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3b
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x49
4c2ad1
+	.uleb128 0x13
4c2ad1
+	.uleb128 0x2
4c2ad1
+	.uleb128 0xa
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x7
4c2ad1
+	.uleb128 0x24
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3e
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0x8
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x8	/* Abbrev Number: 8 (DW_TAG_array_type) */
4c2ad1
+	.uleb128 0x1
4c2ad1
+	.byte	0x1
4c2ad1
+	.uleb128 0x49	/* DW_AT_type */
4c2ad1
+	.uleb128 0x13	/* DW_FORM_ref4 */
4c2ad1
+	.uleb128 0x1	/* DW_AT_sibling */
4c2ad1
+	.uleb128 0x13	/* DW_FORM_ref4 */
4c2ad1
+	.uleb128 0x50	/* DW_AT_data_location */
4c2ad1
+	.uleb128 0xa	/* DW_FORM_block1 */
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x9
4c2ad1
+	.uleb128 0x21
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x49	/* DW_AT_type */
4c2ad1
+	.uleb128 0x13	/* DW_FORM_ref4 */
4c2ad1
+	.uleb128 0x2f
4c2ad1
+	.uleb128 0xa
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0xa
4c2ad1
+	.uleb128 0x24
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3e
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x24
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3e
4c2ad1
+	.uleb128 0xb
4c2ad1
+	.uleb128 0x3
4c2ad1
+	.uleb128 0xe
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.section	.debug_pubnames,"",@progbits
4c2ad1
+	.long	0x16
4c2ad1
+	.value	0x2
4c2ad1
+	.long	.Ldebug_info0
4c2ad1
+	.long	0xa8
4c2ad1
+	.long	0x2d
4c2ad1
+	.string	"foo"
4c2ad1
+	.long	0x0
4c2ad1
+	.section	.debug_aranges,"",@progbits
4c2ad1
+	.long	0x2c
4c2ad1
+	.value	0x2
4c2ad1
+	.long	.Ldebug_info0
4c2ad1
+	.byte	0x8
4c2ad1
+	.byte	0x0
4c2ad1
+	.value	0x0
4c2ad1
+	.value	0x0
4c2ad1
+	.quad	.Ltext0
4c2ad1
+	.quad	.Letext0-.Ltext0
4c2ad1
+	.quad	0x0
4c2ad1
+	.quad	0x0
4c2ad1
+	.section	.debug_str,"MS",@progbits,1
4c2ad1
+.LASF0:
4c2ad1
+	.string	"array"
4c2ad1
+.LASF5:
4c2ad1
+	.string	"size"
4c2ad1
+.LASF3:
4c2ad1
+	.string	"x86_64-vla-typedef.c"
4c2ad1
+.LASF6:
4c2ad1
+	.string	"array_t"
4c2ad1
+.LASF1:
4c2ad1
+	.string	"char"
4c2ad1
+.LASF4:
4c2ad1
+	.string	"gdb.arch"
4c2ad1
+.LASF2:
4c2ad1
+	.string	"GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
4c2ad1
+	.ident	"GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
4c2ad1
+	.section	.note.GNU-stack,"",@progbits
4c2ad1
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
4c2ad1
@@ -0,0 +1,45 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2008 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+#if 0
4c2ad1
+
4c2ad1
+void
4c2ad1
+foo (int size)
4c2ad1
+{
4c2ad1
+  typedef char array_t[size];
4c2ad1
+  array_t array;
4c2ad1
+  int i;
4c2ad1
+
4c2ad1
+  for (i = 0; i < size; i++)
4c2ad1
+    array[i] = i;
4c2ad1
+
4c2ad1
+  array[0] = 0;	/* break-here */
4c2ad1
+}
4c2ad1
+
4c2ad1
+#else
4c2ad1
+
4c2ad1
+void foo (int size);
4c2ad1
+
4c2ad1
+int
4c2ad1
+main (void)
4c2ad1
+{
4c2ad1
+  foo (26);
4c2ad1
+  foo (78);
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
+
4c2ad1
+#endif
4c2ad1
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
4c2ad1
@@ -0,0 +1,64 @@
4c2ad1
+# Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
4c2ad1
+
4c2ad1
+if ![istarget "x86_64-*-*"] then {
4c2ad1
+    verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
4c2ad1
+    return
4c2ad1
+}
4c2ad1
+
4c2ad1
+set testfile x86_64-vla-typedef
4c2ad1
+set srcasmfile ${testfile}-foo.S
4c2ad1
+set srcfile ${testfile}.c
4c2ad1
+set binfile [standard_output_file ${testfile}]
4c2ad1
+set binobjfile [standard_output_file ${testfile}-foo.o]
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
4c2ad1
+    untested "Couldn't compile test program"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
4c2ad1
+    untested "Couldn't compile test program"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+if ![runto_main] {
4c2ad1
+    untested x86_64-vla-typedef
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_breakpoint "break_here"
4c2ad1
+
4c2ad1
+gdb_continue_to_breakpoint "break_here"
4c2ad1
+
4c2ad1
+gdb_test "whatis array" "type = array_t" "first: whatis array"
4c2ad1
+
4c2ad1
+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
4c2ad1
+
4c2ad1
+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
4c2ad1
+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
4c2ad1
+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
4c2ad1
+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
4c2ad1
+
4c2ad1
+gdb_continue_to_breakpoint "break_here"
4c2ad1
+
4c2ad1
+gdb_test "whatis array" "type = array_t" "second: whatis array"
4c2ad1
+
4c2ad1
+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
4c2ad1
diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c
4c2ad1
--- a/gdb/testsuite/gdb.base/arrayidx.c
4c2ad1
+++ b/gdb/testsuite/gdb.base/arrayidx.c
4c2ad1
@@ -17,6 +17,13 @@
4c2ad1
 
4c2ad1
 int array[] = {1, 2, 3, 4};
4c2ad1
 
4c2ad1
+#ifdef __GNUC__
4c2ad1
+struct
4c2ad1
+  {
4c2ad1
+    int a[0];
4c2ad1
+  } unbound;
4c2ad1
+#endif
4c2ad1
+
4c2ad1
 int
4c2ad1
 main (void)
4c2ad1
 {
4c2ad1
diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
4c2ad1
--- a/gdb/testsuite/gdb.base/arrayidx.exp
4c2ad1
+++ b/gdb/testsuite/gdb.base/arrayidx.exp
4c2ad1
@@ -49,4 +49,12 @@ gdb_test "print array" \
4c2ad1
          "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
4c2ad1
          "print array with array-indexes on"
4c2ad1
 
4c2ad1
-
4c2ad1
+set test "p unbound.a == &unbound.a\[0\]"
4c2ad1
+gdb_test_multiple $test $test {
4c2ad1
+    -re " = 1\r\n$gdb_prompt $" {
4c2ad1
+	pass $test
4c2ad1
+    }
4c2ad1
+    -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
4c2ad1
+	unsupported "$test (no GCC)"
4c2ad1
+    }
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.base/internal-var-field-address.c
4c2ad1
@@ -0,0 +1,20 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+struct {
4c2ad1
+  int field;
4c2ad1
+} staticstruct = { 1 };
4c2ad1
diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp
4c2ad1
@@ -0,0 +1,26 @@
4c2ad1
+# Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+set test internal-var-field-address
4c2ad1
+set binfile ${test}.x
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${test}.c" "[standard_output_file ${binfile}]" object {debug}] != "" } {
4c2ad1
+    untested "Couldn't compile test program"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+clean_restart $binfile
4c2ad1
+
4c2ad1
+gdb_test {set $varstruct = staticstruct}
4c2ad1
+gdb_test {p $varstruct.field} " = 1"
4c2ad1
diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.base/vla-frame.c
4c2ad1
@@ -0,0 +1,31 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2011 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+#include <string.h>
4c2ad1
+
4c2ad1
+int
4c2ad1
+main (int argc, char **argv)
4c2ad1
+{
4c2ad1
+  char s[2 + argc];
4c2ad1
+  void (*f) (char *) = 0;
4c2ad1
+
4c2ad1
+  memset (s, 0, sizeof (s));
4c2ad1
+  s[0] = 'X';
4c2ad1
+
4c2ad1
+  f (s);
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.base/vla-frame.exp
4c2ad1
@@ -0,0 +1,38 @@
4c2ad1
+# Copyright 2011 Free Software Foundation, Inc.
4c2ad1
+#
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+set testfile vla-frame
4c2ad1
+set executable ${testfile}
4c2ad1
+
4c2ad1
+if { [prepare_for_testing ${testfile}.exp ${executable}] } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+if ![runto_main] {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+set test "continue"
4c2ad1
+gdb_test_multiple $test $test {
4c2ad1
+    -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" {
4c2ad1
+	pass $test
4c2ad1
+    }
4c2ad1
+    -re "\r\n$gdb_prompt $" {
4c2ad1
+	untested ${testfile}.exp
4c2ad1
+	return
4c2ad1
+    }
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*"
4c2ad1
diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.base/vla-overflow.c
4c2ad1
@@ -0,0 +1,30 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2008 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+#include <stdlib.h>
4c2ad1
+
4c2ad1
+int
4c2ad1
+main (int argc, char **argv)
4c2ad1
+{
4c2ad1
+  int array[argc];
4c2ad1
+
4c2ad1
+  array[0] = array[0];
4c2ad1
+
4c2ad1
+  abort ();
4c2ad1
+
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.base/vla-overflow.exp
4c2ad1
@@ -0,0 +1,109 @@
4c2ad1
+# Copyright 2008 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+# We could crash in:
4c2ad1
+# #0  block_linkage_function (bl=0x0) at ../../gdb/block.c:69
4c2ad1
+# #1  in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97
4c2ad1
+#   97	  framefunc = block_linkage_function (get_frame_block (frame, NULL));
4c2ad1
+# #2  in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496
4c2ad1
+# #3  in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156
4c2ad1
+# #4  dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206
4c2ad1
+# #5  in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430
4c2ad1
+# #6  in create_array_type (...) at ../../gdb/gdbtypes.c:840
4c2ad1
+# ...
4c2ad1
+# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
4c2ad1
+# ...
4c2ad1
+# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
4c2ad1
+
4c2ad1
+set testfile vla-overflow
4c2ad1
+set shfile [standard_output_file ${testfile}-gdb.sh]
4c2ad1
+set srcfile ${testfile}.c
4c2ad1
+set binfile [standard_output_file ${testfile}]
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
4c2ad1
+    untested "Couldn't compile test program"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+set f [open "|getconf PAGESIZE" "r"]
4c2ad1
+gets $f pagesize
4c2ad1
+close $f
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
4c2ad1
+
4c2ad1
+if { [runto_main] < 0 } {
4c2ad1
+    untested vla-overflow
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+# Get the GDB memory size when we stay at main.
4c2ad1
+
4c2ad1
+proc memory_v_pages_get {} {
4c2ad1
+    global pid_of_gdb pagesize
4c2ad1
+    set fd [open "/proc/$pid_of_gdb/statm"]
4c2ad1
+    gets $fd line
4c2ad1
+    close $fd
4c2ad1
+    # number of pages of virtual memory
4c2ad1
+    scan $line "%d" drs
4c2ad1
+    return $drs
4c2ad1
+}
4c2ad1
+
4c2ad1
+set pages_found [memory_v_pages_get]
4c2ad1
+
4c2ad1
+# s390x with glibc-debuginfo.s390x installed used approx. 16MB.
4c2ad1
+set mb_reserve 40
4c2ad1
+verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve"
4c2ad1
+set kb_found [expr $pages_found * $pagesize / 1024]
4c2ad1
+set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024]
4c2ad1
+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
4c2ad1
+
4c2ad1
+# Create the ulimit wrapper.
4c2ad1
+set f [open $shfile "w"]
4c2ad1
+puts $f "#! /bin/sh"
4c2ad1
+puts $f "ulimit -v $kb_permit"
4c2ad1
+puts $f "exec $GDB \"\$@\""
4c2ad1
+close $f
4c2ad1
+remote_exec host "chmod +x $shfile"
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+set GDBold $GDB
4c2ad1
+set GDB "$shfile"
4c2ad1
+gdb_start
4c2ad1
+set GDB $GDBold
4c2ad1
+
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
4c2ad1
+
4c2ad1
+# Check the size again after the second run.
4c2ad1
+# We must not stop in main as it would cache `array' and never crash later.
4c2ad1
+
4c2ad1
+gdb_run_cmd
4c2ad1
+
4c2ad1
+verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
4c2ad1
+
4c2ad1
+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
4c2ad1
+
4c2ad1
+verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
4c2ad1
+
4c2ad1
+# `abort' can get expressed as `*__GI_abort'.
4c2ad1
+gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
4c2ad1
+
4c2ad1
+verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
4c2ad1
diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.base/vla.c
4c2ad1
@@ -0,0 +1,55 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2008 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+#include <string.h>
4c2ad1
+
4c2ad1
+void
4c2ad1
+marker (void)
4c2ad1
+{
4c2ad1
+}
4c2ad1
+
4c2ad1
+void
4c2ad1
+bar (char *a, char *b, char *c, int size)
4c2ad1
+{
4c2ad1
+  memset (a, '1', size);
4c2ad1
+  memset (b, '2', size);
4c2ad1
+  memset (c, '3', 48);
4c2ad1
+}
4c2ad1
+
4c2ad1
+void
4c2ad1
+foo (int size)
4c2ad1
+{
4c2ad1
+  char temp1[size];
4c2ad1
+  char temp3[48];
4c2ad1
+
4c2ad1
+  temp1[size - 1] = '\0';
4c2ad1
+  {
4c2ad1
+    char temp2[size];
4c2ad1
+
4c2ad1
+    bar (temp1, temp2, temp3, size);
4c2ad1
+
4c2ad1
+    marker ();	/* break-here */
4c2ad1
+  }
4c2ad1
+}
4c2ad1
+
4c2ad1
+int
4c2ad1
+main (void)
4c2ad1
+{
4c2ad1
+  foo (26);
4c2ad1
+  foo (78);
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.base/vla.exp
4c2ad1
@@ -0,0 +1,62 @@
4c2ad1
+# Copyright 2008 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+set testfile vla
4c2ad1
+set srcfile ${testfile}.c
4c2ad1
+set binfile [standard_output_file ${testfile}]
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
4c2ad1
+    untested "Couldn't compile test program"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+if ![runto_main] {
4c2ad1
+    untested vla
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "break-here"]
4c2ad1
+
4c2ad1
+gdb_continue_to_breakpoint "break-here"
4c2ad1
+
4c2ad1
+gdb_test "whatis temp1" "type = char \\\[26\\\]" "first: whatis temp1"
4c2ad1
+gdb_test "whatis temp2" "type = char \\\[26\\\]" "first: whatis temp2"
4c2ad1
+gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
4c2ad1
+
4c2ad1
+gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
4c2ad1
+gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
4c2ad1
+gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
4c2ad1
+
4c2ad1
+gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
4c2ad1
+gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
4c2ad1
+gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
4c2ad1
+
4c2ad1
+gdb_continue_to_breakpoint "break-here"
4c2ad1
+
4c2ad1
+gdb_test "whatis temp1" "type = char \\\[78\\\]" "second: whatis temp1"
4c2ad1
+gdb_test "whatis temp2" "type = char \\\[78\\\]" "second: whatis temp2"
4c2ad1
+gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
4c2ad1
+
4c2ad1
+gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
4c2ad1
+gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
4c2ad1
+gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
4c2ad1
+
4c2ad1
+gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
4c2ad1
+gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
4c2ad1
+gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
4c2ad1
diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.cp/gdb9593.cc
4c2ad1
@@ -0,0 +1,180 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2008, 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+   */
4c2ad1
+#include <iostream>
4c2ad1
+
4c2ad1
+using namespace std;
4c2ad1
+
4c2ad1
+class NextOverThrowDerivates
4c2ad1
+{
4c2ad1
+
4c2ad1
+public:
4c2ad1
+
4c2ad1
+
4c2ad1
+  // Single throw an exception in this function.
4c2ad1
+  void function1() 
4c2ad1
+  {
4c2ad1
+    throw 20;
4c2ad1
+  }
4c2ad1
+
4c2ad1
+  // Throw an exception in another function.
4c2ad1
+  void function2() 
4c2ad1
+  {
4c2ad1
+    function1();
4c2ad1
+  }
4c2ad1
+
4c2ad1
+  // Throw an exception in another function, but handle it
4c2ad1
+  // locally.
4c2ad1
+  void function3 () 
4c2ad1
+  {
4c2ad1
+    {
4c2ad1
+      try
4c2ad1
+	{
4c2ad1
+	  function1 ();
4c2ad1
+	}
4c2ad1
+      catch (...) 
4c2ad1
+	{
4c2ad1
+	  cout << "Caught and handled function1 exception" << endl;
4c2ad1
+	}
4c2ad1
+    }
4c2ad1
+  }
4c2ad1
+
4c2ad1
+  void rethrow ()
4c2ad1
+  {
4c2ad1
+    try
4c2ad1
+      {
4c2ad1
+	function1 ();
4c2ad1
+      }
4c2ad1
+    catch (...)
4c2ad1
+      {
4c2ad1
+	throw;
4c2ad1
+      }
4c2ad1
+  }
4c2ad1
+
4c2ad1
+  void finish ()
4c2ad1
+  {
4c2ad1
+    // We use this to test that a "finish" here does not end up in
4c2ad1
+    // this frame, but in the one above.
4c2ad1
+    try
4c2ad1
+      {
4c2ad1
+	function1 ();
4c2ad1
+      }
4c2ad1
+    catch (int x)
4c2ad1
+      {
4c2ad1
+      }
4c2ad1
+    function1 ();		// marker for until
4c2ad1
+  }
4c2ad1
+
4c2ad1
+  void until ()
4c2ad1
+  {
4c2ad1
+    function1 ();
4c2ad1
+    function1 ();		// until here
4c2ad1
+  }
4c2ad1
+
4c2ad1
+};
4c2ad1
+NextOverThrowDerivates next_cases;
4c2ad1
+
4c2ad1
+
4c2ad1
+int main () 
4c2ad1
+{ 
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      next_cases.function1 ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+      // Discard
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      next_cases.function2 ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+      // Discard
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      // This is duplicated so we can next over one but step into
4c2ad1
+      // another.
4c2ad1
+      next_cases.function2 ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+      // Discard
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  next_cases.function3 ();
4c2ad1
+
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      next_cases.rethrow ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+      // Discard
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      // Another duplicate so we can test "finish".
4c2ad1
+      next_cases.function2 ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+      // Discard
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  // Another test for "finish".
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      next_cases.finish ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  // Test of "until".
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      next_cases.finish ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  // Test of "until" with an argument.
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      next_cases.until ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+    }
4c2ad1
+
4c2ad1
+  // Test of "advance".
4c2ad1
+  try
4c2ad1
+    {
4c2ad1
+      next_cases.until ();
4c2ad1
+    }
4c2ad1
+  catch (...)
4c2ad1
+    {
4c2ad1
+    }
4c2ad1
+}
4c2ad1
+
4c2ad1
diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.cp/gdb9593.exp
4c2ad1
@@ -0,0 +1,182 @@
4c2ad1
+# Copyright 2008, 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+
4c2ad1
+if $tracelevel then {
4c2ad1
+    strace $tracelevel
4c2ad1
+}
4c2ad1
+
4c2ad1
+if { [skip_cplus_tests] } { continue }
4c2ad1
+
4c2ad1
+set testfile "gdb9593"
4c2ad1
+set srcfile ${testfile}.cc
4c2ad1
+set binfile [standard_output_file $testfile]
4c2ad1
+
4c2ad1
+# Create and source the file that provides information about the compiler
4c2ad1
+# used to compile the test case.
4c2ad1
+if [get_compiler_info "c++"] {
4c2ad1
+    untested gdb9593.exp
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
4c2ad1
+    untested gdb9593.exp
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+# Some targets can't do function calls, so don't even bother with this
4c2ad1
+# test.
4c2ad1
+if [target_info exists gdb,cannot_call_functions] {
4c2ad1
+    setup_xfail "*-*-*" 9593
4c2ad1
+    fail "This target can not call functions"
4c2ad1
+    continue
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+if ![runto_main] then {
4c2ad1
+    perror "couldn't run to main"
4c2ad1
+    continue
4c2ad1
+} 
4c2ad1
+
4c2ad1
+# See whether we have the needed unwinder hooks.
4c2ad1
+set ok 1
4c2ad1
+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
4c2ad1
+    -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
4c2ad1
+	pass "check for unwinder hook"
4c2ad1
+    }
4c2ad1
+    -re "No symbol .* in current context.\r\n$gdb_prompt $" {
4c2ad1
+	# Pass the test so we don't get bogus fails in the results.
4c2ad1
+	pass "check for unwinder hook"
4c2ad1
+	set ok 0
4c2ad1
+    }
4c2ad1
+}
4c2ad1
+if {!$ok} {
4c2ad1
+    untested gdb9593.exp
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+    ".*catch (...).*" \
4c2ad1
+    "next over a throw 1"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.function2.*" \
4c2ad1
+  "next past catch 1"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+    ".*catch (...).*" \
4c2ad1
+    "next over a throw 2"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.function2.*" \
4c2ad1
+  "next past catch 2"
4c2ad1
+
4c2ad1
+gdb_test "step" \
4c2ad1
+  ".*function1().*" \
4c2ad1
+  "step into function2 1"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+    ".*catch (...).*" \
4c2ad1
+    "next over a throw 3"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.function3.*" \
4c2ad1
+  "next past catch 3"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.rethrow.*" \
4c2ad1
+    "next over a throw 4"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*catch (...).*" \
4c2ad1
+  "next over a rethrow"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.function2.*" \
4c2ad1
+  "next after a rethrow"
4c2ad1
+
4c2ad1
+gdb_test "step" \
4c2ad1
+  ".*function1().*" \
4c2ad1
+  "step into function2 2"
4c2ad1
+
4c2ad1
+gdb_test "finish" \
4c2ad1
+  ".*catch (...).*" \
4c2ad1
+  "finish 1"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.finish ().*" \
4c2ad1
+  "next past catch 4"
4c2ad1
+
4c2ad1
+gdb_test "step" \
4c2ad1
+  ".*function1 ().*" \
4c2ad1
+  "step into finish method"
4c2ad1
+
4c2ad1
+gdb_test "finish" \
4c2ad1
+  ".*catch (...).*" \
4c2ad1
+  "finish 2"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.finish ().*" \
4c2ad1
+  "next past catch 5"
4c2ad1
+
4c2ad1
+gdb_test "step" \
4c2ad1
+  ".*function1 ().*" \
4c2ad1
+  "step into finish, for until"
4c2ad1
+
4c2ad1
+gdb_test "until" \
4c2ad1
+  ".*function1 ().*" \
4c2ad1
+  "until with no argument 1"
4c2ad1
+
4c2ad1
+set line [gdb_get_line_number "marker for until" $testfile.cc]
4c2ad1
+
4c2ad1
+gdb_test "until $line" \
4c2ad1
+  ".*function1 ().*" \
4c2ad1
+  "next past catch 6"
4c2ad1
+
4c2ad1
+gdb_test "until" \
4c2ad1
+  ".*catch (...).*" \
4c2ad1
+  "until with no argument 2"
4c2ad1
+
4c2ad1
+set line [gdb_get_line_number "until here" $testfile.cc]
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.until ().*" \
4c2ad1
+  "next past catch 6"
4c2ad1
+
4c2ad1
+gdb_test "step" \
4c2ad1
+  ".*function1 ().*" \
4c2ad1
+  "step into until"
4c2ad1
+
4c2ad1
+gdb_test "until $line" \
4c2ad1
+  ".*catch (...).*" \
4c2ad1
+  "until-over-throw"
4c2ad1
+
4c2ad1
+gdb_test "next" \
4c2ad1
+  ".*next_cases.until ().*" \
4c2ad1
+  "next past catch 7"
4c2ad1
+
4c2ad1
+gdb_test "step" \
4c2ad1
+  ".*function1 ().*" \
4c2ad1
+  "step into until, for advance"
4c2ad1
+
4c2ad1
+gdb_test "advance $line" \
4c2ad1
+  ".*catch (...).*" \
4c2ad1
+  "advance-over-throw"
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
4c2ad1
@@ -0,0 +1,246 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2010 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+/* Debug information */
4c2ad1
+
4c2ad1
+/* We will `break *main' at the very first instruction.  */
4c2ad1
+#define main_length 1
4c2ad1
+
4c2ad1
+	.section	.data
4c2ad1
+vardata:
4c2ad1
+	/* See DW_OP_lit3 + 1 (0-based).  */
4c2ad1
+	.string		"seennotseen"
4c2ad1
+
4c2ad1
+	.section	.debug_info
4c2ad1
+.Lcu1_begin:
4c2ad1
+	.4byte		.Lcu1_end - .Lcu1_start	/* Length of Compilation Unit */
4c2ad1
+.Lcu1_start:
4c2ad1
+	.2byte		2			/* DWARF version number */
4c2ad1
+	.4byte		.Ldebug_abbrev0		/* Offset Into Abbrev. Section */
4c2ad1
+	.byte		4			/* Pointer Size (in bytes) */
4c2ad1
+
4c2ad1
+	/* CU die */
4c2ad1
+	.uleb128	1			/* Abbrev: DW_TAG_compile_unit */
4c2ad1
+	.4byte		.Lproducer		/* DW_AT_producer */
4c2ad1
+	/* Use C++ to exploit a bug in parsing DW_AT_name "".  */
4c2ad1
+	.byte		4			/* DW_AT_language (C++) -  */
4c2ad1
+	.4byte		main			/* DW_AT_low_pc */
4c2ad1
+	.byte		main_length		/* DW_AT_high_pc */
4c2ad1
+
4c2ad1
+.Larray_type:
4c2ad1
+	.uleb128	2			/* Abbrev: DW_TAG_array_type */
4c2ad1
+	.4byte		.Lchar_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+
4c2ad1
+	.uleb128	3			/* Abbrev: DW_TAG_subrange_type */
4c2ad1
+	.4byte		.Luint_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+	.byte		0			/* DW_AT_lower_bound */
4c2ad1
+	.4byte		.Llen_var-.Lcu1_begin	/* DW_AT_upper_bound */
4c2ad1
+	.byte		0			/* End of children of die */
4c2ad1
+
4c2ad1
+	/* DW_AT_upper_bound is referencing an optimized-out variable.  */
4c2ad1
+.Larrayb_type:
4c2ad1
+	.uleb128	2			/* Abbrev: DW_TAG_array_type */
4c2ad1
+	.4byte		.Lchar_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+
4c2ad1
+	.uleb128	3			/* Abbrev: DW_TAG_subrange_type */
4c2ad1
+	.4byte		.Luint_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+	.byte		0			/* DW_AT_lower_bound */
4c2ad1
+	.4byte		.Llenb_var-.Lcu1_begin	/* DW_AT_upper_bound */
4c2ad1
+	.byte		0			/* End of children of die */
4c2ad1
+
4c2ad1
+	/* DW_AT_upper_bound is referencing register.  */
4c2ad1
+.Larrayreg_type:
4c2ad1
+	.uleb128	2			/* Abbrev: DW_TAG_array_type */
4c2ad1
+	.4byte		.Lchar_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+
4c2ad1
+	.uleb128	8			/* Abbrev: DW_TAG_subrange_type with block */
4c2ad1
+	.4byte		.Luint_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+	.byte		0			/* DW_AT_lower_bound */
4c2ad1
+	.byte		2f - 1f			/* DW_AT_upper_bound */
4c2ad1
+1:	.byte		0x50			/* DW_OP_reg0 */
4c2ad1
+2:
4c2ad1
+	.byte		0			/* End of children of die */
4c2ad1
+
4c2ad1
+.Luint_type:
4c2ad1
+	.uleb128	4			/* Abbrev: DW_TAG_base_type */
4c2ad1
+	.4byte		.Luint_str		/* DW_AT_name */
4c2ad1
+	.byte		4			/* DW_AT_byte_size */
4c2ad1
+	.byte		7			/* DW_AT_encoding */
4c2ad1
+
4c2ad1
+.Lchar_type:
4c2ad1
+	.uleb128	4			/* Abbrev: DW_TAG_base_type */
4c2ad1
+	.4byte		.Lchar_str		/* DW_AT_name */
4c2ad1
+	.byte		1			/* DW_AT_byte_size */
4c2ad1
+	.byte		6			/* DW_AT_encoding */
4c2ad1
+
4c2ad1
+.Llen_var:
4c2ad1
+	.uleb128	5			/* Abbrev: DW_TAG_variable artificial */
4c2ad1
+	.byte		1			/* DW_AT_artificial */
4c2ad1
+	.4byte		.Luint_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+	.4byte		.Llen_loclist-.Lloclist	/* DW_AT_location */
4c2ad1
+
4c2ad1
+	/* optimized-out variable for b_string.  */
4c2ad1
+.Llenb_var:
4c2ad1
+	.uleb128	7			/* Abbrev: DW_TAG_variable artificial no DW_AT_location */
4c2ad1
+	.byte		1			/* DW_AT_artificial */
4c2ad1
+	.4byte		.Luint_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+
4c2ad1
+	.uleb128	6			/* Abbrev: DW_TAG_variable DW_FORM_string */
4c2ad1
+	.string		"a_string"		/* DW_AT_name */
4c2ad1
+	.4byte		.Larray_type-.Lcu1_begin /* DW_AT_type */
4c2ad1
+	.byte		2f - 1f			/* DW_AT_location */
4c2ad1
+1:	.byte		3			/*   DW_OP_addr */
4c2ad1
+	.4byte		vardata			/*   <addr> */
4c2ad1
+2:
4c2ad1
+
4c2ad1
+	/* DW_AT_upper_bound is referencing an optimized-out variable.  */
4c2ad1
+	.uleb128	6			/* Abbrev: DW_TAG_variable DW_FORM_string */
4c2ad1
+	.string		"b_string"		/* DW_AT_name */
4c2ad1
+	.4byte		.Larrayb_type-.Lcu1_begin /* DW_AT_type */
4c2ad1
+	.byte		2f - 1f			/* DW_AT_location */
4c2ad1
+1:	.byte		3			/*   DW_OP_addr */
4c2ad1
+	.4byte		vardata			/*   <addr> */
4c2ad1
+2:
4c2ad1
+
4c2ad1
+	/* DW_AT_upper_bound is referencing register.  */
4c2ad1
+	.uleb128	6			/* Abbrev: DW_TAG_variable DW_FORM_string */
4c2ad1
+	.string		"reg_string"		/* DW_AT_name */
4c2ad1
+	.4byte		.Larrayreg_type-.Lcu1_begin /* DW_AT_type */
4c2ad1
+	.byte		2f - 1f			/* DW_AT_location */
4c2ad1
+1:	.byte		3			/*   DW_OP_addr */
4c2ad1
+	.4byte		vardata			/*   <addr> */
4c2ad1
+2:
4c2ad1
+
4c2ad1
+	.byte		0			/* End of children of CU */
4c2ad1
+.Lcu1_end:
4c2ad1
+
4c2ad1
+	.section	.debug_loc
4c2ad1
+.Lloclist:
4c2ad1
+.Llen_loclist:
4c2ad1
+	.4byte	0			# Location list begin address
4c2ad1
+	.4byte	main_length		# Location list end address
4c2ad1
+	.value	2f-1f	# Location expression size
4c2ad1
+1:	.byte	0x33	# DW_OP_lit3
4c2ad1
+	.byte	0x9f	# DW_OP_stack_value
4c2ad1
+2:
4c2ad1
+	.quad	0x0	# Location list terminator begin (*.LLST2)
4c2ad1
+	.quad	0x0	# Location list terminator end (*.LLST2)
4c2ad1
+
4c2ad1
+	.section .debug_abbrev
4c2ad1
+.Ldebug_abbrev0:
4c2ad1
+	.uleb128	1			/* Abbrev code */
4c2ad1
+	.uleb128	0x11			/* DW_TAG_compile_unit */
4c2ad1
+	.byte		0x1			/* has_children */
4c2ad1
+	.uleb128	0x25			/* DW_AT_producer */
4c2ad1
+	.uleb128	0xe			/* DW_FORM_strp */
4c2ad1
+	.uleb128	0x13			/* DW_AT_language */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.uleb128	0x11			/* DW_AT_low_pc */
4c2ad1
+	.uleb128	0x1			/* DW_FORM_addr */
4c2ad1
+	.uleb128	0x12			/* DW_AT_high_pc */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	2			/* Abbrev code */
4c2ad1
+	.uleb128	0x1			/* TAG: DW_TAG_array_type */
4c2ad1
+	.byte		0x1			/* DW_children_yes */
4c2ad1
+	.uleb128	0x49			/* DW_AT_type */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	3			/* Abbrev code */
4c2ad1
+	.uleb128	0x21			/* DW_TAG_subrange_type */
4c2ad1
+	.byte		0x0			/* no children */
4c2ad1
+	.uleb128	0x49			/* DW_AT_type */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.uleb128	0x22			/* DW_AT_lower_bound */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.uleb128	0x2f			/* DW_AT_upper_bound */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	4			/* Abbrev code */
4c2ad1
+	.uleb128	0x24			/* DW_TAG_base_type */
4c2ad1
+	.byte		0x0			/* no_children */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0xe			/* DW_FORM_strp */
4c2ad1
+	.uleb128	0xb			/* DW_AT_byte_size */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.uleb128	0x3e			/* DW_AT_encoding */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	5			/* Abbrev code */
4c2ad1
+	.uleb128	0x34			/* DW_TAG_variable */
4c2ad1
+	.byte		0x0			/* no_children */
4c2ad1
+	.uleb128	0x34			/* DW_AT_artificial */
4c2ad1
+	.uleb128	0x0c			/* DW_FORM_flag */
4c2ad1
+	.uleb128	0x49			/* DW_AT_type */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.uleb128	0x02			/* DW_AT_location */
4c2ad1
+	.uleb128	0x06			/* DW_FORM_data4 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	6			/* Abbrev code */
4c2ad1
+	.uleb128	0x34			/* DW_TAG_variable */
4c2ad1
+	.byte		0x0			/* no_children */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0x49			/* DW_AT_type */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.uleb128	0x2			/* DW_AT_location */
4c2ad1
+	.uleb128	0xa			/* DW_FORM_block1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	7			/* Abbrev code */
4c2ad1
+	.uleb128	0x34			/* DW_TAG_variable */
4c2ad1
+	.byte		0x0			/* no_children */
4c2ad1
+	.uleb128	0x34			/* DW_AT_artificial */
4c2ad1
+	.uleb128	0x0c			/* DW_FORM_flag */
4c2ad1
+	.uleb128	0x49			/* DW_AT_type */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	8			/* Abbrev code */
4c2ad1
+	.uleb128	0x21			/* DW_TAG_subrange_type with block */
4c2ad1
+	.byte		0x0			/* no children */
4c2ad1
+	.uleb128	0x49			/* DW_AT_type */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.uleb128	0x22			/* DW_AT_lower_bound */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.uleb128	0x2f			/* DW_AT_upper_bound */
4c2ad1
+	.uleb128	0xa			/* DW_FORM_block1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+/* String table */
4c2ad1
+	.section .debug_str
4c2ad1
+.Lproducer:
4c2ad1
+	.string		"GNU C 3.3.3"
4c2ad1
+.Lchar_str:
4c2ad1
+	.string		"char"
4c2ad1
+.Luint_str:
4c2ad1
+	.string		"unsigned int"
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
4c2ad1
@@ -0,0 +1,66 @@
4c2ad1
+# Copyright 2010 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+# Test printing variable with dynamic bounds which reference a different
4c2ad1
+# (artificial in the GCC case) variable containing loclist as its location.
4c2ad1
+# This testcase uses value (not address) of the referenced variable:
4c2ad1
+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
4c2ad1
+
4c2ad1
+# This test can only be run on targets which support DWARF-2 and use gas.
4c2ad1
+# For now pick a sampling of likely targets.
4c2ad1
+if {![istarget *-*-linux*]
4c2ad1
+    && ![istarget *-*-gnu*]
4c2ad1
+    && ![istarget *-*-elf*]
4c2ad1
+    && ![istarget *-*-openbsd*]
4c2ad1
+    && ![istarget arm-*-eabi*]
4c2ad1
+    && ![istarget powerpc-*-eabi*]} {
4c2ad1
+    return 0
4c2ad1
+}
4c2ad1
+
4c2ad1
+set testfile dw2-bound-loclist
4c2ad1
+if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+# Verify it behaves at least as an unbound array without inferior.
4c2ad1
+
4c2ad1
+# FIXME: FSF GDB crashes due to !has_stack_frames ().
4c2ad1
+# But in practice that should not happen.
4c2ad1
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
4c2ad1
+#set test "p a_string"
4c2ad1
+#gdb_test_multiple $test $test {
4c2ad1
+#    -re " = 0x\[0-9a-f\]+ \"seennotseen\"\r\n$gdb_prompt $" {
4c2ad1
+#	pass $test
4c2ad1
+#    }
4c2ad1
+#    -re "No registers\\.\r\n$gdb_prompt $" {
4c2ad1
+#	kfail "vlaregression" $test
4c2ad1
+#    }
4c2ad1
+#}
4c2ad1
+#
4c2ad1
+#gdb_test "ptype a_string" {type = char \[variable length\]}
4c2ad1
+
4c2ad1
+# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
4c2ad1
+if ![runto "*main"] {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_test "p a_string" { = "seen"}
4c2ad1
+gdb_test "ptype a_string" {type = char \[4\]}
4c2ad1
+
4c2ad1
+gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
4c2ad1
+gdb_test "ptype b_string" {type = char \[\]}
4c2ad1
+
4c2ad1
+# The register contains unpredictable value - the array size.
4c2ad1
+gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]}
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
4c2ad1
@@ -0,0 +1,42 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2004 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 2 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+ 
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program; if not, write to the Free Software
4c2ad1
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
4c2ad1
+   USA.  */
4c2ad1
+
4c2ad1
+
4c2ad1
+/* The function `func1' traced into must have debug info on offset > 0;
4c2ad1
+   (DW_UNSND (attr)).  This is the reason of `func0' existence.  */
4c2ad1
+
4c2ad1
+void
4c2ad1
+func0(int a, int b)
4c2ad1
+{
4c2ad1
+}
4c2ad1
+
4c2ad1
+/* `func1' being traced into must have some arguments to dump.  */
4c2ad1
+
4c2ad1
+void
4c2ad1
+func1(int a, int b)
4c2ad1
+{
4c2ad1
+  func0 (a,b);
4c2ad1
+}
4c2ad1
+
4c2ad1
+int
4c2ad1
+main(void)
4c2ad1
+{
4c2ad1
+  func1 (1, 2);
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
4c2ad1
@@ -0,0 +1,79 @@
4c2ad1
+# Copyright 2006 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 2 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+# 
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+# 
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program; if not, write to the Free Software
4c2ad1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4c2ad1
+
4c2ad1
+# Minimal DWARF-2 unit test
4c2ad1
+
4c2ad1
+# This test can only be run on targets which support DWARF-2.
4c2ad1
+# For now pick a sampling of likely targets.
4c2ad1
+if {![istarget *-*-linux*]
4c2ad1
+    && ![istarget *-*-gnu*]
4c2ad1
+    && ![istarget *-*-elf*]
4c2ad1
+    && ![istarget *-*-openbsd*]
4c2ad1
+    && ![istarget arm-*-eabi*]
4c2ad1
+    && ![istarget powerpc-*-eabi*]} {
4c2ad1
+    return 0  
4c2ad1
+}
4c2ad1
+
4c2ad1
+set testfile "dw2-stripped"
4c2ad1
+set srcfile ${testfile}.c
4c2ad1
+set binfile [standard_output_file ${testfile}.x]
4c2ad1
+
4c2ad1
+remote_exec build "rm -f ${binfile}"
4c2ad1
+
4c2ad1
+# get the value of gcc_compiled
4c2ad1
+if [get_compiler_info ${binfile}] {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+# This test can only be run on gcc as we use additional_flags=FIXME
4c2ad1
+if {$gcc_compiled == 0} {
4c2ad1
+    return 0
4c2ad1
+}
4c2ad1
+
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+remote_exec build "objcopy -R .debug_loc ${binfile}"
4c2ad1
+set strip_output [remote_exec build "objdump -h ${binfile}"]
4c2ad1
+
4c2ad1
+set test "stripping test file preservation"
4c2ad1
+if [ regexp ".debug_info " $strip_output]  {
4c2ad1
+    pass "$test (.debug_info preserved)"
4c2ad1
+} else {
4c2ad1
+    fail "$test (.debug_info got also stripped)"
4c2ad1
+}
4c2ad1
+
4c2ad1
+set test "stripping test file functionality"
4c2ad1
+if [ regexp ".debug_loc " $strip_output]  {
4c2ad1
+    fail "$test (.debug_loc still present)"
4c2ad1
+} else {
4c2ad1
+    pass "$test (.debug_loc stripped)"
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+# For C programs, "start" should stop in main().
4c2ad1
+
4c2ad1
+gdb_test "start" \
4c2ad1
+         ".*main \\(\\) at .*" \
4c2ad1
+         "start"
4c2ad1
+gdb_test "step" \
4c2ad1
+         "func.* \\(.*\\) at .*" \
4c2ad1
+         "step"
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
4c2ad1
@@ -0,0 +1,83 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+/* Debug information */
4c2ad1
+
4c2ad1
+	.section .debug_info
4c2ad1
+.Lcu1_begin:
4c2ad1
+	/* CU header */
4c2ad1
+	.4byte	.Lcu1_end - .Lcu1_start		/* Length of Compilation Unit */
4c2ad1
+.Lcu1_start:
4c2ad1
+	.2byte	2				/* DWARF Version */
4c2ad1
+	.4byte	.Labbrev1_begin			/* Offset into abbrev section */
4c2ad1
+	.byte	4				/* Pointer size */
4c2ad1
+
4c2ad1
+	/* CU die */
4c2ad1
+	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
4c2ad1
+	.ascii	"dw2-struct-member-data-location.c\0"	/* DW_AT_name */
4c2ad1
+	.ascii	"GNU C 4.3.2\0"			/* DW_AT_producer */
4c2ad1
+	.byte	1				/* DW_AT_language (C) */
4c2ad1
+
4c2ad1
+.Ltype_uchar:
4c2ad1
+	.uleb128	2			/* Abbrev: DW_TAG_structure_type */
4c2ad1
+	.ascii		"some_struct\0"		/* DW_AT_name */
4c2ad1
+
4c2ad1
+	.uleb128	3			/* Abbrev: DW_TAG_member */
4c2ad1
+	.ascii		"field\0"		/* DW_AT_name */
4c2ad1
+	.byte		0			/* DW_AT_data_member_location */
4c2ad1
+
4c2ad1
+	.byte		0			/* End of children of some_struct */
4c2ad1
+
4c2ad1
+	.byte		0			/* End of children of CU */
4c2ad1
+
4c2ad1
+.Lcu1_end:
4c2ad1
+
4c2ad1
+/* Abbrev table */
4c2ad1
+	.section .debug_abbrev
4c2ad1
+.Labbrev1_begin:
4c2ad1
+	.uleb128	1			/* Abbrev code */
4c2ad1
+	.uleb128	0x11			/* DW_TAG_compile_unit */
4c2ad1
+	.byte		1			/* has_children */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0x25			/* DW_AT_producer */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0x13			/* DW_AT_language */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	2			/* Abbrev code */
4c2ad1
+	.uleb128	0x13			/* DW_TAG_structure_type */
4c2ad1
+	.byte		1			/* has_children */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	3			/* Abbrev code */
4c2ad1
+	.uleb128	0x0d			/* DW_TAG_member */
4c2ad1
+	.byte		0			/* has_children */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0x38			/* DW_AT_data_member_location */
4c2ad1
+	.uleb128	0x0b			/* DW_FORM_data1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
4c2ad1
@@ -0,0 +1,37 @@
4c2ad1
+# Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+# This test can only be run on targets which support DWARF-2 and use gas.
4c2ad1
+# For now pick a sampling of likely targets.
4c2ad1
+if {![istarget *-*-linux*]
4c2ad1
+    && ![istarget *-*-gnu*]
4c2ad1
+    && ![istarget *-*-elf*]
4c2ad1
+    && ![istarget *-*-openbsd*]
4c2ad1
+    && ![istarget arm-*-eabi*]
4c2ad1
+    && ![istarget powerpc-*-eabi*]} {
4c2ad1
+    return 0  
4c2ad1
+}
4c2ad1
+
4c2ad1
+set testfile "dw2-struct-member-data-location"
4c2ad1
+set srcfile ${testfile}.S
4c2ad1
+set binfile ${testfile}.x
4c2ad1
+
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "[standard_output_file ${binfile}]" object {nodebug}] != "" } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+clean_restart $binfile
4c2ad1
+
4c2ad1
+gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
4c2ad1
@@ -0,0 +1,121 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2012 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+/* Debug information */
4c2ad1
+
4c2ad1
+	.section	.data
4c2ad1
+vardata:
4c2ad1
+	.rept		129
4c2ad1
+	.ascii		"x"
4c2ad1
+	.endr
4c2ad1
+	.ascii		"UNSEEN\0"
4c2ad1
+
4c2ad1
+	.section	.debug_info
4c2ad1
+.Lcu1_begin:
4c2ad1
+	.4byte		.Lcu1_end - .Lcu1_start	/* Length of Compilation Unit */
4c2ad1
+.Lcu1_start:
4c2ad1
+	.2byte		2			/* DWARF version number */
4c2ad1
+	.4byte		.Ldebug_abbrev0		/* Offset Into Abbrev. Section */
4c2ad1
+	.byte		4			/* Pointer Size (in bytes) */
4c2ad1
+
4c2ad1
+	/* CU die */
4c2ad1
+	.uleb128	1			/* Abbrev: DW_TAG_compile_unit */
4c2ad1
+	.ascii		"GNU C 3.3.3\0"		/* DW_AT_producer */
4c2ad1
+	.byte		2			/* DW_AT_language (C) -  */
4c2ad1
+
4c2ad1
+.Larray_type:
4c2ad1
+	.uleb128	2			/* Abbrev: DW_TAG_array_type */
4c2ad1
+	.4byte		.Lchar_type-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+
4c2ad1
+	.uleb128	8			/* Abbrev: DW_TAG_subrange_type without DW_AT_type */
4c2ad1
+	.byte		0			/* DW_AT_lower_bound */
4c2ad1
+	.byte		128			/* DW_AT_upper_bound */
4c2ad1
+
4c2ad1
+	.byte		0			/* End of children of die */
4c2ad1
+
4c2ad1
+.Lchar_type:
4c2ad1
+	.uleb128	4			/* Abbrev: DW_TAG_base_type */
4c2ad1
+	.ascii		"char\0"		/* DW_AT_name */
4c2ad1
+	.byte		1			/* DW_AT_byte_size */
4c2ad1
+	.byte		6			/* DW_AT_encoding */
4c2ad1
+
4c2ad1
+	.uleb128	6			/* Abbrev: DW_TAG_variable DW_FORM_string */
4c2ad1
+	.ascii		"notype_string\0"	/* DW_AT_name */
4c2ad1
+	.4byte		.Larray_type-.Lcu1_begin /* DW_AT_type */
4c2ad1
+	.byte		2f - 1f			/* DW_AT_location */
4c2ad1
+1:	.byte		3			/*   DW_OP_addr */
4c2ad1
+	.4byte		vardata			/*   <addr> */
4c2ad1
+2:
4c2ad1
+
4c2ad1
+	.byte		0			/* End of children of CU */
4c2ad1
+.Lcu1_end:
4c2ad1
+
4c2ad1
+	.section .debug_abbrev
4c2ad1
+.Ldebug_abbrev0:
4c2ad1
+	.uleb128	1			/* Abbrev code */
4c2ad1
+	.uleb128	0x11			/* DW_TAG_compile_unit */
4c2ad1
+	.byte		0x1			/* has_children */
4c2ad1
+	.uleb128	0x25			/* DW_AT_producer */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0x13			/* DW_AT_language */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	2			/* Abbrev code */
4c2ad1
+	.uleb128	0x1			/* TAG: DW_TAG_array_type */
4c2ad1
+	.byte		0x1			/* DW_children_yes */
4c2ad1
+	.uleb128	0x49			/* DW_AT_type */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	4			/* Abbrev code */
4c2ad1
+	.uleb128	0x24			/* DW_TAG_base_type */
4c2ad1
+	.byte		0x0			/* no_children */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0xb			/* DW_AT_byte_size */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.uleb128	0x3e			/* DW_AT_encoding */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	6			/* Abbrev code */
4c2ad1
+	.uleb128	0x34			/* DW_TAG_variable */
4c2ad1
+	.byte		0x0			/* no_children */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0x49			/* DW_AT_type */
4c2ad1
+	.uleb128	0x13			/* DW_FORM_ref4 */
4c2ad1
+	.uleb128	0x2			/* DW_AT_location */
4c2ad1
+	.uleb128	0xa			/* DW_FORM_block1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	8			/* Abbrev code */
4c2ad1
+	.uleb128	0x21			/* DW_TAG_subrange_type without DW_AT_type */
4c2ad1
+	.byte		0x0			/* no children */
4c2ad1
+	.uleb128	0x22			/* DW_AT_lower_bound */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.uleb128	0x2f			/* DW_AT_upper_bound */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
4c2ad1
@@ -0,0 +1,39 @@
4c2ad1
+# Copyright 2012 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+load_lib dwarf.exp
4c2ad1
+
4c2ad1
+# https://bugzilla.redhat.com/show_bug.cgi?id=806920
4c2ad1
+# read_subrange_type <TYPE_CODE (base_type) == TYPE_CODE_VOID> reinitialization
4c2ad1
+# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without
4c2ad1
+# specified DW_AT_type, present only in XLF produced code.
4c2ad1
+
4c2ad1
+# This test can only be run on targets which support DWARF-2 and use gas.
4c2ad1
+if {![dwarf2_support]} {
4c2ad1
+    return 0  
4c2ad1
+}
4c2ad1
+
4c2ad1
+set testfile dw2-subrange-no-type
4c2ad1
+set srcfile ${testfile}.S
4c2ad1
+set executable ${testfile}.x
4c2ad1
+set binfile [standard_output_file ${executable}]
4c2ad1
+
4c2ad1
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+clean_restart $executable
4c2ad1
+
4c2ad1
+gdb_test "ptype notype_string" {type = char \[129\]}
4c2ad1
+gdb_test "p notype_string" " = 'x' <repeats 129 times>"
4c2ad1
diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
4c2ad1
@@ -0,0 +1,42 @@
4c2ad1
+# Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 2 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+# 
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+# 
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program; if not, write to the Free Software
4c2ad1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
4c2ad1
+
4c2ad1
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
4c2ad1
+
4c2ad1
+# This file is part of the gdb testsuite.  Array element stride must not be
4c2ad1
+# specified in the number of elements but in a number of bytes instead.
4c2ad1
+# Original problem:
4c2ad1
+# (gdb) p c40pt(1)
4c2ad1
+# $1 = '0-hello', ' ' <repeats 33 times>
4c2ad1
+# (gdb) p c40pt(2)
4c2ad1
+# warning: Fortran array stride not divisible by the element size
4c2ad1
+
4c2ad1
+set testfile dwarf-stride
4c2ad1
+set srcfile ${testfile}.f90
4c2ad1
+
4c2ad1
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+if ![runto MAIN__] then {
4c2ad1
+    perror "couldn't run to breakpoint MAIN__"
4c2ad1
+    continue
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "break-here"]
4c2ad1
+gdb_continue_to_breakpoint "break-here" ".*break-here.*"
4c2ad1
+gdb_test "p c40pt(1)" " = '0-hello.*"
4c2ad1
+gdb_test "p c40pt(2)" " = '1-hello.*"
4c2ad1
diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
4c2ad1
@@ -0,0 +1,40 @@
4c2ad1
+! Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+!
4c2ad1
+! This program is free software; you can redistribute it and/or modify
4c2ad1
+! it under the terms of the GNU General Public License as published by
4c2ad1
+! the Free Software Foundation; either version 2 of the License, or
4c2ad1
+! (at your option) any later version.
4c2ad1
+!
4c2ad1
+! This program is distributed in the hope that it will be useful,
4c2ad1
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+! GNU General Public License for more details.
4c2ad1
+!
4c2ad1
+! You should have received a copy of the GNU General Public License
4c2ad1
+! along with this program; if not, write to the Free Software
4c2ad1
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4c2ad1
+!
4c2ad1
+! File written by Alan Matsuoka.
4c2ad1
+
4c2ad1
+program repro
4c2ad1
+
4c2ad1
+  type small_stride
4c2ad1
+     character*40 long_string
4c2ad1
+     integer      small_pad
4c2ad1
+  end type small_stride
4c2ad1
+
4c2ad1
+  type(small_stride), dimension (20), target :: unpleasant
4c2ad1
+  character*40, pointer, dimension(:):: c40pt
4c2ad1
+
4c2ad1
+  integer i
4c2ad1
+
4c2ad1
+  do i = 0,19
4c2ad1
+     unpleasant(i+1)%small_pad = i+1
4c2ad1
+     unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
4c2ad1
+  end do
4c2ad1
+
4c2ad1
+  c40pt => unpleasant%long_string
4c2ad1
+
4c2ad1
+  print *, c40pt  ! break-here
4c2ad1
+
4c2ad1
+end program repro
4c2ad1
diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.fortran/dynamic.exp
4c2ad1
@@ -0,0 +1,154 @@
4c2ad1
+# Copyright 2007 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 2 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+# 
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+# 
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program; if not, write to the Free Software
4c2ad1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
4c2ad1
+
4c2ad1
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
4c2ad1
+
4c2ad1
+# This file is part of the gdb testsuite.  It contains tests for dynamically
4c2ad1
+# allocated Fortran arrays.
4c2ad1
+# It depends on the GCC dynamic Fortran arrays DWARF support:
4c2ad1
+# 	http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
4c2ad1
+
4c2ad1
+set testfile "dynamic"
4c2ad1
+set srcfile ${testfile}.f90
4c2ad1
+set binfile [standard_output_file ${testfile}]
4c2ad1
+
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
4c2ad1
+    untested "Couldn't compile ${srcfile}"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+if ![runto MAIN__] then {
4c2ad1
+    perror "couldn't run to breakpoint MAIN__"
4c2ad1
+    continue
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varx-init"]
4c2ad1
+gdb_continue_to_breakpoint "varx-init"
4c2ad1
+
4c2ad1
+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
4c2ad1
+# Do not: gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx unallocated"
4c2ad1
+# Do not: gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx unallocated"
4c2ad1
+# Do not: gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) unallocated"
4c2ad1
+# Do not: gdb_test "p varx(1,5,17)=1" {no such vector element \(vector not allocated\)} "p varx(1,5,17)=1 unallocated"
4c2ad1
+# Do not: gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) unallocated"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varx-allocated"]
4c2ad1
+gdb_continue_to_breakpoint "varx-allocated"
4c2ad1
+# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
4c2ad1
+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated"
4c2ad1
+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
4c2ad1
+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varx-filled"]
4c2ad1
+gdb_continue_to_breakpoint "varx-filled"
4c2ad1
+gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
4c2ad1
+gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
4c2ad1
+gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
4c2ad1
+gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
4c2ad1
+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
4c2ad1
+# Do not: gdb_test "p varv" "\\$\[0-9\]* = <not associated>" "p varv unassociated"
4c2ad1
+# Do not: gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv unassociated"
4c2ad1
+
4c2ad1
+set test "output varx"
4c2ad1
+gdb_test_multiple $test $test {
4c2ad1
+    -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" {
4c2ad1
+	pass $test
4c2ad1
+    }
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varv-associated"]
4c2ad1
+gdb_continue_to_breakpoint "varv-associated"
4c2ad1
+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
4c2ad1
+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
4c2ad1
+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
4c2ad1
+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
4c2ad1
+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated"
4c2ad1
+# Intel Fortran Compiler 10.1.008 uses the pointer type.
4c2ad1
+gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varv-filled"]
4c2ad1
+gdb_continue_to_breakpoint "varv-filled"
4c2ad1
+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
4c2ad1
+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
4c2ad1
+gdb_continue_to_breakpoint "varv-deassociated"
4c2ad1
+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
4c2ad1
+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"
4c2ad1
+gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv deassociated"
4c2ad1
+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
4c2ad1
+gdb_test "p varv(1,5,17)" {no such vector element \(vector not associated\)}
4c2ad1
+gdb_test "ptype varv(1,5,17)" {no such vector element \(vector not associated\)}
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
4c2ad1
+gdb_continue_to_breakpoint "varx-deallocated"
4c2ad1
+gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx deallocated"
4c2ad1
+gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx deallocated"
4c2ad1
+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
4c2ad1
+gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) deallocated"
4c2ad1
+gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) deallocated"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "vary-passed"]
4c2ad1
+gdb_continue_to_breakpoint "vary-passed"
4c2ad1
+# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
4c2ad1
+gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "vary-filled"]
4c2ad1
+gdb_continue_to_breakpoint "vary-filled"
4c2ad1
+gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
4c2ad1
+gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
4c2ad1
+gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
4c2ad1
+gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
4c2ad1
+# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
4c2ad1
+gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
4c2ad1
+gdb_continue_to_breakpoint "varw-almostfilled"
4c2ad1
+gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
4c2ad1
+gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
4c2ad1
+# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
4c2ad1
+gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
4c2ad1
+# "up" works with GCC but other Fortran compilers may copy the values into the
4c2ad1
+# outer function only on the exit of the inner function.
4c2ad1
+# We need both variants as depending on the arch we optionally may still be
4c2ad1
+# executing the caller line or not after `finish'.
4c2ad1
+gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))"
4c2ad1
+gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
4c2ad1
+gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
4c2ad1
+gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
4c2ad1
+gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
4c2ad1
+gdb_continue_to_breakpoint "varz-almostfilled"
4c2ad1
+# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
4c2ad1
+gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
4c2ad1
+# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
4c2ad1
+# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
4c2ad1
+gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
4c2ad1
+gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
4c2ad1
+gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
4c2ad1
+gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
4c2ad1
+# maps to foo::vary(1,1)
4c2ad1
+gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
4c2ad1
+# maps to foo::vary(2,2)
4c2ad1
+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
4c2ad1
+# maps to foo::vary(1,3)
4c2ad1
+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
4c2ad1
diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.fortran/dynamic.f90
4c2ad1
@@ -0,0 +1,98 @@
4c2ad1
+! Copyright 2007 Free Software Foundation, Inc.
4c2ad1
+!
4c2ad1
+! This program is free software; you can redistribute it and/or modify
4c2ad1
+! it under the terms of the GNU General Public License as published by
4c2ad1
+! the Free Software Foundation; either version 2 of the License, or
4c2ad1
+! (at your option) any later version.
4c2ad1
+!
4c2ad1
+! This program is distributed in the hope that it will be useful,
4c2ad1
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+! GNU General Public License for more details.
4c2ad1
+!
4c2ad1
+! You should have received a copy of the GNU General Public License
4c2ad1
+! along with this program; if not, write to the Free Software
4c2ad1
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4c2ad1
+!
4c2ad1
+! Ihis file is the Fortran source file for dynamic.exp.
4c2ad1
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
4c2ad1
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
4c2ad1
+
4c2ad1
+subroutine baz
4c2ad1
+  real, target, allocatable :: varx (:, :, :)
4c2ad1
+  real, pointer :: varv (:, :, :)
4c2ad1
+  real, target :: varu (1, 2, 3)
4c2ad1
+  logical :: l
4c2ad1
+  allocate (varx (1:6, 5:15, 17:28))            ! varx-init
4c2ad1
+  l = allocated (varx)
4c2ad1
+  varx(:, :, :) = 6                             ! varx-allocated
4c2ad1
+  varx(1, 5, 17) = 7
4c2ad1
+  varx(2, 6, 18) = 8
4c2ad1
+  varx(6, 15, 28) = 9
4c2ad1
+  varv => varx                                  ! varx-filled
4c2ad1
+  l = associated (varv)
4c2ad1
+  varv(3, 7, 19) = 10                           ! varv-associated
4c2ad1
+  varv => null ()                               ! varv-filled
4c2ad1
+  l = associated (varv)
4c2ad1
+  deallocate (varx)                             ! varv-deassociated
4c2ad1
+  l = allocated (varx)
4c2ad1
+  varu(:, :, :) = 10                            ! varx-deallocated
4c2ad1
+  allocate (varv (1:6, 5:15, 17:28))
4c2ad1
+  l = associated (varv)
4c2ad1
+  varv(:, :, :) = 6
4c2ad1
+  varv(1, 5, 17) = 7
4c2ad1
+  varv(2, 6, 18) = 8
4c2ad1
+  varv(6, 15, 28) = 9
4c2ad1
+  deallocate (varv)
4c2ad1
+  l = associated (varv)
4c2ad1
+  varv => varu
4c2ad1
+  varv(1, 1, 1) = 6
4c2ad1
+  varv(1, 2, 3) = 7
4c2ad1
+  l = associated (varv)
4c2ad1
+end subroutine baz
4c2ad1
+subroutine foo (vary, varw)
4c2ad1
+  real :: vary (:, :)
4c2ad1
+  real :: varw (:, :, :)
4c2ad1
+  vary(:, :) = 4                                ! vary-passed
4c2ad1
+  vary(1, 1) = 8
4c2ad1
+  vary(2, 2) = 9
4c2ad1
+  vary(1, 3) = 10
4c2ad1
+  varw(:, :, :) = 5                             ! vary-filled
4c2ad1
+  varw(1, 1, 1) = 6
4c2ad1
+  varw(2, 2, 2) = 7                             ! varw-almostfilled
4c2ad1
+end subroutine foo
4c2ad1
+subroutine bar (varz, vart)
4c2ad1
+  real :: varz (*)
4c2ad1
+  real :: vart (2:11, 7:*)
4c2ad1
+  varz(1:3) = 4
4c2ad1
+  varz(2) = 5                                   ! varz-almostfilled
4c2ad1
+  vart(2,7) = vart(2,7)
4c2ad1
+end subroutine bar
4c2ad1
+program test
4c2ad1
+  interface
4c2ad1
+    subroutine foo (vary, varw)
4c2ad1
+    real :: vary (:, :)
4c2ad1
+    real :: varw (:, :, :)
4c2ad1
+    end subroutine
4c2ad1
+  end interface
4c2ad1
+  interface
4c2ad1
+    subroutine bar (varz, vart)
4c2ad1
+    real :: varz (*)
4c2ad1
+    real :: vart (2:11, 7:*)
4c2ad1
+    end subroutine
4c2ad1
+  end interface
4c2ad1
+  real :: x (10, 10), y (5), z(8, 8, 8)
4c2ad1
+  x(:,:) = 1
4c2ad1
+  y(:) = 2
4c2ad1
+  z(:,:,:) = 3
4c2ad1
+  call baz
4c2ad1
+  call foo (x, z(2:6, 4:7, 6:8))
4c2ad1
+  call bar (y, x)
4c2ad1
+  if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
4c2ad1
+  if (x (1, 3) .ne. 10) call abort
4c2ad1
+  if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
4c2ad1
+  if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
4c2ad1
+  call foo (transpose (x), z)
4c2ad1
+  if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
4c2ad1
+  if (x (3, 1) .ne. 10) call abort
4c2ad1
+end
4c2ad1
diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.fortran/string.exp
4c2ad1
@@ -0,0 +1,59 @@
4c2ad1
+# Copyright 2008 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 2 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+# 
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+# 
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program; if not, write to the Free Software
4c2ad1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
4c2ad1
+
4c2ad1
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
4c2ad1
+
4c2ad1
+# This file is part of the gdb testsuite.  It contains tests for Fortran
4c2ad1
+# strings with dynamic length.
4c2ad1
+
4c2ad1
+set testfile "string"
4c2ad1
+set srcfile ${testfile}.f90
4c2ad1
+set binfile [standard_output_file ${testfile}]
4c2ad1
+
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
4c2ad1
+    untested "Couldn't compile ${srcfile}"
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+
4c2ad1
+if ![runto MAIN__] then {
4c2ad1
+    perror "couldn't run to breakpoint MAIN__"
4c2ad1
+    continue
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "var-init"]
4c2ad1
+gdb_continue_to_breakpoint "var-init"
4c2ad1
+gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
4c2ad1
+gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
4c2ad1
+gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
4c2ad1
+gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
4c2ad1
+gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
4c2ad1
+gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
4c2ad1
+gdb_test "p c" "\\$\[0-9\]* = 'c'"
4c2ad1
+gdb_test "p d" "\\$\[0-9\]* = 'd       '"
4c2ad1
+gdb_test "p e" "\\$\[0-9\]* = 'g   '"
4c2ad1
+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   '\\) \\)"
4c2ad1
+gdb_test "p *e" "Attempt to take contents of a non-pointer value."
4c2ad1
+gdb_test "p *f" "Attempt to take contents of a non-pointer value."
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "var-finish"]
4c2ad1
+gdb_continue_to_breakpoint "var-finish"
4c2ad1
+gdb_test "p e" "\\$\[0-9\]* = 'e   '" "p e re-set"
4c2ad1
+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"
4c2ad1
diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.fortran/string.f90
4c2ad1
@@ -0,0 +1,37 @@
4c2ad1
+! Copyright 2008 Free Software Foundation, Inc.
4c2ad1
+!
4c2ad1
+! This program is free software; you can redistribute it and/or modify
4c2ad1
+! it under the terms of the GNU General Public License as published by
4c2ad1
+! the Free Software Foundation; either version 2 of the License, or
4c2ad1
+! (at your option) any later version.
4c2ad1
+!
4c2ad1
+! This program is distributed in the hope that it will be useful,
4c2ad1
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+! GNU General Public License for more details.
4c2ad1
+!
4c2ad1
+! You should have received a copy of the GNU General Public License
4c2ad1
+! along with this program; if not, write to the Free Software
4c2ad1
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4c2ad1
+!
4c2ad1
+! Ihis file is the Fortran source file for dynamic.exp.
4c2ad1
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
4c2ad1
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
4c2ad1
+
4c2ad1
+subroutine foo (e, f)
4c2ad1
+  character (len=1) :: c
4c2ad1
+  character (len=8) :: d
4c2ad1
+  character (len=*) :: e
4c2ad1
+  character (len=*) :: f (1:7, 8:10)
4c2ad1
+  c = 'c'
4c2ad1
+  d = 'd'
4c2ad1
+  e = 'e'                                       ! var-init
4c2ad1
+  f = 'f'
4c2ad1
+  f(1,9) = 'f2'
4c2ad1
+  c = 'c'                                       ! var-finish
4c2ad1
+end subroutine foo
4c2ad1
+  character (len=4) :: g, h (1:7, 8:10)
4c2ad1
+  g = 'g'
4c2ad1
+  h = 'h'
4c2ad1
+  call foo (g, h)
4c2ad1
+end
4c2ad1
diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.fortran/subrange.exp
4c2ad1
@@ -0,0 +1,72 @@
4c2ad1
+# Copyright 2011 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+if { [skip_fortran_tests] } { return -1 }
4c2ad1
+
4c2ad1
+set testfile "subrange"
4c2ad1
+set srcfile ${testfile}.f90
4c2ad1
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+if ![runto MAIN__] {
4c2ad1
+    perror "Couldn't run to MAIN__"
4c2ad1
+    continue
4c2ad1
+}
4c2ad1
+
4c2ad1
+# Depending on the compiler version being used, the name of the 4-byte integer
4c2ad1
+# and real types can be printed differently.  For instance, gfortran-4.1 uses
4c2ad1
+# "int4" whereas gfortran-4.3 uses "int(kind=4)".
4c2ad1
+set int4 "(int4|integer\\(kind=4\\))"
4c2ad1
+
4c2ad1
+gdb_breakpoint [gdb_get_line_number "break-static"]
4c2ad1
+gdb_continue_to_breakpoint "break-static" ".*break-static.*"
4c2ad1
+
4c2ad1
+foreach var {a alloc ptr} {
4c2ad1
+    global pf_prefix
4c2ad1
+    set old_prefix $pf_prefix
4c2ad1
+    lappend pf_prefix "$var:"
4c2ad1
+
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (1, 2:)" { = \(21, 31\)}
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (2, :2)" { = \(12, 22\)}
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (3, 2:2)" { = \(23\)}
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (:)" "Wrong number of subscripts"
4c2ad1
+    setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+    gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
4c2ad1
+
4c2ad1
+    set pf_prefix $old_prefix
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_test_no_output {set $a=a}
4c2ad1
+delete_breakpoints
4c2ad1
+gdb_unload
4c2ad1
+setup_kfail "*-*-*" "vlaregression/9999"
4c2ad1
+gdb_test {p $a (3, 2:2)} { = \(23\)}
4c2ad1
diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.fortran/subrange.f90
4c2ad1
@@ -0,0 +1,28 @@
4c2ad1
+! Copyright 2011 Free Software Foundation, Inc.
4c2ad1
+!
4c2ad1
+! This program is free software; you can redistribute it and/or modify
4c2ad1
+! it under the terms of the GNU General Public License as published by
4c2ad1
+! the Free Software Foundation; either version 3 of the License, or
4c2ad1
+! (at your option) any later version.
4c2ad1
+! 
4c2ad1
+! This program is distributed in the hope that it will be useful,
4c2ad1
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+! GNU General Public License for more details.
4c2ad1
+! 
4c2ad1
+! You should have received a copy of the GNU General Public License
4c2ad1
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+program test
4c2ad1
+  integer, target :: a (4, 3)
4c2ad1
+  integer, allocatable :: alloc (:, :)
4c2ad1
+  integer, pointer :: ptr (:, :)
4c2ad1
+  do 1 i = 1, 4
4c2ad1
+  do 1 j = 1, 3
4c2ad1
+    a (i, j) = j * 10 + i
4c2ad1
+1 continue
4c2ad1
+  allocate (alloc (4, 3))
4c2ad1
+  alloc = a
4c2ad1
+  ptr => a
4c2ad1
+  write (*,*) a                 ! break-static
4c2ad1
+end
4c2ad1
diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
4c2ad1
@@ -0,0 +1,26 @@
4c2ad1
+/* Copyright 2011 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This file is part of GDB.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+int
4c2ad1
+main (int argc, char **argv)
4c2ad1
+{
4c2ad1
+  char vla[argc];
4c2ad1
+
4c2ad1
+  vla[0] = 0;	/* break-here */
4c2ad1
+
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
4c2ad1
@@ -0,0 +1,57 @@
4c2ad1
+# Copyright 2011 Free Software Foundation, Inc.
4c2ad1
+#
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+load_lib mi-support.exp
4c2ad1
+set MIFLAGS "-i=mi2"
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+if [mi_gdb_start] {
4c2ad1
+    continue
4c2ad1
+}
4c2ad1
+
4c2ad1
+set testfile "mi2-var-stale-type"
4c2ad1
+set srcfile ${testfile}.c
4c2ad1
+set binfile [standard_output_file ${testfile}]
4c2ad1
+if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+mi_delete_breakpoints
4c2ad1
+mi_gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+mi_gdb_load ${binfile}
4c2ad1
+
4c2ad1
+mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
4c2ad1
+  {\^done} \
4c2ad1
+  "maintenance set internal-error quit yes"
4c2ad1
+
4c2ad1
+mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
4c2ad1
+  {\^done} \
4c2ad1
+  "maintenance set internal-error corefile yes"
4c2ad1
+
4c2ad1
+set line [gdb_get_line_number "break-here"]
4c2ad1
+set func "main"
4c2ad1
+
4c2ad1
+mi_gdb_test "-break-insert -t $srcfile:$line" \
4c2ad1
+  "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",fullname=\".*\",line=\"$line\",\[^\r\n\]*,original-location=\".*\"\}" \
4c2ad1
+  "breakpoint at $func"
4c2ad1
+
4c2ad1
+if { [mi_run_cmd] < 0 } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
4c2ad1
+
4c2ad1
+mi_create_varobj "vla" "vla" "create local variable vla"
4c2ad1
+
4c2ad1
+mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *"
4c2ad1
diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
4c2ad1
@@ -0,0 +1,22 @@
4c2ad1
+/* This file is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+int
4c2ad1
+func (int *arr)
4c2ad1
+{
4c2ad1
+  return arr[0];
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.opt/array-from-register.c
4c2ad1
@@ -0,0 +1,28 @@
4c2ad1
+/* This file is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+   This program is free software; you can redistribute it and/or modify
4c2ad1
+   it under the terms of the GNU General Public License as published by
4c2ad1
+   the Free Software Foundation; either version 3 of the License, or
4c2ad1
+   (at your option) any later version.
4c2ad1
+
4c2ad1
+   This program is distributed in the hope that it will be useful,
4c2ad1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+   GNU General Public License for more details.
4c2ad1
+
4c2ad1
+   You should have received a copy of the GNU General Public License
4c2ad1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4c2ad1
+
4c2ad1
+extern int func (int *arr);
4c2ad1
+
4c2ad1
+int
4c2ad1
+main (void)
4c2ad1
+{
4c2ad1
+  int arr[] = { 42 };
4c2ad1
+
4c2ad1
+  func (arr);
4c2ad1
+
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.opt/array-from-register.exp
4c2ad1
@@ -0,0 +1,33 @@
4c2ad1
+# Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+#
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 2 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program; if not, write to the Free Software
4c2ad1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4c2ad1
+#
4c2ad1
+# This file is part of the gdb testsuite.
4c2ad1
+
4c2ad1
+if { [prepare_for_testing array-from-register.exp "array-from-register"      \
4c2ad1
+			  {array-from-register.c array-from-register-func.c} \
4c2ad1
+			  {debug optimize=-O2}] } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+if ![runto func] then {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
4c2ad1
+
4c2ad1
+# Seen regression:
4c2ad1
+# Address requested for identifier "arr" which is in register $rdi
4c2ad1
+gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
4c2ad1
diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.opt/fortran-string.exp
4c2ad1
@@ -0,0 +1,39 @@
4c2ad1
+# Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 2 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+# 
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+# 
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program; if not, write to the Free Software
4c2ad1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
4c2ad1
+
4c2ad1
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
4c2ad1
+
4c2ad1
+# Test GDB can cope with Fortran strings having their length present in a CPU
4c2ad1
+# register.  With -O0 the string length is passed on the stack.  To make this
4c2ad1
+# test meaningful the follow assertion should pass.  It is not being checked
4c2ad1
+# here as the "_s" symbol is compiler dependent:
4c2ad1
+#   (gdb) info address _s
4c2ad1
+#   Symbol "_s" is a variable in register XX.
4c2ad1
+
4c2ad1
+set test fortran-string
4c2ad1
+set srcfile ${test}.f90
4c2ad1
+if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f90 additional_flags=-O2}] } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+if ![runto $srcfile:[gdb_get_line_number "s = s"]] then {
4c2ad1
+    perror "couldn't run to breakpoint MAIN__"
4c2ad1
+    continue
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_test "frame" ".*s='foo'.*"
4c2ad1
+gdb_test "ptype s" "type = character\\*3"
4c2ad1
+gdb_test "p s" "\\$\[0-9\]* = 'foo'"
4c2ad1
diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.opt/fortran-string.f90
4c2ad1
@@ -0,0 +1,28 @@
4c2ad1
+! Copyright 2009 Free Software Foundation, Inc.
4c2ad1
+!
4c2ad1
+! This program is free software; you can redistribute it and/or modify
4c2ad1
+! it under the terms of the GNU General Public License as published by
4c2ad1
+! the Free Software Foundation; either version 2 of the License, or
4c2ad1
+! (at your option) any later version.
4c2ad1
+!
4c2ad1
+! This program is distributed in the hope that it will be useful,
4c2ad1
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+! GNU General Public License for more details.
4c2ad1
+!
4c2ad1
+! You should have received a copy of the GNU General Public License
4c2ad1
+! along with this program; if not, write to the Free Software
4c2ad1
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4c2ad1
+!
4c2ad1
+! Ihis file is the Fortran source file for dynamic.exp.
4c2ad1
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
4c2ad1
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
4c2ad1
+
4c2ad1
+  subroutine f(s)
4c2ad1
+  character*(*) s
4c2ad1
+  s = s
4c2ad1
+  end
4c2ad1
+
4c2ad1
+  program main
4c2ad1
+  call f ('foo')
4c2ad1
+  end
4c2ad1
diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.pascal/arrays.exp
4c2ad1
@@ -0,0 +1,104 @@
4c2ad1
+# Copyright 2008, 2009 Free Software Foundation, Inc.
4c2ad1
+#
4c2ad1
+# This program is free software; you can redistribute it and/or modify
4c2ad1
+# it under the terms of the GNU General Public License as published by
4c2ad1
+# the Free Software Foundation; either version 3 of the License, or
4c2ad1
+# (at your option) any later version.
4c2ad1
+#
4c2ad1
+# This program is distributed in the hope that it will be useful,
4c2ad1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+# GNU General Public License for more details.
4c2ad1
+#
4c2ad1
+# You should have received a copy of the GNU General Public License
4c2ad1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+
4c2ad1
+if $tracelevel then {
4c2ad1
+    strace $tracelevel
4c2ad1
+}
4c2ad1
+
4c2ad1
+load_lib "pascal.exp"
4c2ad1
+
4c2ad1
+set testfile "arrays"
4c2ad1
+set srcfile ${testfile}.pas
4c2ad1
+set binfile [standard_output_file ${testfile}$EXEEXT]
4c2ad1
+
4c2ad1
+# These tests only work with fpc, using the -gw3 compile-option
4c2ad1
+pascal_init
4c2ad1
+if { $pascal_compiler_is_fpc != 1 } {
4c2ad1
+  return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+# Detect if the fpc version is below 2.3.0
4c2ad1
+set fpc_generates_dwarf_for_dynamic_arrays 1
4c2ad1
+if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))}  {
4c2ad1
+  set fpc_generates_dwarf_for_dynamic_arrays 0
4c2ad1
+}
4c2ad1
+
4c2ad1
+
4c2ad1
+if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
4c2ad1
+  return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_exit
4c2ad1
+gdb_start
4c2ad1
+gdb_reinitialize_dir $srcdir/$subdir
4c2ad1
+gdb_load ${binfile}
4c2ad1
+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
4c2ad1
+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
4c2ad1
+
4c2ad1
+
4c2ad1
+if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
4c2ad1
+    pass "setting breakpoint 1"
4c2ad1
+}
4c2ad1
+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
4c2ad1
+    pass "setting breakpoint 2"
4c2ad1
+}
4c2ad1
+
4c2ad1
+# Verify that "start" lands inside the right procedure.
4c2ad1
+if { [gdb_start_cmd] < 0 } {
4c2ad1
+    untested start
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+gdb_test "" ".* at .*${srcfile}.*" "start"
4c2ad1
+
4c2ad1
+gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
4c2ad1
+
4c2ad1
+gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type"
4c2ad1
+gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer"
4c2ad1
+
4c2ad1
+gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
4c2ad1
+
4c2ad1
+gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char"
4c2ad1
+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"
4c2ad1
+
4c2ad1
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
4c2ad1
+  setup_xfail "*-*-*"
4c2ad1
+}
4c2ad1
+gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type"
4c2ad1
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
4c2ad1
+  setup_xfail "*-*-*"
4c2ad1
+}
4c2ad1
+gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
4c2ad1
+
4c2ad1
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
4c2ad1
+  setup_xfail "*-*-*"
4c2ad1
+}
4c2ad1
+gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
4c2ad1
+
4c2ad1
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
4c2ad1
+  setup_xfail "*-*-*"
4c2ad1
+}
4c2ad1
+gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
4c2ad1
+
4c2ad1
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
4c2ad1
+  setup_xfail "*-*-*"
4c2ad1
+}
4c2ad1
+gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
4c2ad1
+
4c2ad1
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
4c2ad1
+  setup_xfail "*-*-*"
4c2ad1
+}
4c2ad1
+gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
4c2ad1
+
4c2ad1
diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.pascal/arrays.pas
4c2ad1
@@ -0,0 +1,82 @@
4c2ad1
+{
4c2ad1
+ Copyright 2008, 2009 Free Software Foundation, Inc.
4c2ad1
+
4c2ad1
+ This program is free software; you can redistribute it and/or modify
4c2ad1
+ it under the terms of the GNU General Public License as published by
4c2ad1
+ the Free Software Foundation; either version 3 of the License, or
4c2ad1
+ (at your option) any later version.
4c2ad1
+
4c2ad1
+ This program is distributed in the hope that it will be useful,
4c2ad1
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
4c2ad1
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c2ad1
+ GNU General Public License for more details.
4c2ad1
+
4c2ad1
+ You should have received a copy of the GNU General Public License
4c2ad1
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
4c2ad1
+}
4c2ad1
+
4c2ad1
+program arrays;
4c2ad1
+
4c2ad1
+{$mode objfpc}{$h+}
4c2ad1
+
4c2ad1
+uses sysutils;
4c2ad1
+
4c2ad1
+type TStatArrInt= array[0..11] of integer;
4c2ad1
+     TDynArrInt= array of integer;
4c2ad1
+     TStatArrStr= array[0..12] of string;
4c2ad1
+     TDynArrStr= array of string;
4c2ad1
+     TDynArrChar = array of char;
4c2ad1
+     TStatArrChar = array [0..11] of char;
4c2ad1
+
4c2ad1
+     TStat2dArrInt = array[0..11,0..4] of integer;
4c2ad1
+
4c2ad1
+var StatArrInt: TStatArrInt;
4c2ad1
+    StatArrInt_: Array[0..11] of integer;
4c2ad1
+    DynArrInt:  TDynArrInt;
4c2ad1
+    DynArrInt_: Array of integer;
4c2ad1
+    StatArrStr: TStatArrStr;
4c2ad1
+    DynArrStr: TDynArrStr;
4c2ad1
+    StatArrChar: TStatArrChar;
4c2ad1
+    DynArrChar: TDynArrChar;
4c2ad1
+
4c2ad1
+    Stat2dArrInt: TStat2dArrInt;
4c2ad1
+
4c2ad1
+    s: string;
4c2ad1
+	
4c2ad1
+    i,j : integer;
4c2ad1
+
4c2ad1
+begin
4c2ad1
+  for i := 0 to 11 do
4c2ad1
+    begin
4c2ad1
+    StatArrInt[i]:= i+50;
4c2ad1
+    StatArrInt_[i]:= i+50;
4c2ad1
+    StatArrChar[i]:= chr(ord('a')+i);
4c2ad1
+    for j := 0 to 4 do
4c2ad1
+      Stat2dArrInt[i,j]:=i+j;
4c2ad1
+    end;
4c2ad1
+  writeln(StatArrInt_[0]);
4c2ad1
+  writeln(StatArrInt[0]); { set breakpoint 1 here }
4c2ad1
+  writeln(StatArrChar[0]);
4c2ad1
+  writeln(Stat2dArrInt[0,0]);
4c2ad1
+
4c2ad1
+  setlength(DynArrInt,13);
4c2ad1
+  setlength(DynArrInt_,13);
4c2ad1
+  setlength(DynArrStr,13);
4c2ad1
+  setlength(DynArrChar,13);
4c2ad1
+  for i := 0 to 12 do
4c2ad1
+    begin
4c2ad1
+    DynArrInt[i]:= i+50;
4c2ad1
+    DynArrInt_[i]:= i+50;
4c2ad1
+    DynArrChar[i]:= chr(ord('a')+i);
4c2ad1
+    StatArrStr[i]:='str'+inttostr(i);
4c2ad1
+    DynArrStr[i]:='dstr'+inttostr(i);
4c2ad1
+    end;
4c2ad1
+  writeln(DynArrInt_[1]);
4c2ad1
+  writeln(DynArrInt[1]); 
4c2ad1
+  writeln(DynArrStr[1]); 
4c2ad1
+  writeln(StatArrStr[1]);
4c2ad1
+  writeln(DynArrChar[1]);
4c2ad1
+
4c2ad1
+  s := 'test'#0'string';
4c2ad1
+  writeln(s); { set breakpoint 2 here }
4c2ad1
+end.
4c2ad1
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
4c2ad1
--- a/gdb/testsuite/lib/gdb.exp
4c2ad1
+++ b/gdb/testsuite/lib/gdb.exp
4c2ad1
@@ -170,6 +170,11 @@ proc gdb_unload {} {
4c2ad1
 	    send_gdb "y\n"
4c2ad1
 	    exp_continue
4c2ad1
 	}
4c2ad1
+	-re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
4c2ad1
+	    { send_gdb "y\n"
4c2ad1
+		verbose "\t\tUnloading symbols for program being debugged"
4c2ad1
+	    exp_continue
4c2ad1
+	}
4c2ad1
 	-re "Discard symbol table from .*y or n.*$" {
4c2ad1
 	    send_gdb "y\n"
4c2ad1
 	    exp_continue
4c2ad1
diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp
4c2ad1
--- a/gdb/testsuite/lib/pascal.exp
4c2ad1
+++ b/gdb/testsuite/lib/pascal.exp
4c2ad1
@@ -37,6 +37,9 @@ proc pascal_init {} {
4c2ad1
     global pascal_compiler_is_fpc
4c2ad1
     global gpc_compiler
4c2ad1
     global fpc_compiler
4c2ad1
+    global fpcversion_major
4c2ad1
+    global fpcversion_minor
4c2ad1
+    global fpcversion_release
4c2ad1
     global env
4c2ad1
  
4c2ad1
     if { $pascal_init_done == 1 } {
4c2ad1
@@ -64,6 +67,20 @@ proc pascal_init {} {
4c2ad1
 	    set pascal_compiler_is_fpc 1
4c2ad1
 	    verbose -log "Free Pascal compiler found"
4c2ad1
 	}
4c2ad1
+
4c2ad1
+	# Detect the fpc-version
4c2ad1
+	if { $pascal_compiler_is_fpc == 1 } {
4c2ad1
+	    set fpcversion_major 1
4c2ad1
+	    set fpcversion_minor 0
4c2ad1
+	    set fpcversion_release 0
4c2ad1
+	    set fpcversion [ remote_exec host $fpc_compiler "-iV" ] 
4c2ad1
+	    if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] {
4c2ad1
+              regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major
4c2ad1
+              regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor
4c2ad1
+              regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release
4c2ad1
+	    }
4c2ad1
+            verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
4c2ad1
+	}
4c2ad1
     }
4c2ad1
     set pascal_init_done 1
4c2ad1
 }