]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-archer-vla-tests.patch
updated source url to https
[packages/gdb.git] / gdb-archer-vla-tests.patch
CommitLineData
4b0e5c1b
AM
1From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2From: Fedora GDB patches <invalid@email.com>
3Date: Fri, 27 Oct 2017 21:07:50 +0200
4Subject: gdb-archer-vla-tests.patch
5
4b0e5c1b 6;;=fedoratest
4b0e5c1b
AM
7
8diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp
4b0e5c1b
AM
9--- a/gdb/testsuite/gdb.ada/packed_array.exp
10+++ b/gdb/testsuite/gdb.ada/packed_array.exp
e28f2cc1 11@@ -53,5 +53,11 @@ gdb_test_multiple "$test" "$test" {
aa964043
KK
12 # are. Observed with (FSF GNU Ada 4.5.3 20110124).
13 xfail $test
14 }
15+ -re "= \\(\\)\[\r\n\]+$gdb_prompt $" {
16+ # archer-jankratochvil-vla resolves it as a dynamic type resolved as an
17+ # empty array [0..-1].
18+ # DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref)
19+ xfail $test
20+ }
21 }
22
4b0e5c1b
AM
23diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
24new file mode 100644
4b0e5c1b
AM
25--- /dev/null
26+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
140f8057
JR
27@@ -0,0 +1,358 @@
28+ .file "x86_64-vla-pointer.c"
29+ .text
30+.Ltext0:
31+ .globl foo
32+ .type foo, @function
33+foo:
34+.LFB0:
35+ .file 1 "gdb.arch/x86_64-vla-pointer.c"
36+ # gdb.arch/x86_64-vla-pointer.c:22
37+ .loc 1 22 0
38+ .cfi_startproc
39+# BLOCK 2 seq:0
40+# PRED: ENTRY (FALLTHRU)
41+ pushq %rbp
42+ .cfi_def_cfa_offset 16
43+ .cfi_offset 6, -16
44+ movq %rsp, %rbp
45+ .cfi_def_cfa_register 6
46+ pushq %rbx
47+ subq $56, %rsp
48+ .cfi_offset 3, -24
49+ movl %edi, -52(%rbp)
50+ # gdb.arch/x86_64-vla-pointer.c:22
51+ .loc 1 22 0
52+ movq %rsp, %rax
53+ movq %rax, %rsi
54+ # gdb.arch/x86_64-vla-pointer.c:23
55+ .loc 1 23 0
56+ movl -52(%rbp), %eax
57+ movslq %eax, %rdx
58+ subq $1, %rdx
59+ movq %rdx, -32(%rbp)
60+ movslq %eax, %rdx
61+ movq %rdx, %r8
62+ movl $0, %r9d
63+ # gdb.arch/x86_64-vla-pointer.c:24
64+ .loc 1 24 0
65+ movslq %eax, %rdx
66+ movq %rdx, %rcx
67+ movl $0, %ebx
68+ cltq
69+ movl $16, %edx
70+ subq $1, %rdx
71+ addq %rdx, %rax
72+ movl $16, %ebx
73+ movl $0, %edx
74+ divq %rbx
75+ imulq $16, %rax, %rax
76+ subq %rax, %rsp
77+ movq %rsp, %rax
78+ addq $0, %rax
79+ movq %rax, -40(%rbp)
80+ # gdb.arch/x86_64-vla-pointer.c:27
81+ .loc 1 27 0
82+ movl $0, -20(%rbp)
83+# SUCC: 4 [100.0%]
84+ jmp .L2
85+# BLOCK 3 seq:1
86+# PRED: 4
87+.L3:
88+ # gdb.arch/x86_64-vla-pointer.c:28
89+ .loc 1 28 0 discriminator 3
90+ movl -20(%rbp), %eax
91+ movl %eax, %ecx
92+ movq -40(%rbp), %rdx
93+ movl -20(%rbp), %eax
94+ cltq
95+ movb %cl, (%rdx,%rax)
96+# SUCC: 4 (FALLTHRU,DFS_BACK)
97+ # gdb.arch/x86_64-vla-pointer.c:27
98+ .loc 1 27 0 discriminator 3
99+ addl $1, -20(%rbp)
100+# BLOCK 4 seq:2
101+# PRED: 3 (FALLTHRU,DFS_BACK) 2 [100.0%]
102+.L2:
103+ # gdb.arch/x86_64-vla-pointer.c:27
104+ .loc 1 27 0 is_stmt 0 discriminator 1
105+ movl -20(%rbp), %eax
106+ cmpl -52(%rbp), %eax
107+# SUCC: 3 5 (FALLTHRU)
108+ jl .L3
109+# BLOCK 5 seq:3
110+# PRED: 4 (FALLTHRU)
111+ # gdb.arch/x86_64-vla-pointer.c:30
112+ .loc 1 30 0 is_stmt 1
113+ movq -40(%rbp), %rax
114+ movb $0, (%rax)
115+ movq %rsi, %rsp
116+ # gdb.arch/x86_64-vla-pointer.c:31
117+ .loc 1 31 0
118+ nop
119+ movq -8(%rbp), %rbx
120+ leave
121+ .cfi_def_cfa 7, 8
122+# SUCC: EXIT [100.0%]
123+ ret
124+ .cfi_endproc
125+.LFE0:
126+ .size foo, .-foo
127+.Letext0:
128+ .section .debug_info,"",@progbits
129+.Ldebug_info0:
130+ .long 0xa5 # Length of Compilation Unit Info
131+ .value 0x4 # DWARF version number
132+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
133+ .byte 0x8 # Pointer Size (in bytes)
134+ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
135+ .long .LASF3 # DW_AT_producer: "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
136+ .byte 0xc # DW_AT_language
137+ .long .LASF4 # DW_AT_name: "gdb.arch/x86_64-vla-pointer.c"
138+ .long .LASF5 # DW_AT_comp_dir: "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
139+ .quad .Ltext0 # DW_AT_low_pc
140+ .quad .Letext0-.Ltext0 # DW_AT_high_pc
141+ .long .Ldebug_line0 # DW_AT_stmt_list
142+ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
143+ # DW_AT_external
144+ .ascii "foo\0" # DW_AT_name
145+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
146+ .byte 0x15 # DW_AT_decl_line
147+ # DW_AT_prototyped
148+ .quad .LFB0 # DW_AT_low_pc
149+ .quad .LFE0-.LFB0 # DW_AT_high_pc
150+ .uleb128 0x1 # DW_AT_frame_base
151+ .byte 0x9c # DW_OP_call_frame_cfa
152+ # DW_AT_GNU_all_call_sites
153+ .long 0x80 # DW_AT_sibling
154+ .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter)
155+ .long .LASF6 # DW_AT_name: "size"
156+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
157+ .byte 0x15 # DW_AT_decl_line
158+ .long 0x80 # DW_AT_type
159+ .uleb128 0x3 # DW_AT_location
160+ .byte 0x91 # DW_OP_fbreg
161+ .sleb128 -68
162+ .uleb128 0x4 # (DIE (0x59) DW_TAG_typedef)
163+ .long .LASF7 # DW_AT_name: "array_t"
164+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
165+ .byte 0x17 # DW_AT_decl_line
166+ .long 0x87 # DW_AT_type
167+ .uleb128 0x5 # (DIE (0x64) DW_TAG_variable)
168+ .long .LASF0 # DW_AT_name: "array"
169+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
170+ .byte 0x18 # DW_AT_decl_line
171+ .long 0x59 # DW_AT_type
172+ .uleb128 0x3 # DW_AT_location
173+ .byte 0x91 # DW_OP_fbreg
174+ .sleb128 -56
175+ .byte 0x6 # DW_OP_deref
176+ .uleb128 0x6 # (DIE (0x73) DW_TAG_variable)
177+ .ascii "i\0" # DW_AT_name
178+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
179+ .byte 0x19 # DW_AT_decl_line
180+ .long 0x80 # DW_AT_type
181+ .uleb128 0x2 # DW_AT_location
182+ .byte 0x91 # DW_OP_fbreg
183+ .sleb128 -36
184+ .byte 0 # end of children of DIE 0x2d
185+ .uleb128 0x7 # (DIE (0x80) DW_TAG_base_type)
186+ .byte 0x4 # DW_AT_byte_size
187+ .byte 0x5 # DW_AT_encoding
188+ .ascii "int\0" # DW_AT_name
189+ .uleb128 0x8 # (DIE (0x87) DW_TAG_array_type)
190+ .long 0xa1 # DW_AT_type
191+ .long 0x9a # DW_AT_sibling
192+ .uleb128 0x9 # (DIE (0x90) DW_TAG_subrange_type)
193+ .long 0x9a # DW_AT_type
194+ .uleb128 0x3 # DW_AT_upper_bound
195+ .byte 0x91 # DW_OP_fbreg
196+ .sleb128 -48
197+ .byte 0x6 # DW_OP_deref
198+ .byte 0 # end of children of DIE 0x87
199+ .uleb128 0xa # (DIE (0x9a) DW_TAG_base_type)
200+ .byte 0x8 # DW_AT_byte_size
201+ .byte 0x7 # DW_AT_encoding
202+ .long .LASF1 # DW_AT_name: "sizetype"
203+ .uleb128 0xa # (DIE (0xa1) DW_TAG_base_type)
204+ .byte 0x1 # DW_AT_byte_size
205+ .byte 0x6 # DW_AT_encoding
206+ .long .LASF2 # DW_AT_name: "char"
207+ .byte 0 # end of children of DIE 0xb
208+ .section .debug_abbrev,"",@progbits
209+.Ldebug_abbrev0:
210+ .uleb128 0x1 # (abbrev code)
211+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
212+ .byte 0x1 # DW_children_yes
213+ .uleb128 0x25 # (DW_AT_producer)
214+ .uleb128 0xe # (DW_FORM_strp)
215+ .uleb128 0x13 # (DW_AT_language)
216+ .uleb128 0xb # (DW_FORM_data1)
217+ .uleb128 0x3 # (DW_AT_name)
218+ .uleb128 0xe # (DW_FORM_strp)
219+ .uleb128 0x1b # (DW_AT_comp_dir)
220+ .uleb128 0xe # (DW_FORM_strp)
221+ .uleb128 0x11 # (DW_AT_low_pc)
222+ .uleb128 0x1 # (DW_FORM_addr)
223+ .uleb128 0x12 # (DW_AT_high_pc)
224+ .uleb128 0x7 # (DW_FORM_data8)
225+ .uleb128 0x10 # (DW_AT_stmt_list)
226+ .uleb128 0x17 # (DW_FORM_sec_offset)
227+ .byte 0
228+ .byte 0
229+ .uleb128 0x2 # (abbrev code)
230+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
231+ .byte 0x1 # DW_children_yes
232+ .uleb128 0x3f # (DW_AT_external)
233+ .uleb128 0x19 # (DW_FORM_flag_present)
234+ .uleb128 0x3 # (DW_AT_name)
235+ .uleb128 0x8 # (DW_FORM_string)
236+ .uleb128 0x3a # (DW_AT_decl_file)
237+ .uleb128 0xb # (DW_FORM_data1)
238+ .uleb128 0x3b # (DW_AT_decl_line)
239+ .uleb128 0xb # (DW_FORM_data1)
240+ .uleb128 0x27 # (DW_AT_prototyped)
241+ .uleb128 0x19 # (DW_FORM_flag_present)
242+ .uleb128 0x11 # (DW_AT_low_pc)
243+ .uleb128 0x1 # (DW_FORM_addr)
244+ .uleb128 0x12 # (DW_AT_high_pc)
245+ .uleb128 0x7 # (DW_FORM_data8)
246+ .uleb128 0x40 # (DW_AT_frame_base)
247+ .uleb128 0x18 # (DW_FORM_exprloc)
248+ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
249+ .uleb128 0x19 # (DW_FORM_flag_present)
250+ .uleb128 0x1 # (DW_AT_sibling)
251+ .uleb128 0x13 # (DW_FORM_ref4)
252+ .byte 0
253+ .byte 0
254+ .uleb128 0x3 # (abbrev code)
255+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
256+ .byte 0 # DW_children_no
257+ .uleb128 0x3 # (DW_AT_name)
258+ .uleb128 0xe # (DW_FORM_strp)
259+ .uleb128 0x3a # (DW_AT_decl_file)
260+ .uleb128 0xb # (DW_FORM_data1)
261+ .uleb128 0x3b # (DW_AT_decl_line)
262+ .uleb128 0xb # (DW_FORM_data1)
263+ .uleb128 0x49 # (DW_AT_type)
264+ .uleb128 0x13 # (DW_FORM_ref4)
265+ .uleb128 0x2 # (DW_AT_location)
266+ .uleb128 0x18 # (DW_FORM_exprloc)
267+ .byte 0
268+ .byte 0
269+ .uleb128 0x4 # (abbrev code)
270+ .uleb128 0x16 # (TAG: DW_TAG_typedef)
271+ .byte 0 # DW_children_no
272+ .uleb128 0x3 # (DW_AT_name)
273+ .uleb128 0xe # (DW_FORM_strp)
274+ .uleb128 0x3a # (DW_AT_decl_file)
275+ .uleb128 0xb # (DW_FORM_data1)
276+ .uleb128 0x3b # (DW_AT_decl_line)
277+ .uleb128 0xb # (DW_FORM_data1)
278+ .uleb128 0x49 # (DW_AT_type)
279+ .uleb128 0x13 # (DW_FORM_ref4)
280+ .byte 0
281+ .byte 0
282+ .uleb128 0x5 # (abbrev code)
283+ .uleb128 0x34 # (TAG: DW_TAG_variable)
284+ .byte 0 # DW_children_no
285+ .uleb128 0x3 # (DW_AT_name)
286+ .uleb128 0xe # (DW_FORM_strp)
287+ .uleb128 0x3a # (DW_AT_decl_file)
288+ .uleb128 0xb # (DW_FORM_data1)
289+ .uleb128 0x3b # (DW_AT_decl_line)
290+ .uleb128 0xb # (DW_FORM_data1)
291+ .uleb128 0x49 # (DW_AT_type)
292+ .uleb128 0x13 # (DW_FORM_ref4)
293+ .uleb128 0x2 # (DW_AT_location)
294+ .uleb128 0x18 # (DW_FORM_exprloc)
295+ .byte 0
296+ .byte 0
297+ .uleb128 0x6 # (abbrev code)
298+ .uleb128 0x34 # (TAG: DW_TAG_variable)
299+ .byte 0 # DW_children_no
300+ .uleb128 0x3 # (DW_AT_name)
301+ .uleb128 0x8 # (DW_FORM_string)
302+ .uleb128 0x3a # (DW_AT_decl_file)
303+ .uleb128 0xb # (DW_FORM_data1)
304+ .uleb128 0x3b # (DW_AT_decl_line)
305+ .uleb128 0xb # (DW_FORM_data1)
306+ .uleb128 0x49 # (DW_AT_type)
307+ .uleb128 0x13 # (DW_FORM_ref4)
308+ .uleb128 0x2 # (DW_AT_location)
309+ .uleb128 0x18 # (DW_FORM_exprloc)
310+ .byte 0
311+ .byte 0
312+ .uleb128 0x7 # (abbrev code)
313+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
314+ .byte 0 # DW_children_no
315+ .uleb128 0xb # (DW_AT_byte_size)
316+ .uleb128 0xb # (DW_FORM_data1)
317+ .uleb128 0x3e # (DW_AT_encoding)
318+ .uleb128 0xb # (DW_FORM_data1)
319+ .uleb128 0x3 # (DW_AT_name)
320+ .uleb128 0x8 # (DW_FORM_string)
321+ .byte 0
322+ .byte 0
323+ .uleb128 0x8 # (abbrev code)
324+ .uleb128 0x1 # (TAG: DW_TAG_array_type)
325+ .byte 0x1 # DW_children_yes
326+ .uleb128 0x49 # (DW_AT_type)
327+ .uleb128 0x13 # (DW_FORM_ref4)
328+ .uleb128 0x1 # (DW_AT_sibling)
329+ .uleb128 0x13 # (DW_FORM_ref4)
330+ .byte 0
331+ .byte 0
332+ .uleb128 0x9 # (abbrev code)
333+ .uleb128 0x21 # (TAG: DW_TAG_subrange_type)
334+ .byte 0 # DW_children_no
335+ .uleb128 0x49 # (DW_AT_type)
336+ .uleb128 0x13 # (DW_FORM_ref4)
337+ .uleb128 0x2f # (DW_AT_upper_bound)
338+ .uleb128 0x18 # (DW_FORM_exprloc)
339+ .byte 0
340+ .byte 0
341+ .uleb128 0xa # (abbrev code)
342+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
343+ .byte 0 # DW_children_no
344+ .uleb128 0xb # (DW_AT_byte_size)
345+ .uleb128 0xb # (DW_FORM_data1)
346+ .uleb128 0x3e # (DW_AT_encoding)
347+ .uleb128 0xb # (DW_FORM_data1)
348+ .uleb128 0x3 # (DW_AT_name)
349+ .uleb128 0xe # (DW_FORM_strp)
350+ .byte 0
351+ .byte 0
352+ .byte 0
353+ .section .debug_aranges,"",@progbits
354+ .long 0x2c # Length of Address Ranges Info
355+ .value 0x2 # DWARF Version
356+ .long .Ldebug_info0 # Offset of Compilation Unit Info
357+ .byte 0x8 # Size of Address
358+ .byte 0 # Size of Segment Descriptor
359+ .value 0 # Pad to 16 byte boundary
360+ .value 0
361+ .quad .Ltext0 # Address
362+ .quad .Letext0-.Ltext0 # Length
363+ .quad 0
364+ .quad 0
365+ .section .debug_line,"",@progbits
366+.Ldebug_line0:
367+ .section .debug_str,"MS",@progbits,1
368+.LASF4:
369+ .string "gdb.arch/x86_64-vla-pointer.c"
370+.LASF7:
371+ .string "array_t"
372+.LASF3:
373+ .string "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
374+.LASF2:
375+ .string "char"
376+.LASF1:
377+ .string "sizetype"
378+.LASF5:
379+ .string "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
380+.LASF6:
381+ .string "size"
382+.LASF0:
383+ .string "array"
384+ .ident "GCC: (GNU) 6.2.1 20160916 (Red Hat 6.2.1-2)"
385+ .section .note.GNU-stack,"",@progbits
4b0e5c1b
AM
386diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
387new file mode 100644
4b0e5c1b
AM
388--- /dev/null
389+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
140f8057
JR
390@@ -0,0 +1,45 @@
391+/* This testcase is part of GDB, the GNU debugger.
392+
393+ Copyright 2009 Free Software Foundation, Inc.
394+
395+ This program is free software; you can redistribute it and/or modify
396+ it under the terms of the GNU General Public License as published by
397+ the Free Software Foundation; either version 3 of the License, or
398+ (at your option) any later version.
399+
400+ This program is distributed in the hope that it will be useful,
401+ but WITHOUT ANY WARRANTY; without even the implied warranty of
402+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
403+ GNU General Public License for more details.
404+
405+ You should have received a copy of the GNU General Public License
406+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
407+
408+#if 0
409+
410+void
411+foo (int size)
412+{
413+ typedef char array_t[size];
414+ array_t array;
415+ int i;
416+
417+ for (i = 0; i < size; i++)
418+ array[i] = i;
419+
420+ array[0] = 0; /* break-here */
421+}
422+
423+#else
424+
425+void foo (int size);
426+
427+int
428+main (void)
429+{
430+ foo (26);
431+ foo (78);
432+ return 0;
433+}
434+
435+#endif
4b0e5c1b
AM
436diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
437new file mode 100644
4b0e5c1b
AM
438--- /dev/null
439+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
140f8057
JR
440@@ -0,0 +1,65 @@
441+# Copyright 2009 Free Software Foundation, Inc.
442+
443+# This program is free software; you can redistribute it and/or modify
444+# it under the terms of the GNU General Public License as published by
445+# the Free Software Foundation; either version 3 of the License, or
446+# (at your option) any later version.
447+#
448+# This program is distributed in the hope that it will be useful,
449+# but WITHOUT ANY WARRANTY; without even the implied warranty of
450+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
451+# GNU General Public License for more details.
452+#
453+# You should have received a copy of the GNU General Public License
454+# along with this program. If not, see <http://www.gnu.org/licenses/>.
455+
456+if ![istarget "x86_64-*-*"] then {
457+ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64."
458+ return
459+}
460+
461+set testfile x86_64-vla-pointer
462+set srcasmfile ${testfile}-foo.S
463+set srcfile ${testfile}.c
464+set binfile [standard_output_file ${testfile}]
465+set binobjfile [standard_output_file ${testfile}-foo.o]
466+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
467+ untested "Couldn't compile test program"
468+ return -1
469+}
470+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {}] != "" } {
471+ untested "Couldn't compile test program"
472+ return -1
473+}
474+
475+gdb_exit
476+gdb_start
477+gdb_reinitialize_dir $srcdir/$subdir
478+gdb_load ${binfile}
479+
480+if ![runto_main] {
481+ untested x86_64-vla-pointer
482+ return -1
483+}
484+
485+gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
486+
487+gdb_continue_to_breakpoint "break-here"
488+
489+gdb_test "whatis array" "type = array_t" "first: whatis array"
490+gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "first: whatis array_t"
491+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
492+
493+gdb_test "whatis *array" "type = char" "first: whatis *array"
494+gdb_test "ptype *array" "type = char" "first: ptype *array"
495+
496+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
497+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
498+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
499+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
500+
501+gdb_continue_to_breakpoint "break_here"
502+
503+gdb_test "whatis array" "type = array_t" "second: whatis array"
504+gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "second: whatis array_t"
505+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
4b0e5c1b
AM
506diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
507new file mode 100644
4b0e5c1b
AM
508--- /dev/null
509+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
aa964043
KK
510@@ -0,0 +1,455 @@
511+ .file "x86_64-vla-typedef.c"
512+ .section .debug_abbrev,"",@progbits
513+.Ldebug_abbrev0:
514+ .section .debug_info,"",@progbits
515+.Ldebug_info0:
516+ .section .debug_line,"",@progbits
517+.Ldebug_line0:
518+ .text
519+.Ltext0:
520+.globl foo
521+ .type foo, @function
522+foo:
523+.LFB2:
524+ .file 1 "x86_64-vla-typedef.c"
525+ .loc 1 22 0
526+ pushq %rbp
527+.LCFI0:
528+ movq %rsp, %rbp
529+.LCFI1:
530+ subq $64, %rsp
531+.LCFI2:
532+ movl %edi, -36(%rbp)
533+ .loc 1 22 0
534+ movq %rsp, %rax
535+ movq %rax, -48(%rbp)
536+ .loc 1 23 0
537+ movl -36(%rbp), %edx
538+ movslq %edx,%rax
539+ subq $1, %rax
540+ movq %rax, -24(%rbp)
541+ .loc 1 24 0
542+ movslq %edx,%rax
543+ addq $15, %rax
544+ addq $15, %rax
545+ shrq $4, %rax
546+ salq $4, %rax
547+ subq %rax, %rsp
548+ movq %rsp, -56(%rbp)
549+ movq -56(%rbp), %rax
550+ addq $15, %rax
551+ shrq $4, %rax
552+ salq $4, %rax
553+ movq %rax, -56(%rbp)
554+ movq -56(%rbp), %rax
555+ movq %rax, -16(%rbp)
556+ .loc 1 27 0
557+ movl $0, -4(%rbp)
558+ jmp .L2
559+.L3:
560+ .loc 1 28 0
561+ movl -4(%rbp), %esi
562+ movl -4(%rbp), %eax
563+ movl %eax, %ecx
564+ movq -16(%rbp), %rdx
565+ movslq %esi,%rax
566+ movb %cl, (%rdx,%rax)
567+ .loc 1 27 0
568+ addl $1, -4(%rbp)
569+.L2:
570+ movl -4(%rbp), %eax
571+ cmpl -36(%rbp), %eax
572+ jl .L3
573+ .loc 1 30 0
574+ .globl break_here
575+break_here:
576+ movq -16(%rbp), %rax
577+ movb $0, (%rax)
578+ movq -48(%rbp), %rsp
579+ .loc 1 31 0
580+ leave
581+ ret
582+.LFE2:
583+ .size foo, .-foo
584+ .section .debug_frame,"",@progbits
585+.Lframe0:
586+ .long .LECIE0-.LSCIE0
587+.LSCIE0:
588+ .long 0xffffffff
589+ .byte 0x1
590+ .string ""
591+ .uleb128 0x1
592+ .sleb128 -8
593+ .byte 0x10
594+ .byte 0xc
595+ .uleb128 0x7
596+ .uleb128 0x8
597+ .byte 0x90
598+ .uleb128 0x1
599+ .align 8
600+.LECIE0:
601+.LSFDE0:
602+ .long .LEFDE0-.LASFDE0
603+.LASFDE0:
604+ .long .Lframe0
605+ .quad .LFB2
606+ .quad .LFE2-.LFB2
607+ .byte 0x4
608+ .long .LCFI0-.LFB2
609+ .byte 0xe
610+ .uleb128 0x10
611+ .byte 0x86
612+ .uleb128 0x2
613+ .byte 0x4
614+ .long .LCFI1-.LCFI0
615+ .byte 0xd
616+ .uleb128 0x6
617+ .align 8
618+.LEFDE0:
619+ .section .eh_frame,"a",@progbits
620+.Lframe1:
621+ .long .LECIE1-.LSCIE1
622+.LSCIE1:
623+ .long 0x0
624+ .byte 0x1
625+ .string "zR"
626+ .uleb128 0x1
627+ .sleb128 -8
628+ .byte 0x10
629+ .uleb128 0x1
630+ .byte 0x3
631+ .byte 0xc
632+ .uleb128 0x7
633+ .uleb128 0x8
634+ .byte 0x90
635+ .uleb128 0x1
636+ .align 8
637+.LECIE1:
638+.LSFDE1:
639+ .long .LEFDE1-.LASFDE1
640+.LASFDE1:
641+ .long .LASFDE1-.Lframe1
642+ .long .LFB2
643+ .long .LFE2-.LFB2
644+ .uleb128 0x0
645+ .byte 0x4
646+ .long .LCFI0-.LFB2
647+ .byte 0xe
648+ .uleb128 0x10
649+ .byte 0x86
650+ .uleb128 0x2
651+ .byte 0x4
652+ .long .LCFI1-.LCFI0
653+ .byte 0xd
654+ .uleb128 0x6
655+ .align 8
656+.LEFDE1:
657+ .text
658+.Letext0:
659+ .section .debug_loc,"",@progbits
660+.Ldebug_loc0:
661+.LLST0:
662+ .quad .LFB2-.Ltext0
663+ .quad .LCFI0-.Ltext0
664+ .value 0x2
665+ .byte 0x77
666+ .sleb128 8
667+ .quad .LCFI0-.Ltext0
668+ .quad .LCFI1-.Ltext0
669+ .value 0x2
670+ .byte 0x77
671+ .sleb128 16
672+ .quad .LCFI1-.Ltext0
673+ .quad .LFE2-.Ltext0
674+ .value 0x2
675+ .byte 0x76
676+ .sleb128 16
677+ .quad 0x0
678+ .quad 0x0
679+ .section .debug_info
680+ .long .Ldebug_end - .Ldebug_start
681+.Ldebug_start:
682+ .value 0x2
683+ .long .Ldebug_abbrev0
684+ .byte 0x8
685+ .uleb128 0x1
686+ .long .LASF2
687+ .byte 0x1
688+ .long .LASF3
689+ .long .LASF4
690+ .quad .Ltext0
691+ .quad .Letext0
692+ .long .Ldebug_line0
693+ .uleb128 0x2
694+ .byte 0x1
695+ .string "foo"
696+ .byte 0x1
697+ .byte 0x16
698+ .byte 0x1
699+ .quad .LFB2
700+ .quad .LFE2
701+ .long .LLST0
702+ .long 0x83
703+ .uleb128 0x3
704+ .long .LASF5
705+ .byte 0x1
706+ .byte 0x15
707+ .long 0x83
708+ .byte 0x2
709+ .byte 0x91
710+ .sleb128 -52
711+.Ltag_typedef:
712+ .uleb128 0x4
713+ .long .LASF6
714+ .byte 0x1
715+ .byte 0x17
716+ .long .Ltag_array_type - .debug_info
717+ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */
718+ .long .LASF0
719+ .byte 0x1
720+ .byte 0x18
721+#if 1
722+ .long .Ltag_typedef - .debug_info
723+#else
724+ /* Debugging only: Skip the typedef indirection. */
725+ .long .Ltag_array_type - .debug_info
726+#endif
727+ /* DW_AT_location: DW_FORM_block1: start */
728+ .byte 0x3
729+ .byte 0x91
730+ .sleb128 -32
731+#if 0
732+ .byte 0x6 /* DW_OP_deref */
733+#else
734+ .byte 0x96 /* DW_OP_nop */
735+#endif
736+ /* DW_AT_location: DW_FORM_block1: end */
737+ .uleb128 0x6
738+ .string "i"
739+ .byte 0x1
740+ .byte 0x19
741+ .long 0x83
742+ .byte 0x2
743+ .byte 0x91
744+ .sleb128 -20
745+ .byte 0x0
746+ .uleb128 0x7
747+ .byte 0x4
748+ .byte 0x5
749+ .string "int"
750+.Ltag_array_type:
751+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
752+ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */
753+ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */
754+1: /* DW_AT_data_location: DW_FORM_block1: start */
755+ .byte 2f - 3f /* length */
756+3:
757+ .byte 0x97 /* DW_OP_push_object_address */
758+ .byte 0x6 /* DW_OP_deref */
759+2: /* DW_AT_data_location: DW_FORM_block1: end */
760+ .uleb128 0x9
761+ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */
762+ .byte 0x3
763+ .byte 0x91
764+ .sleb128 -40
765+ .byte 0x6
766+ .byte 0x0
767+ .uleb128 0xa
768+ .byte 0x8
769+ .byte 0x7
770+ .uleb128 0xb
771+ .byte 0x1
772+ .byte 0x6
773+ .long .LASF1
774+ .byte 0x0
775+.Ldebug_end:
776+ .section .debug_abbrev
777+ .uleb128 0x1
778+ .uleb128 0x11
779+ .byte 0x1
780+ .uleb128 0x25
781+ .uleb128 0xe
782+ .uleb128 0x13
783+ .uleb128 0xb
784+ .uleb128 0x3
785+ .uleb128 0xe
786+ .uleb128 0x1b
787+ .uleb128 0xe
788+ .uleb128 0x11
789+ .uleb128 0x1
790+ .uleb128 0x12
791+ .uleb128 0x1
792+ .uleb128 0x10
793+ .uleb128 0x6
794+ .byte 0x0
795+ .byte 0x0
796+ .uleb128 0x2
797+ .uleb128 0x2e
798+ .byte 0x1
799+ .uleb128 0x3f
800+ .uleb128 0xc
801+ .uleb128 0x3
802+ .uleb128 0x8
803+ .uleb128 0x3a
804+ .uleb128 0xb
805+ .uleb128 0x3b
806+ .uleb128 0xb
807+ .uleb128 0x27
808+ .uleb128 0xc
809+ .uleb128 0x11
810+ .uleb128 0x1
811+ .uleb128 0x12
812+ .uleb128 0x1
813+ .uleb128 0x40
814+ .uleb128 0x6
815+ .uleb128 0x1
816+ .uleb128 0x13
817+ .byte 0x0
818+ .byte 0x0
819+ .uleb128 0x3
820+ .uleb128 0x5
821+ .byte 0x0
822+ .uleb128 0x3
823+ .uleb128 0xe
824+ .uleb128 0x3a
825+ .uleb128 0xb
826+ .uleb128 0x3b
827+ .uleb128 0xb
828+ .uleb128 0x49
829+ .uleb128 0x13
830+ .uleb128 0x2
831+ .uleb128 0xa
832+ .byte 0x0
833+ .byte 0x0
834+ .uleb128 0x4
835+ .uleb128 0x16
836+ .byte 0x0
837+ .uleb128 0x3
838+ .uleb128 0xe
839+ .uleb128 0x3a
840+ .uleb128 0xb
841+ .uleb128 0x3b
842+ .uleb128 0xb
843+ .uleb128 0x49
844+ .uleb128 0x13
845+ .byte 0x0
846+ .byte 0x0
847+ .uleb128 0x5
848+ .uleb128 0x34
849+ .byte 0x0
850+ .uleb128 0x3
851+ .uleb128 0xe
852+ .uleb128 0x3a
853+ .uleb128 0xb
854+ .uleb128 0x3b
855+ .uleb128 0xb
856+ .uleb128 0x49
857+ .uleb128 0x13
858+ .uleb128 0x2
859+ .uleb128 0xa
860+ .byte 0x0
861+ .byte 0x0
862+ .uleb128 0x6
863+ .uleb128 0x34
864+ .byte 0x0
865+ .uleb128 0x3
866+ .uleb128 0x8
867+ .uleb128 0x3a
868+ .uleb128 0xb
869+ .uleb128 0x3b
870+ .uleb128 0xb
871+ .uleb128 0x49
872+ .uleb128 0x13
873+ .uleb128 0x2
874+ .uleb128 0xa
875+ .byte 0x0
876+ .byte 0x0
877+ .uleb128 0x7
878+ .uleb128 0x24
879+ .byte 0x0
880+ .uleb128 0xb
881+ .uleb128 0xb
882+ .uleb128 0x3e
883+ .uleb128 0xb
884+ .uleb128 0x3
885+ .uleb128 0x8
886+ .byte 0x0
887+ .byte 0x0
888+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
889+ .uleb128 0x1
890+ .byte 0x1
891+ .uleb128 0x49 /* DW_AT_type */
892+ .uleb128 0x13 /* DW_FORM_ref4 */
893+ .uleb128 0x1 /* DW_AT_sibling */
894+ .uleb128 0x13 /* DW_FORM_ref4 */
895+ .uleb128 0x50 /* DW_AT_data_location */
896+ .uleb128 0xa /* DW_FORM_block1 */
897+ .byte 0x0
898+ .byte 0x0
899+ .uleb128 0x9
900+ .uleb128 0x21
901+ .byte 0x0
902+ .uleb128 0x49 /* DW_AT_type */
903+ .uleb128 0x13 /* DW_FORM_ref4 */
904+ .uleb128 0x2f
905+ .uleb128 0xa
906+ .byte 0x0
907+ .byte 0x0
908+ .uleb128 0xa
909+ .uleb128 0x24
910+ .byte 0x0
911+ .uleb128 0xb
912+ .uleb128 0xb
913+ .uleb128 0x3e
914+ .uleb128 0xb
915+ .byte 0x0
916+ .byte 0x0
917+ .uleb128 0xb
918+ .uleb128 0x24
919+ .byte 0x0
920+ .uleb128 0xb
921+ .uleb128 0xb
922+ .uleb128 0x3e
923+ .uleb128 0xb
924+ .uleb128 0x3
925+ .uleb128 0xe
926+ .byte 0x0
927+ .byte 0x0
928+ .byte 0x0
929+ .section .debug_pubnames,"",@progbits
930+ .long 0x16
931+ .value 0x2
932+ .long .Ldebug_info0
933+ .long 0xa8
934+ .long 0x2d
935+ .string "foo"
936+ .long 0x0
937+ .section .debug_aranges,"",@progbits
938+ .long 0x2c
939+ .value 0x2
940+ .long .Ldebug_info0
941+ .byte 0x8
942+ .byte 0x0
943+ .value 0x0
944+ .value 0x0
945+ .quad .Ltext0
946+ .quad .Letext0-.Ltext0
947+ .quad 0x0
948+ .quad 0x0
949+ .section .debug_str,"MS",@progbits,1
950+.LASF0:
951+ .string "array"
952+.LASF5:
953+ .string "size"
954+.LASF3:
955+ .string "x86_64-vla-typedef.c"
956+.LASF6:
957+ .string "array_t"
958+.LASF1:
959+ .string "char"
960+.LASF4:
961+ .string "gdb.arch"
962+.LASF2:
963+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
964+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
965+ .section .note.GNU-stack,"",@progbits
4b0e5c1b
AM
966diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
967new file mode 100644
4b0e5c1b
AM
968--- /dev/null
969+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
28b292e9 970@@ -0,0 +1,45 @@
aa964043
KK
971+/* This testcase is part of GDB, the GNU debugger.
972+
973+ Copyright 2008 Free Software Foundation, Inc.
974+
975+ This program is free software; you can redistribute it and/or modify
976+ it under the terms of the GNU General Public License as published by
977+ the Free Software Foundation; either version 3 of the License, or
978+ (at your option) any later version.
979+
980+ This program is distributed in the hope that it will be useful,
981+ but WITHOUT ANY WARRANTY; without even the implied warranty of
982+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
983+ GNU General Public License for more details.
984+
985+ You should have received a copy of the GNU General Public License
986+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
987+
988+#if 0
989+
990+void
991+foo (int size)
992+{
993+ typedef char array_t[size];
994+ array_t array;
995+ int i;
996+
997+ for (i = 0; i < size; i++)
998+ array[i] = i;
999+
1000+ array[0] = 0; /* break-here */
1001+}
1002+
1003+#else
1004+
28b292e9
AM
1005+void foo (int size);
1006+
aa964043
KK
1007+int
1008+main (void)
1009+{
1010+ foo (26);
1011+ foo (78);
1012+ return 0;
1013+}
1014+
1015+#endif
4b0e5c1b
AM
1016diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
1017new file mode 100644
4b0e5c1b
AM
1018--- /dev/null
1019+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
aa964043
KK
1020@@ -0,0 +1,64 @@
1021+# Copyright 2009 Free Software Foundation, Inc.
1022+
1023+# This program is free software; you can redistribute it and/or modify
1024+# it under the terms of the GNU General Public License as published by
1025+# the Free Software Foundation; either version 3 of the License, or
1026+# (at your option) any later version.
1027+#
1028+# This program is distributed in the hope that it will be useful,
1029+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1030+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1031+# GNU General Public License for more details.
1032+#
1033+# You should have received a copy of the GNU General Public License
1034+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1035+
1036+# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
1037+
1038+if ![istarget "x86_64-*-*"] then {
1039+ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
1040+ return
1041+}
1042+
1043+set testfile x86_64-vla-typedef
1044+set srcasmfile ${testfile}-foo.S
1045+set srcfile ${testfile}.c
28b292e9
AM
1046+set binfile [standard_output_file ${testfile}]
1047+set binobjfile [standard_output_file ${testfile}-foo.o]
aa964043
KK
1048+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
1049+ untested "Couldn't compile test program"
1050+ return -1
1051+}
1052+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
1053+ untested "Couldn't compile test program"
1054+ return -1
1055+}
1056+
1057+gdb_exit
1058+gdb_start
1059+gdb_reinitialize_dir $srcdir/$subdir
1060+gdb_load ${binfile}
1061+
1062+if ![runto_main] {
1063+ untested x86_64-vla-typedef
1064+ return -1
1065+}
1066+
1067+gdb_breakpoint "break_here"
1068+
1069+gdb_continue_to_breakpoint "break_here"
1070+
1071+gdb_test "whatis array" "type = array_t" "first: whatis array"
1072+
1073+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
1074+
1075+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
1076+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
1077+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
1078+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
1079+
1080+gdb_continue_to_breakpoint "break_here"
1081+
1082+gdb_test "whatis array" "type = array_t" "second: whatis array"
1083+
1084+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
4b0e5c1b 1085diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c
4b0e5c1b
AM
1086--- a/gdb/testsuite/gdb.base/arrayidx.c
1087+++ b/gdb/testsuite/gdb.base/arrayidx.c
aa964043
KK
1088@@ -17,6 +17,13 @@
1089
1090 int array[] = {1, 2, 3, 4};
1091
1092+#ifdef __GNUC__
1093+struct
1094+ {
1095+ int a[0];
1096+ } unbound;
1097+#endif
1098+
1099 int
1100 main (void)
1101 {
4b0e5c1b 1102diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
4b0e5c1b
AM
1103--- a/gdb/testsuite/gdb.base/arrayidx.exp
1104+++ b/gdb/testsuite/gdb.base/arrayidx.exp
1105@@ -49,4 +49,12 @@ gdb_test "print array" \
aa964043 1106 "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
140f8057 1107 "print array with array-indexes on"
aa964043
KK
1108
1109-
1110+set test "p unbound.a == &unbound.a\[0\]"
1111+gdb_test_multiple $test $test {
1112+ -re " = 1\r\n$gdb_prompt $" {
1113+ pass $test
1114+ }
1115+ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
1116+ unsupported "$test (no GCC)"
1117+ }
1118+}
4b0e5c1b
AM
1119diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c
1120new file mode 100644
4b0e5c1b
AM
1121--- /dev/null
1122+++ b/gdb/testsuite/gdb.base/internal-var-field-address.c
aa964043
KK
1123@@ -0,0 +1,20 @@
1124+/* This testcase is part of GDB, the GNU debugger.
1125+
1126+ Copyright 2009 Free Software Foundation, Inc.
1127+
1128+ This program is free software; you can redistribute it and/or modify
1129+ it under the terms of the GNU General Public License as published by
1130+ the Free Software Foundation; either version 3 of the License, or
1131+ (at your option) any later version.
1132+
1133+ This program is distributed in the hope that it will be useful,
1134+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1135+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1136+ GNU General Public License for more details.
1137+
1138+ You should have received a copy of the GNU General Public License
1139+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
1140+
1141+struct {
1142+ int field;
1143+} staticstruct = { 1 };
4b0e5c1b
AM
1144diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp
1145new file mode 100644
4b0e5c1b
AM
1146--- /dev/null
1147+++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp
aa964043
KK
1148@@ -0,0 +1,26 @@
1149+# Copyright 2009 Free Software Foundation, Inc.
1150+
1151+# This program is free software; you can redistribute it and/or modify
1152+# it under the terms of the GNU General Public License as published by
1153+# the Free Software Foundation; either version 3 of the License, or
1154+# (at your option) any later version.
1155+#
1156+# This program is distributed in the hope that it will be useful,
1157+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1158+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1159+# GNU General Public License for more details.
1160+#
1161+# You should have received a copy of the GNU General Public License
1162+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1163+
1164+set test internal-var-field-address
1165+set binfile ${test}.x
1166+if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "[standard_output_file ${binfile}]" object {debug}] != "" } {
1167+ untested "Couldn't compile test program"
1168+ return -1
1169+}
1170+
1171+clean_restart $binfile
1172+
1173+gdb_test {set $varstruct = staticstruct}
1174+gdb_test {p $varstruct.field} " = 1"
4b0e5c1b
AM
1175diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c
1176new file mode 100644
4b0e5c1b
AM
1177--- /dev/null
1178+++ b/gdb/testsuite/gdb.base/vla-frame.c
aa964043
KK
1179@@ -0,0 +1,31 @@
1180+/* This testcase is part of GDB, the GNU debugger.
1181+
1182+ Copyright 2011 Free Software Foundation, Inc.
1183+
1184+ This program is free software; you can redistribute it and/or modify
1185+ it under the terms of the GNU General Public License as published by
1186+ the Free Software Foundation; either version 3 of the License, or
1187+ (at your option) any later version.
1188+
1189+ This program is distributed in the hope that it will be useful,
1190+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1191+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1192+ GNU General Public License for more details.
1193+
1194+ You should have received a copy of the GNU General Public License
1195+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
1196+
1197+#include <string.h>
1198+
1199+int
1200+main (int argc, char **argv)
1201+{
1202+ char s[2 + argc];
1203+ void (*f) (char *) = 0;
1204+
1205+ memset (s, 0, sizeof (s));
1206+ s[0] = 'X';
1207+
1208+ f (s);
1209+ return 0;
1210+}
4b0e5c1b
AM
1211diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp
1212new file mode 100644
4b0e5c1b
AM
1213--- /dev/null
1214+++ b/gdb/testsuite/gdb.base/vla-frame.exp
aa964043
KK
1215@@ -0,0 +1,38 @@
1216+# Copyright 2011 Free Software Foundation, Inc.
1217+#
1218+# This program is free software; you can redistribute it and/or modify
1219+# it under the terms of the GNU General Public License as published by
1220+# the Free Software Foundation; either version 3 of the License, or
1221+# (at your option) any later version.
1222+#
1223+# This program is distributed in the hope that it will be useful,
1224+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1225+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1226+# GNU General Public License for more details.
1227+#
1228+# You should have received a copy of the GNU General Public License
1229+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1230+
1231+set testfile vla-frame
1232+set executable ${testfile}
1233+
1234+if { [prepare_for_testing ${testfile}.exp ${executable}] } {
1235+ return -1
1236+}
1237+
1238+if ![runto_main] {
1239+ return -1
1240+}
1241+
1242+set test "continue"
1243+gdb_test_multiple $test $test {
1244+ -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" {
1245+ pass $test
1246+ }
1247+ -re "\r\n$gdb_prompt $" {
1248+ untested ${testfile}.exp
1249+ return
1250+ }
1251+}
1252+
1253+gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*"
4b0e5c1b
AM
1254diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c
1255new file mode 100644
4b0e5c1b
AM
1256--- /dev/null
1257+++ b/gdb/testsuite/gdb.base/vla-overflow.c
aa964043
KK
1258@@ -0,0 +1,30 @@
1259+/* This testcase is part of GDB, the GNU debugger.
1260+
1261+ Copyright 2008 Free Software Foundation, Inc.
1262+
1263+ This program is free software; you can redistribute it and/or modify
1264+ it under the terms of the GNU General Public License as published by
1265+ the Free Software Foundation; either version 3 of the License, or
1266+ (at your option) any later version.
1267+
1268+ This program is distributed in the hope that it will be useful,
1269+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1270+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1271+ GNU General Public License for more details.
1272+
1273+ You should have received a copy of the GNU General Public License
1274+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
1275+
1276+#include <stdlib.h>
1277+
1278+int
1279+main (int argc, char **argv)
1280+{
1281+ int array[argc];
1282+
1283+ array[0] = array[0];
1284+
1285+ abort ();
1286+
1287+ return 0;
1288+}
4b0e5c1b
AM
1289diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp
1290new file mode 100644
4b0e5c1b
AM
1291--- /dev/null
1292+++ b/gdb/testsuite/gdb.base/vla-overflow.exp
aa964043
KK
1293@@ -0,0 +1,109 @@
1294+# Copyright 2008 Free Software Foundation, Inc.
1295+
1296+# This program is free software; you can redistribute it and/or modify
1297+# it under the terms of the GNU General Public License as published by
1298+# the Free Software Foundation; either version 3 of the License, or
1299+# (at your option) any later version.
1300+#
1301+# This program is distributed in the hope that it will be useful,
1302+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1303+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1304+# GNU General Public License for more details.
1305+#
1306+# You should have received a copy of the GNU General Public License
1307+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1308+
1309+# We could crash in:
1310+# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69
1311+# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97
1312+# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL));
1313+# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496
1314+# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156
1315+# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206
1316+# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430
1317+# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840
1318+# ...
1319+# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
1320+# ...
1321+# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
1322+
1323+set testfile vla-overflow
28b292e9 1324+set shfile [standard_output_file ${testfile}-gdb.sh]
aa964043 1325+set srcfile ${testfile}.c
28b292e9 1326+set binfile [standard_output_file ${testfile}]
aa964043
KK
1327+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
1328+ untested "Couldn't compile test program"
1329+ return -1
1330+}
1331+
1332+set f [open "|getconf PAGESIZE" "r"]
1333+gets $f pagesize
1334+close $f
1335+
1336+gdb_exit
1337+gdb_start
1338+gdb_reinitialize_dir $srcdir/$subdir
1339+gdb_load ${binfile}
1340+
1341+set pid_of_gdb [exp_pid -i [board_info host fileid]]
1342+
1343+if { [runto_main] < 0 } {
1344+ untested vla-overflow
1345+ return -1
1346+}
1347+
1348+# Get the GDB memory size when we stay at main.
1349+
1350+proc memory_v_pages_get {} {
1351+ global pid_of_gdb pagesize
1352+ set fd [open "/proc/$pid_of_gdb/statm"]
1353+ gets $fd line
1354+ close $fd
1355+ # number of pages of virtual memory
1356+ scan $line "%d" drs
1357+ return $drs
1358+}
1359+
1360+set pages_found [memory_v_pages_get]
1361+
1362+# s390x with glibc-debuginfo.s390x installed used approx. 16MB.
1363+set mb_reserve 40
1364+verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve"
1365+set kb_found [expr $pages_found * $pagesize / 1024]
1366+set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024]
1367+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
1368+
1369+# Create the ulimit wrapper.
1370+set f [open $shfile "w"]
1371+puts $f "#! /bin/sh"
1372+puts $f "ulimit -v $kb_permit"
1373+puts $f "exec $GDB \"\$@\""
1374+close $f
1375+remote_exec host "chmod +x $shfile"
1376+
1377+gdb_exit
1378+set GDBold $GDB
1379+set GDB "$shfile"
1380+gdb_start
1381+set GDB $GDBold
1382+
1383+gdb_reinitialize_dir $srcdir/$subdir
1384+gdb_load ${binfile}
1385+
1386+set pid_of_gdb [exp_pid -i [board_info host fileid]]
1387+
1388+# Check the size again after the second run.
1389+# We must not stop in main as it would cache `array' and never crash later.
1390+
1391+gdb_run_cmd
1392+
1393+verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
1394+
1395+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
1396+
1397+verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
1398+
1399+# `abort' can get expressed as `*__GI_abort'.
1400+gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
1401+
1402+verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
4b0e5c1b
AM
1403diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c
1404new file mode 100644
4b0e5c1b
AM
1405--- /dev/null
1406+++ b/gdb/testsuite/gdb.base/vla.c
aa964043
KK
1407@@ -0,0 +1,55 @@
1408+/* This testcase is part of GDB, the GNU debugger.
1409+
1410+ Copyright 2008 Free Software Foundation, Inc.
1411+
1412+ This program is free software; you can redistribute it and/or modify
1413+ it under the terms of the GNU General Public License as published by
1414+ the Free Software Foundation; either version 3 of the License, or
1415+ (at your option) any later version.
1416+
1417+ This program is distributed in the hope that it will be useful,
1418+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1419+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1420+ GNU General Public License for more details.
1421+
1422+ You should have received a copy of the GNU General Public License
1423+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
1424+
1425+#include <string.h>
1426+
1427+void
1428+marker (void)
1429+{
1430+}
1431+
1432+void
1433+bar (char *a, char *b, char *c, int size)
1434+{
1435+ memset (a, '1', size);
1436+ memset (b, '2', size);
1437+ memset (c, '3', 48);
1438+}
1439+
1440+void
1441+foo (int size)
1442+{
1443+ char temp1[size];
1444+ char temp3[48];
1445+
1446+ temp1[size - 1] = '\0';
1447+ {
1448+ char temp2[size];
1449+
1450+ bar (temp1, temp2, temp3, size);
1451+
1452+ marker (); /* break-here */
1453+ }
1454+}
1455+
1456+int
1457+main (void)
1458+{
1459+ foo (26);
1460+ foo (78);
1461+ return 0;
1462+}
4b0e5c1b
AM
1463diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp
1464new file mode 100644
4b0e5c1b
AM
1465--- /dev/null
1466+++ b/gdb/testsuite/gdb.base/vla.exp
aa964043
KK
1467@@ -0,0 +1,62 @@
1468+# Copyright 2008 Free Software Foundation, Inc.
1469+
1470+# This program is free software; you can redistribute it and/or modify
1471+# it under the terms of the GNU General Public License as published by
1472+# the Free Software Foundation; either version 3 of the License, or
1473+# (at your option) any later version.
1474+#
1475+# This program is distributed in the hope that it will be useful,
1476+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1477+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1478+# GNU General Public License for more details.
1479+#
1480+# You should have received a copy of the GNU General Public License
1481+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1482+
1483+set testfile vla
1484+set srcfile ${testfile}.c
28b292e9 1485+set binfile [standard_output_file ${testfile}]
aa964043
KK
1486+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
1487+ untested "Couldn't compile test program"
1488+ return -1
1489+}
1490+
1491+gdb_exit
1492+gdb_start
1493+gdb_reinitialize_dir $srcdir/$subdir
1494+gdb_load ${binfile}
1495+
1496+if ![runto_main] {
1497+ untested vla
1498+ return -1
1499+}
1500+
1501+gdb_breakpoint [gdb_get_line_number "break-here"]
1502+
1503+gdb_continue_to_breakpoint "break-here"
1504+
1505+gdb_test "whatis temp1" "type = char \\\[26\\\]" "first: whatis temp1"
1506+gdb_test "whatis temp2" "type = char \\\[26\\\]" "first: whatis temp2"
1507+gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
1508+
1509+gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
1510+gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
1511+gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
1512+
1513+gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
1514+gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
1515+gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
1516+
1517+gdb_continue_to_breakpoint "break-here"
1518+
1519+gdb_test "whatis temp1" "type = char \\\[78\\\]" "second: whatis temp1"
1520+gdb_test "whatis temp2" "type = char \\\[78\\\]" "second: whatis temp2"
1521+gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
1522+
1523+gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
1524+gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
1525+gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
1526+
1527+gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
1528+gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
1529+gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
4b0e5c1b
AM
1530diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc
1531new file mode 100644
4b0e5c1b
AM
1532--- /dev/null
1533+++ b/gdb/testsuite/gdb.cp/gdb9593.cc
140f8057
JR
1534@@ -0,0 +1,180 @@
1535+/* This testcase is part of GDB, the GNU debugger.
1536+
1537+ Copyright 2008, 2009 Free Software Foundation, Inc.
1538+
1539+ This program is free software; you can redistribute it and/or modify
1540+ it under the terms of the GNU General Public License as published by
1541+ the Free Software Foundation; either version 3 of the License, or
1542+ (at your option) any later version.
1543+
1544+ This program is distributed in the hope that it will be useful,
1545+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1546+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1547+ GNU General Public License for more details.
1548+
1549+ You should have received a copy of the GNU General Public License
1550+ along with this program. If not, see <http://www.gnu.org/licenses/>.
1551+ */
1552+#include <iostream>
1553+
1554+using namespace std;
1555+
1556+class NextOverThrowDerivates
1557+{
1558+
1559+public:
1560+
1561+
1562+ // Single throw an exception in this function.
1563+ void function1()
1564+ {
1565+ throw 20;
1566+ }
1567+
1568+ // Throw an exception in another function.
1569+ void function2()
1570+ {
1571+ function1();
1572+ }
1573+
1574+ // Throw an exception in another function, but handle it
1575+ // locally.
1576+ void function3 ()
1577+ {
1578+ {
1579+ try
1580+ {
1581+ function1 ();
1582+ }
1583+ catch (...)
1584+ {
1585+ cout << "Caught and handled function1 exception" << endl;
1586+ }
1587+ }
1588+ }
1589+
1590+ void rethrow ()
1591+ {
1592+ try
1593+ {
1594+ function1 ();
1595+ }
1596+ catch (...)
1597+ {
1598+ throw;
1599+ }
1600+ }
1601+
1602+ void finish ()
1603+ {
1604+ // We use this to test that a "finish" here does not end up in
1605+ // this frame, but in the one above.
1606+ try
1607+ {
1608+ function1 ();
1609+ }
1610+ catch (int x)
1611+ {
1612+ }
1613+ function1 (); // marker for until
1614+ }
1615+
1616+ void until ()
1617+ {
1618+ function1 ();
1619+ function1 (); // until here
1620+ }
1621+
1622+};
1623+NextOverThrowDerivates next_cases;
1624+
1625+
1626+int main ()
1627+{
1628+ try
1629+ {
1630+ next_cases.function1 ();
1631+ }
1632+ catch (...)
1633+ {
1634+ // Discard
1635+ }
1636+
1637+ try
1638+ {
1639+ next_cases.function2 ();
1640+ }
1641+ catch (...)
1642+ {
1643+ // Discard
1644+ }
1645+
1646+ try
1647+ {
1648+ // This is duplicated so we can next over one but step into
1649+ // another.
1650+ next_cases.function2 ();
1651+ }
1652+ catch (...)
1653+ {
1654+ // Discard
1655+ }
1656+
1657+ next_cases.function3 ();
1658+
1659+ try
1660+ {
1661+ next_cases.rethrow ();
1662+ }
1663+ catch (...)
1664+ {
1665+ // Discard
1666+ }
1667+
1668+ try
1669+ {
1670+ // Another duplicate so we can test "finish".
1671+ next_cases.function2 ();
1672+ }
1673+ catch (...)
1674+ {
1675+ // Discard
1676+ }
1677+
1678+ // Another test for "finish".
1679+ try
1680+ {
1681+ next_cases.finish ();
1682+ }
1683+ catch (...)
1684+ {
1685+ }
1686+
1687+ // Test of "until".
1688+ try
1689+ {
1690+ next_cases.finish ();
1691+ }
1692+ catch (...)
1693+ {
1694+ }
1695+
1696+ // Test of "until" with an argument.
1697+ try
1698+ {
1699+ next_cases.until ();
1700+ }
1701+ catch (...)
1702+ {
1703+ }
1704+
1705+ // Test of "advance".
1706+ try
1707+ {
1708+ next_cases.until ();
1709+ }
1710+ catch (...)
1711+ {
1712+ }
1713+}
1714+
4b0e5c1b
AM
1715diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp
1716new file mode 100644
4b0e5c1b
AM
1717--- /dev/null
1718+++ b/gdb/testsuite/gdb.cp/gdb9593.exp
140f8057
JR
1719@@ -0,0 +1,182 @@
1720+# Copyright 2008, 2009 Free Software Foundation, Inc.
1721+
1722+# This program is free software; you can redistribute it and/or modify
1723+# it under the terms of the GNU General Public License as published by
1724+# the Free Software Foundation; either version 3 of the License, or
1725+# (at your option) any later version.
1726+#
1727+# This program is distributed in the hope that it will be useful,
1728+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1729+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1730+# GNU General Public License for more details.
1731+#
1732+# You should have received a copy of the GNU General Public License
1733+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1734+
1735+
1736+if $tracelevel then {
1737+ strace $tracelevel
1738+}
1739+
1740+if { [skip_cplus_tests] } { continue }
1741+
1742+set testfile "gdb9593"
1743+set srcfile ${testfile}.cc
1744+set binfile [standard_output_file $testfile]
1745+
1746+# Create and source the file that provides information about the compiler
1747+# used to compile the test case.
1748+if [get_compiler_info "c++"] {
1749+ untested gdb9593.exp
1750+ return -1
1751+}
1752+
1753+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
1754+ untested gdb9593.exp
1755+ return -1
1756+}
1757+
1758+# Some targets can't do function calls, so don't even bother with this
1759+# test.
1760+if [target_info exists gdb,cannot_call_functions] {
1761+ setup_xfail "*-*-*" 9593
1762+ fail "This target can not call functions"
1763+ continue
1764+}
1765+
1766+gdb_exit
1767+gdb_start
1768+gdb_reinitialize_dir $srcdir/$subdir
1769+gdb_load ${binfile}
1770+
1771+if ![runto_main] then {
1772+ perror "couldn't run to main"
1773+ continue
1774+}
1775+
1776+# See whether we have the needed unwinder hooks.
1777+set ok 1
1778+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
1779+ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
1780+ pass "check for unwinder hook"
1781+ }
1782+ -re "No symbol .* in current context.\r\n$gdb_prompt $" {
1783+ # Pass the test so we don't get bogus fails in the results.
1784+ pass "check for unwinder hook"
1785+ set ok 0
1786+ }
1787+}
1788+if {!$ok} {
1789+ untested gdb9593.exp
1790+ return -1
1791+}
1792+
1793+# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
1794+
1795+gdb_test "next" \
1796+ ".*catch (...).*" \
1797+ "next over a throw 1"
1798+
1799+gdb_test "next" \
1800+ ".*next_cases.function2.*" \
1801+ "next past catch 1"
1802+
1803+gdb_test "next" \
1804+ ".*catch (...).*" \
1805+ "next over a throw 2"
1806+
1807+gdb_test "next" \
1808+ ".*next_cases.function2.*" \
1809+ "next past catch 2"
1810+
1811+gdb_test "step" \
1812+ ".*function1().*" \
1813+ "step into function2 1"
1814+
1815+gdb_test "next" \
1816+ ".*catch (...).*" \
1817+ "next over a throw 3"
1818+
1819+gdb_test "next" \
1820+ ".*next_cases.function3.*" \
1821+ "next past catch 3"
1822+
1823+gdb_test "next" \
1824+ ".*next_cases.rethrow.*" \
1825+ "next over a throw 4"
1826+
1827+gdb_test "next" \
1828+ ".*catch (...).*" \
1829+ "next over a rethrow"
1830+
1831+gdb_test "next" \
1832+ ".*next_cases.function2.*" \
1833+ "next after a rethrow"
1834+
1835+gdb_test "step" \
1836+ ".*function1().*" \
1837+ "step into function2 2"
1838+
1839+gdb_test "finish" \
1840+ ".*catch (...).*" \
1841+ "finish 1"
1842+
1843+gdb_test "next" \
1844+ ".*next_cases.finish ().*" \
1845+ "next past catch 4"
1846+
1847+gdb_test "step" \
1848+ ".*function1 ().*" \
1849+ "step into finish method"
1850+
1851+gdb_test "finish" \
1852+ ".*catch (...).*" \
1853+ "finish 2"
1854+
1855+gdb_test "next" \
1856+ ".*next_cases.finish ().*" \
1857+ "next past catch 5"
1858+
1859+gdb_test "step" \
1860+ ".*function1 ().*" \
1861+ "step into finish, for until"
1862+
1863+gdb_test "until" \
1864+ ".*function1 ().*" \
1865+ "until with no argument 1"
1866+
1867+set line [gdb_get_line_number "marker for until" $testfile.cc]
1868+
1869+gdb_test "until $line" \
1870+ ".*function1 ().*" \
1871+ "next past catch 6"
1872+
1873+gdb_test "until" \
1874+ ".*catch (...).*" \
1875+ "until with no argument 2"
1876+
1877+set line [gdb_get_line_number "until here" $testfile.cc]
1878+
1879+gdb_test "next" \
1880+ ".*next_cases.until ().*" \
1881+ "next past catch 6"
1882+
1883+gdb_test "step" \
1884+ ".*function1 ().*" \
1885+ "step into until"
1886+
1887+gdb_test "until $line" \
1888+ ".*catch (...).*" \
1889+ "until-over-throw"
1890+
1891+gdb_test "next" \
1892+ ".*next_cases.until ().*" \
1893+ "next past catch 7"
1894+
1895+gdb_test "step" \
1896+ ".*function1 ().*" \
1897+ "step into until, for advance"
1898+
1899+gdb_test "advance $line" \
1900+ ".*catch (...).*" \
1901+ "advance-over-throw"
4b0e5c1b
AM
1902diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
1903new file mode 100644
4b0e5c1b
AM
1904--- /dev/null
1905+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
aa964043
KK
1906@@ -0,0 +1,246 @@
1907+/* This testcase is part of GDB, the GNU debugger.
1908+
1909+ Copyright 2010 Free Software Foundation, Inc.
1910+
1911+ This program is free software; you can redistribute it and/or modify
1912+ it under the terms of the GNU General Public License as published by
1913+ the Free Software Foundation; either version 3 of the License, or
1914+ (at your option) any later version.
1915+
1916+ This program is distributed in the hope that it will be useful,
1917+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1918+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1919+ GNU General Public License for more details.
1920+
1921+ You should have received a copy of the GNU General Public License
1922+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
1923+
1924+/* Debug information */
1925+
1926+/* We will `break *main' at the very first instruction. */
1927+#define main_length 1
1928+
1929+ .section .data
1930+vardata:
1931+ /* See DW_OP_lit3 + 1 (0-based). */
1932+ .string "seennotseen"
1933+
1934+ .section .debug_info
1935+.Lcu1_begin:
1936+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
1937+.Lcu1_start:
1938+ .2byte 2 /* DWARF version number */
1939+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
1940+ .byte 4 /* Pointer Size (in bytes) */
1941+
1942+ /* CU die */
1943+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
1944+ .4byte .Lproducer /* DW_AT_producer */
1945+ /* Use C++ to exploit a bug in parsing DW_AT_name "". */
1946+ .byte 4 /* DW_AT_language (C++) - */
1947+ .4byte main /* DW_AT_low_pc */
1948+ .byte main_length /* DW_AT_high_pc */
1949+
1950+.Larray_type:
1951+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
1952+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1953+
1954+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
1955+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1956+ .byte 0 /* DW_AT_lower_bound */
1957+ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */
1958+ .byte 0 /* End of children of die */
1959+
1960+ /* DW_AT_upper_bound is referencing an optimized-out variable. */
1961+.Larrayb_type:
1962+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
1963+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1964+
1965+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
1966+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1967+ .byte 0 /* DW_AT_lower_bound */
1968+ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */
1969+ .byte 0 /* End of children of die */
1970+
1971+ /* DW_AT_upper_bound is referencing register. */
1972+.Larrayreg_type:
1973+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
1974+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1975+
1976+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */
1977+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1978+ .byte 0 /* DW_AT_lower_bound */
1979+ .byte 2f - 1f /* DW_AT_upper_bound */
1980+1: .byte 0x50 /* DW_OP_reg0 */
1981+2:
1982+ .byte 0 /* End of children of die */
1983+
1984+.Luint_type:
1985+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
1986+ .4byte .Luint_str /* DW_AT_name */
1987+ .byte 4 /* DW_AT_byte_size */
1988+ .byte 7 /* DW_AT_encoding */
1989+
1990+.Lchar_type:
1991+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
1992+ .4byte .Lchar_str /* DW_AT_name */
1993+ .byte 1 /* DW_AT_byte_size */
1994+ .byte 6 /* DW_AT_encoding */
1995+
1996+.Llen_var:
1997+ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */
1998+ .byte 1 /* DW_AT_artificial */
1999+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2000+ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */
2001+
2002+ /* optimized-out variable for b_string. */
2003+.Llenb_var:
2004+ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */
2005+ .byte 1 /* DW_AT_artificial */
2006+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2007+
2008+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2009+ .string "a_string" /* DW_AT_name */
2010+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
2011+ .byte 2f - 1f /* DW_AT_location */
2012+1: .byte 3 /* DW_OP_addr */
2013+ .4byte vardata /* <addr> */
2014+2:
2015+
2016+ /* DW_AT_upper_bound is referencing an optimized-out variable. */
2017+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2018+ .string "b_string" /* DW_AT_name */
2019+ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */
2020+ .byte 2f - 1f /* DW_AT_location */
2021+1: .byte 3 /* DW_OP_addr */
2022+ .4byte vardata /* <addr> */
2023+2:
2024+
2025+ /* DW_AT_upper_bound is referencing register. */
2026+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2027+ .string "reg_string" /* DW_AT_name */
2028+ .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */
2029+ .byte 2f - 1f /* DW_AT_location */
2030+1: .byte 3 /* DW_OP_addr */
2031+ .4byte vardata /* <addr> */
2032+2:
2033+
2034+ .byte 0 /* End of children of CU */
2035+.Lcu1_end:
2036+
2037+ .section .debug_loc
2038+.Lloclist:
2039+.Llen_loclist:
2040+ .4byte 0 # Location list begin address
2041+ .4byte main_length # Location list end address
2042+ .value 2f-1f # Location expression size
2043+1: .byte 0x33 # DW_OP_lit3
2044+ .byte 0x9f # DW_OP_stack_value
2045+2:
2046+ .quad 0x0 # Location list terminator begin (*.LLST2)
2047+ .quad 0x0 # Location list terminator end (*.LLST2)
2048+
2049+ .section .debug_abbrev
2050+.Ldebug_abbrev0:
2051+ .uleb128 1 /* Abbrev code */
2052+ .uleb128 0x11 /* DW_TAG_compile_unit */
2053+ .byte 0x1 /* has_children */
2054+ .uleb128 0x25 /* DW_AT_producer */
2055+ .uleb128 0xe /* DW_FORM_strp */
2056+ .uleb128 0x13 /* DW_AT_language */
2057+ .uleb128 0xb /* DW_FORM_data1 */
2058+ .uleb128 0x11 /* DW_AT_low_pc */
2059+ .uleb128 0x1 /* DW_FORM_addr */
2060+ .uleb128 0x12 /* DW_AT_high_pc */
2061+ .uleb128 0xb /* DW_FORM_data1 */
2062+ .byte 0x0 /* Terminator */
2063+ .byte 0x0 /* Terminator */
2064+
2065+ .uleb128 2 /* Abbrev code */
2066+ .uleb128 0x1 /* TAG: DW_TAG_array_type */
2067+ .byte 0x1 /* DW_children_yes */
2068+ .uleb128 0x49 /* DW_AT_type */
2069+ .uleb128 0x13 /* DW_FORM_ref4 */
2070+ .byte 0x0 /* Terminator */
2071+ .byte 0x0 /* Terminator */
2072+
2073+ .uleb128 3 /* Abbrev code */
2074+ .uleb128 0x21 /* DW_TAG_subrange_type */
2075+ .byte 0x0 /* no children */
2076+ .uleb128 0x49 /* DW_AT_type */
2077+ .uleb128 0x13 /* DW_FORM_ref4 */
2078+ .uleb128 0x22 /* DW_AT_lower_bound */
2079+ .uleb128 0xb /* DW_FORM_data1 */
2080+ .uleb128 0x2f /* DW_AT_upper_bound */
2081+ .uleb128 0x13 /* DW_FORM_ref4 */
2082+ .byte 0x0 /* Terminator */
2083+ .byte 0x0 /* Terminator */
2084+
2085+ .uleb128 4 /* Abbrev code */
2086+ .uleb128 0x24 /* DW_TAG_base_type */
2087+ .byte 0x0 /* no_children */
2088+ .uleb128 0x3 /* DW_AT_name */
2089+ .uleb128 0xe /* DW_FORM_strp */
2090+ .uleb128 0xb /* DW_AT_byte_size */
2091+ .uleb128 0xb /* DW_FORM_data1 */
2092+ .uleb128 0x3e /* DW_AT_encoding */
2093+ .uleb128 0xb /* DW_FORM_data1 */
2094+ .byte 0x0 /* Terminator */
2095+ .byte 0x0 /* Terminator */
2096+
2097+ .uleb128 5 /* Abbrev code */
2098+ .uleb128 0x34 /* DW_TAG_variable */
2099+ .byte 0x0 /* no_children */
2100+ .uleb128 0x34 /* DW_AT_artificial */
2101+ .uleb128 0x0c /* DW_FORM_flag */
2102+ .uleb128 0x49 /* DW_AT_type */
2103+ .uleb128 0x13 /* DW_FORM_ref4 */
2104+ .uleb128 0x02 /* DW_AT_location */
2105+ .uleb128 0x06 /* DW_FORM_data4 */
2106+ .byte 0x0 /* Terminator */
2107+ .byte 0x0 /* Terminator */
2108+
2109+ .uleb128 6 /* Abbrev code */
2110+ .uleb128 0x34 /* DW_TAG_variable */
2111+ .byte 0x0 /* no_children */
2112+ .uleb128 0x3 /* DW_AT_name */
2113+ .uleb128 0x8 /* DW_FORM_string */
2114+ .uleb128 0x49 /* DW_AT_type */
2115+ .uleb128 0x13 /* DW_FORM_ref4 */
2116+ .uleb128 0x2 /* DW_AT_location */
2117+ .uleb128 0xa /* DW_FORM_block1 */
2118+ .byte 0x0 /* Terminator */
2119+ .byte 0x0 /* Terminator */
2120+
2121+ .uleb128 7 /* Abbrev code */
2122+ .uleb128 0x34 /* DW_TAG_variable */
2123+ .byte 0x0 /* no_children */
2124+ .uleb128 0x34 /* DW_AT_artificial */
2125+ .uleb128 0x0c /* DW_FORM_flag */
2126+ .uleb128 0x49 /* DW_AT_type */
2127+ .uleb128 0x13 /* DW_FORM_ref4 */
2128+ .byte 0x0 /* Terminator */
2129+ .byte 0x0 /* Terminator */
2130+
2131+ .uleb128 8 /* Abbrev code */
2132+ .uleb128 0x21 /* DW_TAG_subrange_type with block */
2133+ .byte 0x0 /* no children */
2134+ .uleb128 0x49 /* DW_AT_type */
2135+ .uleb128 0x13 /* DW_FORM_ref4 */
2136+ .uleb128 0x22 /* DW_AT_lower_bound */
2137+ .uleb128 0xb /* DW_FORM_data1 */
2138+ .uleb128 0x2f /* DW_AT_upper_bound */
2139+ .uleb128 0xa /* DW_FORM_block1 */
2140+ .byte 0x0 /* Terminator */
2141+ .byte 0x0 /* Terminator */
2142+
2143+ .byte 0x0 /* Terminator */
2144+
2145+/* String table */
2146+ .section .debug_str
2147+.Lproducer:
2148+ .string "GNU C 3.3.3"
2149+.Lchar_str:
2150+ .string "char"
2151+.Luint_str:
2152+ .string "unsigned int"
4b0e5c1b
AM
2153diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
2154new file mode 100644
4b0e5c1b
AM
2155--- /dev/null
2156+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
28b292e9 2157@@ -0,0 +1,66 @@
aa964043
KK
2158+# Copyright 2010 Free Software Foundation, Inc.
2159+
2160+# This program is free software; you can redistribute it and/or modify
2161+# it under the terms of the GNU General Public License as published by
2162+# the Free Software Foundation; either version 3 of the License, or
2163+# (at your option) any later version.
2164+#
2165+# This program is distributed in the hope that it will be useful,
2166+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2167+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2168+# GNU General Public License for more details.
2169+#
2170+# You should have received a copy of the GNU General Public License
2171+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2172+
2173+# Test printing variable with dynamic bounds which reference a different
2174+# (artificial in the GCC case) variable containing loclist as its location.
2175+# This testcase uses value (not address) of the referenced variable:
2176+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
2177+
2178+# This test can only be run on targets which support DWARF-2 and use gas.
2179+# For now pick a sampling of likely targets.
2180+if {![istarget *-*-linux*]
2181+ && ![istarget *-*-gnu*]
2182+ && ![istarget *-*-elf*]
2183+ && ![istarget *-*-openbsd*]
2184+ && ![istarget arm-*-eabi*]
2185+ && ![istarget powerpc-*-eabi*]} {
2186+ return 0
2187+}
2188+
2189+set testfile dw2-bound-loclist
2190+if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
2191+ return -1
2192+}
2193+
2194+# Verify it behaves at least as an unbound array without inferior.
2195+
28b292e9
AM
2196+# FIXME: FSF GDB crashes due to !has_stack_frames ().
2197+# But in practice that should not happen.
2198+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
2199+#set test "p a_string"
2200+#gdb_test_multiple $test $test {
2201+# -re " = 0x\[0-9a-f\]+ \"seennotseen\"\r\n$gdb_prompt $" {
2202+# pass $test
2203+# }
2204+# -re "No registers\\.\r\n$gdb_prompt $" {
2205+# kfail "vlaregression" $test
2206+# }
2207+#}
2208+#
2209+#gdb_test "ptype a_string" {type = char \[variable length\]}
aa964043
KK
2210+
2211+# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
2212+if ![runto "*main"] {
2213+ return -1
2214+}
2215+
2216+gdb_test "p a_string" { = "seen"}
2217+gdb_test "ptype a_string" {type = char \[4\]}
2218+
2219+gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
2220+gdb_test "ptype b_string" {type = char \[\]}
2221+
2222+# The register contains unpredictable value - the array size.
2223+gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]}
4b0e5c1b
AM
2224diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
2225new file mode 100644
4b0e5c1b
AM
2226--- /dev/null
2227+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
aa964043
KK
2228@@ -0,0 +1,42 @@
2229+/* This testcase is part of GDB, the GNU debugger.
2230+
2231+ Copyright 2004 Free Software Foundation, Inc.
2232+
2233+ This program is free software; you can redistribute it and/or modify
2234+ it under the terms of the GNU General Public License as published by
2235+ the Free Software Foundation; either version 2 of the License, or
2236+ (at your option) any later version.
2237+
2238+ This program is distributed in the hope that it will be useful,
2239+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2240+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2241+ GNU General Public License for more details.
2242+
2243+ You should have received a copy of the GNU General Public License
2244+ along with this program; if not, write to the Free Software
2245+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2246+ USA. */
2247+
2248+
2249+/* The function `func1' traced into must have debug info on offset > 0;
2250+ (DW_UNSND (attr)). This is the reason of `func0' existence. */
2251+
2252+void
2253+func0(int a, int b)
2254+{
2255+}
2256+
2257+/* `func1' being traced into must have some arguments to dump. */
2258+
2259+void
2260+func1(int a, int b)
2261+{
2262+ func0 (a,b);
2263+}
2264+
2265+int
2266+main(void)
2267+{
2268+ func1 (1, 2);
2269+ return 0;
2270+}
4b0e5c1b
AM
2271diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
2272new file mode 100644
4b0e5c1b
AM
2273--- /dev/null
2274+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
aa964043
KK
2275@@ -0,0 +1,79 @@
2276+# Copyright 2006 Free Software Foundation, Inc.
2277+
2278+# This program is free software; you can redistribute it and/or modify
2279+# it under the terms of the GNU General Public License as published by
2280+# the Free Software Foundation; either version 2 of the License, or
2281+# (at your option) any later version.
2282+#
2283+# This program is distributed in the hope that it will be useful,
2284+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2285+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2286+# GNU General Public License for more details.
2287+#
2288+# You should have received a copy of the GNU General Public License
2289+# along with this program; if not, write to the Free Software
2290+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2291+
2292+# Minimal DWARF-2 unit test
2293+
2294+# This test can only be run on targets which support DWARF-2.
2295+# For now pick a sampling of likely targets.
2296+if {![istarget *-*-linux*]
2297+ && ![istarget *-*-gnu*]
2298+ && ![istarget *-*-elf*]
2299+ && ![istarget *-*-openbsd*]
2300+ && ![istarget arm-*-eabi*]
2301+ && ![istarget powerpc-*-eabi*]} {
2302+ return 0
2303+}
2304+
2305+set testfile "dw2-stripped"
2306+set srcfile ${testfile}.c
140f8057 2307+set binfile [standard_output_file ${testfile}.x]
aa964043
KK
2308+
2309+remote_exec build "rm -f ${binfile}"
2310+
2311+# get the value of gcc_compiled
2312+if [get_compiler_info ${binfile}] {
2313+ return -1
2314+}
2315+
2316+# This test can only be run on gcc as we use additional_flags=FIXME
2317+if {$gcc_compiled == 0} {
2318+ return 0
2319+}
2320+
2321+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
2322+ return -1
2323+}
2324+
2325+remote_exec build "objcopy -R .debug_loc ${binfile}"
2326+set strip_output [remote_exec build "objdump -h ${binfile}"]
2327+
2328+set test "stripping test file preservation"
2329+if [ regexp ".debug_info " $strip_output] {
2330+ pass "$test (.debug_info preserved)"
2331+} else {
2332+ fail "$test (.debug_info got also stripped)"
2333+}
2334+
2335+set test "stripping test file functionality"
2336+if [ regexp ".debug_loc " $strip_output] {
2337+ fail "$test (.debug_loc still present)"
2338+} else {
2339+ pass "$test (.debug_loc stripped)"
2340+}
2341+
2342+gdb_exit
2343+gdb_start
2344+gdb_reinitialize_dir $srcdir/$subdir
2345+gdb_load ${binfile}
2346+
2347+# For C programs, "start" should stop in main().
2348+
2349+gdb_test "start" \
2350+ ".*main \\(\\) at .*" \
2351+ "start"
2352+gdb_test "step" \
2353+ "func.* \\(.*\\) at .*" \
2354+ "step"
4b0e5c1b
AM
2355diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
2356new file mode 100644
4b0e5c1b
AM
2357--- /dev/null
2358+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
aa964043
KK
2359@@ -0,0 +1,83 @@
2360+/* This testcase is part of GDB, the GNU debugger.
2361+
2362+ Copyright 2009 Free Software Foundation, Inc.
2363+
2364+ This program is free software; you can redistribute it and/or modify
2365+ it under the terms of the GNU General Public License as published by
2366+ the Free Software Foundation; either version 3 of the License, or
2367+ (at your option) any later version.
2368+
2369+ This program is distributed in the hope that it will be useful,
2370+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2371+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2372+ GNU General Public License for more details.
2373+
2374+ You should have received a copy of the GNU General Public License
2375+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2376+
2377+/* Debug information */
2378+
2379+ .section .debug_info
2380+.Lcu1_begin:
2381+ /* CU header */
2382+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2383+.Lcu1_start:
2384+ .2byte 2 /* DWARF Version */
2385+ .4byte .Labbrev1_begin /* Offset into abbrev section */
2386+ .byte 4 /* Pointer size */
2387+
2388+ /* CU die */
2389+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2390+ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */
2391+ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */
2392+ .byte 1 /* DW_AT_language (C) */
2393+
2394+.Ltype_uchar:
2395+ .uleb128 2 /* Abbrev: DW_TAG_structure_type */
2396+ .ascii "some_struct\0" /* DW_AT_name */
2397+
2398+ .uleb128 3 /* Abbrev: DW_TAG_member */
2399+ .ascii "field\0" /* DW_AT_name */
2400+ .byte 0 /* DW_AT_data_member_location */
2401+
2402+ .byte 0 /* End of children of some_struct */
2403+
2404+ .byte 0 /* End of children of CU */
2405+
2406+.Lcu1_end:
2407+
2408+/* Abbrev table */
2409+ .section .debug_abbrev
2410+.Labbrev1_begin:
2411+ .uleb128 1 /* Abbrev code */
2412+ .uleb128 0x11 /* DW_TAG_compile_unit */
2413+ .byte 1 /* has_children */
2414+ .uleb128 0x3 /* DW_AT_name */
2415+ .uleb128 0x8 /* DW_FORM_string */
2416+ .uleb128 0x25 /* DW_AT_producer */
2417+ .uleb128 0x8 /* DW_FORM_string */
2418+ .uleb128 0x13 /* DW_AT_language */
2419+ .uleb128 0xb /* DW_FORM_data1 */
2420+ .byte 0x0 /* Terminator */
2421+ .byte 0x0 /* Terminator */
2422+
2423+ .uleb128 2 /* Abbrev code */
2424+ .uleb128 0x13 /* DW_TAG_structure_type */
2425+ .byte 1 /* has_children */
2426+ .uleb128 0x3 /* DW_AT_name */
2427+ .uleb128 0x8 /* DW_FORM_string */
2428+ .byte 0x0 /* Terminator */
2429+ .byte 0x0 /* Terminator */
2430+
2431+ .uleb128 3 /* Abbrev code */
2432+ .uleb128 0x0d /* DW_TAG_member */
2433+ .byte 0 /* has_children */
2434+ .uleb128 0x3 /* DW_AT_name */
2435+ .uleb128 0x8 /* DW_FORM_string */
2436+ .uleb128 0x38 /* DW_AT_data_member_location */
2437+ .uleb128 0x0b /* DW_FORM_data1 */
2438+ .byte 0x0 /* Terminator */
2439+ .byte 0x0 /* Terminator */
2440+
2441+ .byte 0x0 /* Terminator */
2442+ .byte 0x0 /* Terminator */
4b0e5c1b
AM
2443diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
2444new file mode 100644
4b0e5c1b
AM
2445--- /dev/null
2446+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
aa964043
KK
2447@@ -0,0 +1,37 @@
2448+# Copyright 2009 Free Software Foundation, Inc.
2449+
2450+# This program is free software; you can redistribute it and/or modify
2451+# it under the terms of the GNU General Public License as published by
2452+# the Free Software Foundation; either version 3 of the License, or
2453+# (at your option) any later version.
2454+#
2455+# This program is distributed in the hope that it will be useful,
2456+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2457+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2458+# GNU General Public License for more details.
2459+#
2460+# You should have received a copy of the GNU General Public License
2461+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2462+
2463+# This test can only be run on targets which support DWARF-2 and use gas.
2464+# For now pick a sampling of likely targets.
2465+if {![istarget *-*-linux*]
2466+ && ![istarget *-*-gnu*]
2467+ && ![istarget *-*-elf*]
2468+ && ![istarget *-*-openbsd*]
2469+ && ![istarget arm-*-eabi*]
2470+ && ![istarget powerpc-*-eabi*]} {
2471+ return 0
2472+}
2473+
2474+set testfile "dw2-struct-member-data-location"
2475+set srcfile ${testfile}.S
2476+set binfile ${testfile}.x
2477+
2478+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "[standard_output_file ${binfile}]" object {nodebug}] != "" } {
2479+ return -1
2480+}
2481+
2482+clean_restart $binfile
2483+
2484+gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
4b0e5c1b
AM
2485diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
2486new file mode 100644
4b0e5c1b
AM
2487--- /dev/null
2488+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
aa964043
KK
2489@@ -0,0 +1,121 @@
2490+/* This testcase is part of GDB, the GNU debugger.
2491+
2492+ Copyright 2012 Free Software Foundation, Inc.
2493+
2494+ This program is free software; you can redistribute it and/or modify
2495+ it under the terms of the GNU General Public License as published by
2496+ the Free Software Foundation; either version 3 of the License, or
2497+ (at your option) any later version.
2498+
2499+ This program is distributed in the hope that it will be useful,
2500+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2501+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2502+ GNU General Public License for more details.
2503+
2504+ You should have received a copy of the GNU General Public License
2505+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2506+
2507+/* Debug information */
2508+
2509+ .section .data
2510+vardata:
2511+ .rept 129
2512+ .ascii "x"
2513+ .endr
2514+ .ascii "UNSEEN\0"
2515+
2516+ .section .debug_info
2517+.Lcu1_begin:
2518+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2519+.Lcu1_start:
2520+ .2byte 2 /* DWARF version number */
2521+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
2522+ .byte 4 /* Pointer Size (in bytes) */
2523+
2524+ /* CU die */
2525+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2526+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
2527+ .byte 2 /* DW_AT_language (C) - */
2528+
2529+.Larray_type:
2530+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
2531+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
2532+
2533+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */
2534+ .byte 0 /* DW_AT_lower_bound */
2535+ .byte 128 /* DW_AT_upper_bound */
2536+
2537+ .byte 0 /* End of children of die */
2538+
2539+.Lchar_type:
2540+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
2541+ .ascii "char\0" /* DW_AT_name */
2542+ .byte 1 /* DW_AT_byte_size */
2543+ .byte 6 /* DW_AT_encoding */
2544+
2545+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2546+ .ascii "notype_string\0" /* DW_AT_name */
2547+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
2548+ .byte 2f - 1f /* DW_AT_location */
2549+1: .byte 3 /* DW_OP_addr */
2550+ .4byte vardata /* <addr> */
2551+2:
2552+
2553+ .byte 0 /* End of children of CU */
2554+.Lcu1_end:
2555+
2556+ .section .debug_abbrev
2557+.Ldebug_abbrev0:
2558+ .uleb128 1 /* Abbrev code */
2559+ .uleb128 0x11 /* DW_TAG_compile_unit */
2560+ .byte 0x1 /* has_children */
2561+ .uleb128 0x25 /* DW_AT_producer */
2562+ .uleb128 0x8 /* DW_FORM_string */
2563+ .uleb128 0x13 /* DW_AT_language */
2564+ .uleb128 0xb /* DW_FORM_data1 */
2565+ .byte 0x0 /* Terminator */
2566+ .byte 0x0 /* Terminator */
2567+
2568+ .uleb128 2 /* Abbrev code */
2569+ .uleb128 0x1 /* TAG: DW_TAG_array_type */
2570+ .byte 0x1 /* DW_children_yes */
2571+ .uleb128 0x49 /* DW_AT_type */
2572+ .uleb128 0x13 /* DW_FORM_ref4 */
2573+ .byte 0x0 /* Terminator */
2574+ .byte 0x0 /* Terminator */
2575+
2576+ .uleb128 4 /* Abbrev code */
2577+ .uleb128 0x24 /* DW_TAG_base_type */
2578+ .byte 0x0 /* no_children */
2579+ .uleb128 0x3 /* DW_AT_name */
2580+ .uleb128 0x8 /* DW_FORM_string */
2581+ .uleb128 0xb /* DW_AT_byte_size */
2582+ .uleb128 0xb /* DW_FORM_data1 */
2583+ .uleb128 0x3e /* DW_AT_encoding */
2584+ .uleb128 0xb /* DW_FORM_data1 */
2585+ .byte 0x0 /* Terminator */
2586+ .byte 0x0 /* Terminator */
2587+
2588+ .uleb128 6 /* Abbrev code */
2589+ .uleb128 0x34 /* DW_TAG_variable */
2590+ .byte 0x0 /* no_children */
2591+ .uleb128 0x3 /* DW_AT_name */
2592+ .uleb128 0x8 /* DW_FORM_string */
2593+ .uleb128 0x49 /* DW_AT_type */
2594+ .uleb128 0x13 /* DW_FORM_ref4 */
2595+ .uleb128 0x2 /* DW_AT_location */
2596+ .uleb128 0xa /* DW_FORM_block1 */
2597+ .byte 0x0 /* Terminator */
2598+ .byte 0x0 /* Terminator */
2599+
2600+ .uleb128 8 /* Abbrev code */
2601+ .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */
2602+ .byte 0x0 /* no children */
2603+ .uleb128 0x22 /* DW_AT_lower_bound */
2604+ .uleb128 0xb /* DW_FORM_data1 */
2605+ .uleb128 0x2f /* DW_AT_upper_bound */
2606+ .uleb128 0xb /* DW_FORM_data1 */
2607+ .byte 0x0 /* Terminator */
2608+ .byte 0x0 /* Terminator */
2609+
2610+ .byte 0x0 /* Terminator */
4b0e5c1b
AM
2611diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
2612new file mode 100644
4b0e5c1b
AM
2613--- /dev/null
2614+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
aa964043
KK
2615@@ -0,0 +1,39 @@
2616+# Copyright 2012 Free Software Foundation, Inc.
2617+
2618+# This program is free software; you can redistribute it and/or modify
2619+# it under the terms of the GNU General Public License as published by
2620+# the Free Software Foundation; either version 3 of the License, or
2621+# (at your option) any later version.
2622+#
2623+# This program is distributed in the hope that it will be useful,
2624+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2625+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2626+# GNU General Public License for more details.
2627+#
2628+# You should have received a copy of the GNU General Public License
2629+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2630+load_lib dwarf.exp
2631+
2632+# https://bugzilla.redhat.com/show_bug.cgi?id=806920
2633+# read_subrange_type <TYPE_CODE (base_type) == TYPE_CODE_VOID> reinitialization
2634+# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without
2635+# specified DW_AT_type, present only in XLF produced code.
2636+
2637+# This test can only be run on targets which support DWARF-2 and use gas.
2638+if {![dwarf2_support]} {
2639+ return 0
2640+}
2641+
2642+set testfile dw2-subrange-no-type
2643+set srcfile ${testfile}.S
2644+set executable ${testfile}.x
2645+set binfile [standard_output_file ${executable}]
2646+
2647+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
2648+ return -1
2649+}
2650+
2651+clean_restart $executable
2652+
2653+gdb_test "ptype notype_string" {type = char \[129\]}
2654+gdb_test "p notype_string" " = 'x' <repeats 129 times>"
4b0e5c1b
AM
2655diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
2656new file mode 100644
4b0e5c1b
AM
2657--- /dev/null
2658+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
aa964043
KK
2659@@ -0,0 +1,42 @@
2660+# Copyright 2009 Free Software Foundation, Inc.
2661+
2662+# This program is free software; you can redistribute it and/or modify
2663+# it under the terms of the GNU General Public License as published by
2664+# the Free Software Foundation; either version 2 of the License, or
2665+# (at your option) any later version.
2666+#
2667+# This program is distributed in the hope that it will be useful,
2668+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2669+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2670+# GNU General Public License for more details.
2671+#
2672+# You should have received a copy of the GNU General Public License
2673+# along with this program; if not, write to the Free Software
2674+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2675+
2676+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2677+
2678+# This file is part of the gdb testsuite. Array element stride must not be
2679+# specified in the number of elements but in a number of bytes instead.
2680+# Original problem:
2681+# (gdb) p c40pt(1)
2682+# $1 = '0-hello', ' ' <repeats 33 times>
2683+# (gdb) p c40pt(2)
2684+# warning: Fortran array stride not divisible by the element size
2685+
2686+set testfile dwarf-stride
2687+set srcfile ${testfile}.f90
2688+
2689+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
2690+ return -1
2691+}
2692+
2693+if ![runto MAIN__] then {
2694+ perror "couldn't run to breakpoint MAIN__"
2695+ continue
2696+}
2697+
2698+gdb_breakpoint [gdb_get_line_number "break-here"]
2699+gdb_continue_to_breakpoint "break-here" ".*break-here.*"
2700+gdb_test "p c40pt(1)" " = '0-hello.*"
2701+gdb_test "p c40pt(2)" " = '1-hello.*"
4b0e5c1b
AM
2702diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
2703new file mode 100644
4b0e5c1b
AM
2704--- /dev/null
2705+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
aa964043
KK
2706@@ -0,0 +1,40 @@
2707+! Copyright 2009 Free Software Foundation, Inc.
2708+!
2709+! This program is free software; you can redistribute it and/or modify
2710+! it under the terms of the GNU General Public License as published by
2711+! the Free Software Foundation; either version 2 of the License, or
2712+! (at your option) any later version.
2713+!
2714+! This program is distributed in the hope that it will be useful,
2715+! but WITHOUT ANY WARRANTY; without even the implied warranty of
2716+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2717+! GNU General Public License for more details.
2718+!
2719+! You should have received a copy of the GNU General Public License
2720+! along with this program; if not, write to the Free Software
2721+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2722+!
2723+! File written by Alan Matsuoka.
2724+
2725+program repro
2726+
2727+ type small_stride
2728+ character*40 long_string
2729+ integer small_pad
2730+ end type small_stride
2731+
2732+ type(small_stride), dimension (20), target :: unpleasant
2733+ character*40, pointer, dimension(:):: c40pt
2734+
2735+ integer i
2736+
2737+ do i = 0,19
2738+ unpleasant(i+1)%small_pad = i+1
2739+ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
2740+ end do
2741+
2742+ c40pt => unpleasant%long_string
2743+
2744+ print *, c40pt ! break-here
2745+
2746+end program repro
4b0e5c1b
AM
2747diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
2748new file mode 100644
4b0e5c1b
AM
2749--- /dev/null
2750+++ b/gdb/testsuite/gdb.fortran/dynamic.exp
140f8057 2751@@ -0,0 +1,154 @@
aa964043
KK
2752+# Copyright 2007 Free Software Foundation, Inc.
2753+
2754+# This program is free software; you can redistribute it and/or modify
2755+# it under the terms of the GNU General Public License as published by
2756+# the Free Software Foundation; either version 2 of the License, or
2757+# (at your option) any later version.
2758+#
2759+# This program is distributed in the hope that it will be useful,
2760+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2761+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2762+# GNU General Public License for more details.
2763+#
2764+# You should have received a copy of the GNU General Public License
2765+# along with this program; if not, write to the Free Software
2766+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2767+
2768+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2769+
2770+# This file is part of the gdb testsuite. It contains tests for dynamically
2771+# allocated Fortran arrays.
2772+# It depends on the GCC dynamic Fortran arrays DWARF support:
2773+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
2774+
2775+set testfile "dynamic"
2776+set srcfile ${testfile}.f90
28b292e9 2777+set binfile [standard_output_file ${testfile}]
aa964043
KK
2778+
2779+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
2780+ untested "Couldn't compile ${srcfile}"
2781+ return -1
2782+}
2783+
2784+gdb_exit
2785+gdb_start
2786+gdb_reinitialize_dir $srcdir/$subdir
2787+gdb_load ${binfile}
2788+
2789+if ![runto MAIN__] then {
2790+ perror "couldn't run to breakpoint MAIN__"
2791+ continue
2792+}
2793+
2794+gdb_breakpoint [gdb_get_line_number "varx-init"]
2795+gdb_continue_to_breakpoint "varx-init"
140f8057
JR
2796+
2797+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
2798+# Do not: gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx unallocated"
2799+# Do not: gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx unallocated"
2800+# Do not: gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) unallocated"
2801+# Do not: gdb_test "p varx(1,5,17)=1" {no such vector element \(vector not allocated\)} "p varx(1,5,17)=1 unallocated"
2802+# Do not: gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) unallocated"
aa964043
KK
2803+
2804+gdb_breakpoint [gdb_get_line_number "varx-allocated"]
2805+gdb_continue_to_breakpoint "varx-allocated"
2806+# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
e28f2cc1 2807+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4), allocatable \\(6,5:15,17:28\\)" "ptype varx allocated"
aa964043
KK
2808+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
2809+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
2810+
2811+gdb_breakpoint [gdb_get_line_number "varx-filled"]
2812+gdb_continue_to_breakpoint "varx-filled"
2813+gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
2814+gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
2815+gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
2816+gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
140f8057
JR
2817+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
2818+# Do not: gdb_test "p varv" "\\$\[0-9\]* = <not associated>" "p varv unassociated"
2819+# Do not: gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv unassociated"
aa964043
KK
2820+
2821+set test "output varx"
2822+gdb_test_multiple $test $test {
2823+ -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" {
2824+ pass $test
2825+ }
2826+}
2827+
2828+gdb_breakpoint [gdb_get_line_number "varv-associated"]
2829+gdb_continue_to_breakpoint "varv-associated"
2830+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
2831+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
2832+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
2833+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
e28f2cc1 2834+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4), allocatable \\(6,5:15,17:28\\)" "ptype varx with varv associated"
aa964043
KK
2835+# Intel Fortran Compiler 10.1.008 uses the pointer type.
2836+gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
2837+
2838+gdb_breakpoint [gdb_get_line_number "varv-filled"]
2839+gdb_continue_to_breakpoint "varv-filled"
2840+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
2841+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
2842+
2843+gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
2844+gdb_continue_to_breakpoint "varv-deassociated"
2845+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
2846+gdb_test "p varv" "\\$\[0-9\]* = (<not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated"
140f8057 2847+gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv deassociated"
aa964043 2848+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
28b292e9
AM
2849+gdb_test "p varv(1,5,17)" {no such vector element \(vector not associated\)}
2850+gdb_test "ptype varv(1,5,17)" {no such vector element \(vector not associated\)}
aa964043
KK
2851+
2852+gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
2853+gdb_continue_to_breakpoint "varx-deallocated"
2854+gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx deallocated"
e28f2cc1 2855+gdb_test "ptype varx" {type = real\(kind=4\), allocatable \(:,:,:\)} "ptype varx deallocated"
aa964043 2856+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
28b292e9
AM
2857+gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) deallocated"
2858+gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) deallocated"
aa964043
KK
2859+
2860+gdb_breakpoint [gdb_get_line_number "vary-passed"]
2861+gdb_continue_to_breakpoint "vary-passed"
2862+# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
2863+gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
2864+
2865+gdb_breakpoint [gdb_get_line_number "vary-filled"]
2866+gdb_continue_to_breakpoint "vary-filled"
2867+gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
2868+gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
2869+gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
2870+gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
2871+# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
2872+gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
2873+
2874+gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
2875+gdb_continue_to_breakpoint "varw-almostfilled"
2876+gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
2877+gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
2878+# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
2879+gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
2880+# "up" works with GCC but other Fortran compilers may copy the values into the
2881+# outer function only on the exit of the inner function.
2882+# We need both variants as depending on the arch we optionally may still be
2883+# executing the caller line or not after `finish'.
2884+gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))"
2885+gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
2886+gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
2887+gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
2888+gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
2889+
2890+gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
2891+gdb_continue_to_breakpoint "varz-almostfilled"
2892+# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
2893+gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
2894+# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
2895+# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
2896+gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
2897+gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
2898+gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
2899+gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
2900+# maps to foo::vary(1,1)
2901+gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
2902+# maps to foo::vary(2,2)
2903+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
2904+# maps to foo::vary(1,3)
2905+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
4b0e5c1b
AM
2906diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
2907new file mode 100644
4b0e5c1b
AM
2908--- /dev/null
2909+++ b/gdb/testsuite/gdb.fortran/dynamic.f90
aa964043
KK
2910@@ -0,0 +1,98 @@
2911+! Copyright 2007 Free Software Foundation, Inc.
2912+!
2913+! This program is free software; you can redistribute it and/or modify
2914+! it under the terms of the GNU General Public License as published by
2915+! the Free Software Foundation; either version 2 of the License, or
2916+! (at your option) any later version.
2917+!
2918+! This program is distributed in the hope that it will be useful,
2919+! but WITHOUT ANY WARRANTY; without even the implied warranty of
2920+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2921+! GNU General Public License for more details.
2922+!
2923+! You should have received a copy of the GNU General Public License
2924+! along with this program; if not, write to the Free Software
2925+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2926+!
2927+! Ihis file is the Fortran source file for dynamic.exp.
2928+! Original file written by Jakub Jelinek <jakub@redhat.com>.
2929+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
2930+
2931+subroutine baz
2932+ real, target, allocatable :: varx (:, :, :)
2933+ real, pointer :: varv (:, :, :)
2934+ real, target :: varu (1, 2, 3)
2935+ logical :: l
2936+ allocate (varx (1:6, 5:15, 17:28)) ! varx-init
2937+ l = allocated (varx)
2938+ varx(:, :, :) = 6 ! varx-allocated
2939+ varx(1, 5, 17) = 7
2940+ varx(2, 6, 18) = 8
2941+ varx(6, 15, 28) = 9
2942+ varv => varx ! varx-filled
2943+ l = associated (varv)
2944+ varv(3, 7, 19) = 10 ! varv-associated
2945+ varv => null () ! varv-filled
2946+ l = associated (varv)
2947+ deallocate (varx) ! varv-deassociated
2948+ l = allocated (varx)
2949+ varu(:, :, :) = 10 ! varx-deallocated
2950+ allocate (varv (1:6, 5:15, 17:28))
2951+ l = associated (varv)
2952+ varv(:, :, :) = 6
2953+ varv(1, 5, 17) = 7
2954+ varv(2, 6, 18) = 8
2955+ varv(6, 15, 28) = 9
2956+ deallocate (varv)
2957+ l = associated (varv)
2958+ varv => varu
2959+ varv(1, 1, 1) = 6
2960+ varv(1, 2, 3) = 7
2961+ l = associated (varv)
2962+end subroutine baz
2963+subroutine foo (vary, varw)
2964+ real :: vary (:, :)
2965+ real :: varw (:, :, :)
2966+ vary(:, :) = 4 ! vary-passed
2967+ vary(1, 1) = 8
2968+ vary(2, 2) = 9
2969+ vary(1, 3) = 10
2970+ varw(:, :, :) = 5 ! vary-filled
2971+ varw(1, 1, 1) = 6
2972+ varw(2, 2, 2) = 7 ! varw-almostfilled
2973+end subroutine foo
2974+subroutine bar (varz, vart)
2975+ real :: varz (*)
2976+ real :: vart (2:11, 7:*)
2977+ varz(1:3) = 4
2978+ varz(2) = 5 ! varz-almostfilled
2979+ vart(2,7) = vart(2,7)
2980+end subroutine bar
2981+program test
2982+ interface
2983+ subroutine foo (vary, varw)
2984+ real :: vary (:, :)
2985+ real :: varw (:, :, :)
2986+ end subroutine
2987+ end interface
2988+ interface
2989+ subroutine bar (varz, vart)
2990+ real :: varz (*)
2991+ real :: vart (2:11, 7:*)
2992+ end subroutine
2993+ end interface
2994+ real :: x (10, 10), y (5), z(8, 8, 8)
2995+ x(:,:) = 1
2996+ y(:) = 2
2997+ z(:,:,:) = 3
2998+ call baz
2999+ call foo (x, z(2:6, 4:7, 6:8))
3000+ call bar (y, x)
3001+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
3002+ if (x (1, 3) .ne. 10) call abort
3003+ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
3004+ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
3005+ call foo (transpose (x), z)
3006+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
3007+ if (x (3, 1) .ne. 10) call abort
3008+end
4b0e5c1b
AM
3009diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
3010new file mode 100644
4b0e5c1b
AM
3011--- /dev/null
3012+++ b/gdb/testsuite/gdb.fortran/string.exp
aa964043
KK
3013@@ -0,0 +1,59 @@
3014+# Copyright 2008 Free Software Foundation, Inc.
3015+
3016+# This program is free software; you can redistribute it and/or modify
3017+# it under the terms of the GNU General Public License as published by
3018+# the Free Software Foundation; either version 2 of the License, or
3019+# (at your option) any later version.
3020+#
3021+# This program is distributed in the hope that it will be useful,
3022+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3023+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3024+# GNU General Public License for more details.
3025+#
3026+# You should have received a copy of the GNU General Public License
3027+# along with this program; if not, write to the Free Software
3028+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3029+
3030+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
3031+
3032+# This file is part of the gdb testsuite. It contains tests for Fortran
3033+# strings with dynamic length.
3034+
3035+set testfile "string"
3036+set srcfile ${testfile}.f90
28b292e9 3037+set binfile [standard_output_file ${testfile}]
aa964043
KK
3038+
3039+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
3040+ untested "Couldn't compile ${srcfile}"
3041+ return -1
3042+}
3043+
3044+gdb_exit
3045+gdb_start
3046+gdb_reinitialize_dir $srcdir/$subdir
3047+gdb_load ${binfile}
3048+
3049+if ![runto MAIN__] then {
3050+ perror "couldn't run to breakpoint MAIN__"
3051+ continue
3052+}
3053+
3054+gdb_breakpoint [gdb_get_line_number "var-init"]
3055+gdb_continue_to_breakpoint "var-init"
3056+gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
3057+gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
3058+gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
3059+gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
3060+gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
3061+gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
3062+gdb_test "p c" "\\$\[0-9\]* = 'c'"
3063+gdb_test "p d" "\\$\[0-9\]* = 'd '"
3064+gdb_test "p e" "\\$\[0-9\]* = 'g '"
3065+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)"
3066+gdb_test "p *e" "Attempt to take contents of a non-pointer value."
3067+gdb_test "p *f" "Attempt to take contents of a non-pointer value."
3068+
3069+gdb_breakpoint [gdb_get_line_number "var-finish"]
3070+gdb_continue_to_breakpoint "var-finish"
3071+gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set"
3072+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set"
4b0e5c1b
AM
3073diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
3074new file mode 100644
4b0e5c1b
AM
3075--- /dev/null
3076+++ b/gdb/testsuite/gdb.fortran/string.f90
aa964043
KK
3077@@ -0,0 +1,37 @@
3078+! Copyright 2008 Free Software Foundation, Inc.
3079+!
3080+! This program is free software; you can redistribute it and/or modify
3081+! it under the terms of the GNU General Public License as published by
3082+! the Free Software Foundation; either version 2 of the License, or
3083+! (at your option) any later version.
3084+!
3085+! This program is distributed in the hope that it will be useful,
3086+! but WITHOUT ANY WARRANTY; without even the implied warranty of
3087+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3088+! GNU General Public License for more details.
3089+!
3090+! You should have received a copy of the GNU General Public License
3091+! along with this program; if not, write to the Free Software
3092+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3093+!
3094+! Ihis file is the Fortran source file for dynamic.exp.
3095+! Original file written by Jakub Jelinek <jakub@redhat.com>.
3096+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3097+
3098+subroutine foo (e, f)
3099+ character (len=1) :: c
3100+ character (len=8) :: d
3101+ character (len=*) :: e
3102+ character (len=*) :: f (1:7, 8:10)
3103+ c = 'c'
3104+ d = 'd'
3105+ e = 'e' ! var-init
3106+ f = 'f'
3107+ f(1,9) = 'f2'
3108+ c = 'c' ! var-finish
3109+end subroutine foo
3110+ character (len=4) :: g, h (1:7, 8:10)
3111+ g = 'g'
3112+ h = 'h'
3113+ call foo (g, h)
3114+end
4b0e5c1b
AM
3115diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp
3116new file mode 100644
4b0e5c1b
AM
3117--- /dev/null
3118+++ b/gdb/testsuite/gdb.fortran/subrange.exp
aa964043
KK
3119@@ -0,0 +1,72 @@
3120+# Copyright 2011 Free Software Foundation, Inc.
3121+
3122+# This program is free software; you can redistribute it and/or modify
3123+# it under the terms of the GNU General Public License as published by
3124+# the Free Software Foundation; either version 3 of the License, or
3125+# (at your option) any later version.
3126+#
3127+# This program is distributed in the hope that it will be useful,
3128+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3129+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3130+# GNU General Public License for more details.
3131+#
3132+# You should have received a copy of the GNU General Public License
3133+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3134+
3135+if { [skip_fortran_tests] } { return -1 }
3136+
3137+set testfile "subrange"
3138+set srcfile ${testfile}.f90
3139+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
3140+ return -1
3141+}
3142+
3143+if ![runto MAIN__] {
3144+ perror "Couldn't run to MAIN__"
3145+ continue
3146+}
3147+
3148+# Depending on the compiler version being used, the name of the 4-byte integer
3149+# and real types can be printed differently. For instance, gfortran-4.1 uses
3150+# "int4" whereas gfortran-4.3 uses "int(kind=4)".
3151+set int4 "(int4|integer\\(kind=4\\))"
3152+
3153+gdb_breakpoint [gdb_get_line_number "break-static"]
3154+gdb_continue_to_breakpoint "break-static" ".*break-static.*"
3155+
3156+foreach var {a alloc ptr} {
3157+ global pf_prefix
3158+ set old_prefix $pf_prefix
3159+ lappend pf_prefix "$var:"
3160+
3161+ setup_kfail "*-*-*" "vlaregression/9999"
3162+ gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
3163+ setup_kfail "*-*-*" "vlaregression/9999"
3164+ gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
3165+ setup_kfail "*-*-*" "vlaregression/9999"
3166+ gdb_test "p $var (1, 2:)" { = \(21, 31\)}
3167+ setup_kfail "*-*-*" "vlaregression/9999"
3168+ gdb_test "p $var (2, :2)" { = \(12, 22\)}
3169+ setup_kfail "*-*-*" "vlaregression/9999"
3170+ gdb_test "p $var (3, 2:2)" { = \(23\)}
3171+ setup_kfail "*-*-*" "vlaregression/9999"
3172+ gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
3173+ setup_kfail "*-*-*" "vlaregression/9999"
3174+ gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
3175+ setup_kfail "*-*-*" "vlaregression/9999"
3176+ gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
3177+ setup_kfail "*-*-*" "vlaregression/9999"
3178+ gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
3179+ setup_kfail "*-*-*" "vlaregression/9999"
3180+ gdb_test "p $var (:)" "Wrong number of subscripts"
3181+ setup_kfail "*-*-*" "vlaregression/9999"
3182+ gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
3183+
3184+ set pf_prefix $old_prefix
3185+}
3186+
3187+gdb_test_no_output {set $a=a}
3188+delete_breakpoints
3189+gdb_unload
3190+setup_kfail "*-*-*" "vlaregression/9999"
3191+gdb_test {p $a (3, 2:2)} { = \(23\)}
4b0e5c1b
AM
3192diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90
3193new file mode 100644
4b0e5c1b
AM
3194--- /dev/null
3195+++ b/gdb/testsuite/gdb.fortran/subrange.f90
aa964043
KK
3196@@ -0,0 +1,28 @@
3197+! Copyright 2011 Free Software Foundation, Inc.
3198+!
3199+! This program is free software; you can redistribute it and/or modify
3200+! it under the terms of the GNU General Public License as published by
3201+! the Free Software Foundation; either version 3 of the License, or
3202+! (at your option) any later version.
3203+!
3204+! This program is distributed in the hope that it will be useful,
3205+! but WITHOUT ANY WARRANTY; without even the implied warranty of
3206+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3207+! GNU General Public License for more details.
3208+!
3209+! You should have received a copy of the GNU General Public License
3210+! along with this program. If not, see <http://www.gnu.org/licenses/>.
3211+
3212+program test
3213+ integer, target :: a (4, 3)
3214+ integer, allocatable :: alloc (:, :)
3215+ integer, pointer :: ptr (:, :)
3216+ do 1 i = 1, 4
3217+ do 1 j = 1, 3
3218+ a (i, j) = j * 10 + i
3219+1 continue
3220+ allocate (alloc (4, 3))
3221+ alloc = a
3222+ ptr => a
3223+ write (*,*) a ! break-static
3224+end
4b0e5c1b
AM
3225diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
3226new file mode 100644
4b0e5c1b
AM
3227--- /dev/null
3228+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
aa964043
KK
3229@@ -0,0 +1,26 @@
3230+/* Copyright 2011 Free Software Foundation, Inc.
3231+
3232+ This file is part of GDB.
3233+
3234+ This program is free software; you can redistribute it and/or modify
3235+ it under the terms of the GNU General Public License as published by
3236+ the Free Software Foundation; either version 3 of the License, or
3237+ (at your option) any later version.
3238+
3239+ This program is distributed in the hope that it will be useful,
3240+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3241+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3242+ GNU General Public License for more details.
3243+
3244+ You should have received a copy of the GNU General Public License
3245+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
3246+
3247+int
3248+main (int argc, char **argv)
3249+{
3250+ char vla[argc];
3251+
3252+ vla[0] = 0; /* break-here */
3253+
3254+ return 0;
3255+}
4b0e5c1b
AM
3256diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
3257new file mode 100644
4b0e5c1b
AM
3258--- /dev/null
3259+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
aa964043
KK
3260@@ -0,0 +1,57 @@
3261+# Copyright 2011 Free Software Foundation, Inc.
3262+#
3263+# This program is free software; you can redistribute it and/or modify
3264+# it under the terms of the GNU General Public License as published by
3265+# the Free Software Foundation; either version 3 of the License, or
3266+# (at your option) any later version.
3267+#
3268+# This program is distributed in the hope that it will be useful,
3269+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3270+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3271+# GNU General Public License for more details.
3272+#
3273+# You should have received a copy of the GNU General Public License
3274+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3275+
3276+load_lib mi-support.exp
3277+set MIFLAGS "-i=mi2"
3278+
3279+gdb_exit
3280+if [mi_gdb_start] {
3281+ continue
3282+}
3283+
3284+set testfile "mi2-var-stale-type"
3285+set srcfile ${testfile}.c
3286+set binfile [standard_output_file ${testfile}]
3287+if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
3288+ return -1
3289+}
3290+
3291+mi_delete_breakpoints
3292+mi_gdb_reinitialize_dir $srcdir/$subdir
3293+mi_gdb_load ${binfile}
3294+
3295+mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
3296+ {\^done} \
3297+ "maintenance set internal-error quit yes"
3298+
3299+mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
3300+ {\^done} \
3301+ "maintenance set internal-error corefile yes"
3302+
3303+set line [gdb_get_line_number "break-here"]
3304+set func "main"
3305+
3306+mi_gdb_test "-break-insert -t $srcfile:$line" \
3307+ "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",fullname=\".*\",line=\"$line\",\[^\r\n\]*,original-location=\".*\"\}" \
3308+ "breakpoint at $func"
3309+
3310+if { [mi_run_cmd] < 0 } {
3311+ return -1
3312+}
3313+mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
3314+
3315+mi_create_varobj "vla" "vla" "create local variable vla"
3316+
3317+mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *"
4b0e5c1b
AM
3318diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
3319new file mode 100644
4b0e5c1b
AM
3320--- /dev/null
3321+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
aa964043
KK
3322@@ -0,0 +1,22 @@
3323+/* This file is part of GDB, the GNU debugger.
3324+
3325+ Copyright 2009 Free Software Foundation, Inc.
3326+
3327+ This program is free software; you can redistribute it and/or modify
3328+ it under the terms of the GNU General Public License as published by
3329+ the Free Software Foundation; either version 3 of the License, or
3330+ (at your option) any later version.
3331+
3332+ This program is distributed in the hope that it will be useful,
3333+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3334+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3335+ GNU General Public License for more details.
3336+
3337+ You should have received a copy of the GNU General Public License
3338+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
3339+
3340+int
3341+func (int *arr)
3342+{
3343+ return arr[0];
3344+}
4b0e5c1b
AM
3345diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
3346new file mode 100644
4b0e5c1b
AM
3347--- /dev/null
3348+++ b/gdb/testsuite/gdb.opt/array-from-register.c
aa964043
KK
3349@@ -0,0 +1,28 @@
3350+/* This file is part of GDB, the GNU debugger.
3351+
3352+ Copyright 2009 Free Software Foundation, Inc.
3353+
3354+ This program is free software; you can redistribute it and/or modify
3355+ it under the terms of the GNU General Public License as published by
3356+ the Free Software Foundation; either version 3 of the License, or
3357+ (at your option) any later version.
3358+
3359+ This program is distributed in the hope that it will be useful,
3360+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3361+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3362+ GNU General Public License for more details.
3363+
3364+ You should have received a copy of the GNU General Public License
3365+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
3366+
3367+extern int func (int *arr);
3368+
3369+int
3370+main (void)
3371+{
3372+ int arr[] = { 42 };
3373+
3374+ func (arr);
3375+
3376+ return 0;
3377+}
4b0e5c1b
AM
3378diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
3379new file mode 100644
4b0e5c1b
AM
3380--- /dev/null
3381+++ b/gdb/testsuite/gdb.opt/array-from-register.exp
aa964043
KK
3382@@ -0,0 +1,33 @@
3383+# Copyright 2009 Free Software Foundation, Inc.
3384+#
3385+# This program is free software; you can redistribute it and/or modify
3386+# it under the terms of the GNU General Public License as published by
3387+# the Free Software Foundation; either version 2 of the License, or
3388+# (at your option) any later version.
3389+#
3390+# This program is distributed in the hope that it will be useful,
3391+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3392+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3393+# GNU General Public License for more details.
3394+#
3395+# You should have received a copy of the GNU General Public License
3396+# along with this program; if not, write to the Free Software
3397+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3398+#
3399+# This file is part of the gdb testsuite.
3400+
3401+if { [prepare_for_testing array-from-register.exp "array-from-register" \
3402+ {array-from-register.c array-from-register-func.c} \
3403+ {debug optimize=-O2}] } {
3404+ return -1
3405+}
3406+
3407+if ![runto func] then {
3408+ return -1
3409+}
3410+
3411+gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
3412+
3413+# Seen regression:
3414+# Address requested for identifier "arr" which is in register $rdi
3415+gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
4b0e5c1b
AM
3416diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp
3417new file mode 100644
4b0e5c1b
AM
3418--- /dev/null
3419+++ b/gdb/testsuite/gdb.opt/fortran-string.exp
140f8057
JR
3420@@ -0,0 +1,39 @@
3421+# Copyright 2009 Free Software Foundation, Inc.
3422+
3423+# This program is free software; you can redistribute it and/or modify
3424+# it under the terms of the GNU General Public License as published by
3425+# the Free Software Foundation; either version 2 of the License, or
3426+# (at your option) any later version.
3427+#
3428+# This program is distributed in the hope that it will be useful,
3429+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3430+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3431+# GNU General Public License for more details.
3432+#
3433+# You should have received a copy of the GNU General Public License
3434+# along with this program; if not, write to the Free Software
3435+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3436+
3437+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
3438+
3439+# Test GDB can cope with Fortran strings having their length present in a CPU
3440+# register. With -O0 the string length is passed on the stack. To make this
3441+# test meaningful the follow assertion should pass. It is not being checked
3442+# here as the "_s" symbol is compiler dependent:
3443+# (gdb) info address _s
3444+# Symbol "_s" is a variable in register XX.
3445+
3446+set test fortran-string
3447+set srcfile ${test}.f90
3448+if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f90 additional_flags=-O2}] } {
3449+ return -1
3450+}
3451+
3452+if ![runto $srcfile:[gdb_get_line_number "s = s"]] then {
3453+ perror "couldn't run to breakpoint MAIN__"
3454+ continue
3455+}
3456+
3457+gdb_test "frame" ".*s='foo'.*"
3458+gdb_test "ptype s" "type = character\\*3"
3459+gdb_test "p s" "\\$\[0-9\]* = 'foo'"
4b0e5c1b
AM
3460diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90
3461new file mode 100644
4b0e5c1b
AM
3462--- /dev/null
3463+++ b/gdb/testsuite/gdb.opt/fortran-string.f90
140f8057
JR
3464@@ -0,0 +1,28 @@
3465+! Copyright 2009 Free Software Foundation, Inc.
3466+!
3467+! This program is free software; you can redistribute it and/or modify
3468+! it under the terms of the GNU General Public License as published by
3469+! the Free Software Foundation; either version 2 of the License, or
3470+! (at your option) any later version.
3471+!
3472+! This program is distributed in the hope that it will be useful,
3473+! but WITHOUT ANY WARRANTY; without even the implied warranty of
3474+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3475+! GNU General Public License for more details.
3476+!
3477+! You should have received a copy of the GNU General Public License
3478+! along with this program; if not, write to the Free Software
3479+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3480+!
3481+! Ihis file is the Fortran source file for dynamic.exp.
3482+! Original file written by Jakub Jelinek <jakub@redhat.com>.
3483+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3484+
3485+ subroutine f(s)
3486+ character*(*) s
3487+ s = s
3488+ end
3489+
3490+ program main
3491+ call f ('foo')
3492+ end
4b0e5c1b
AM
3493diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp
3494new file mode 100644
4b0e5c1b
AM
3495--- /dev/null
3496+++ b/gdb/testsuite/gdb.pascal/arrays.exp
aa964043
KK
3497@@ -0,0 +1,104 @@
3498+# Copyright 2008, 2009 Free Software Foundation, Inc.
3499+#
3500+# This program is free software; you can redistribute it and/or modify
3501+# it under the terms of the GNU General Public License as published by
3502+# the Free Software Foundation; either version 3 of the License, or
3503+# (at your option) any later version.
3504+#
3505+# This program is distributed in the hope that it will be useful,
3506+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3507+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3508+# GNU General Public License for more details.
3509+#
3510+# You should have received a copy of the GNU General Public License
3511+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3512+
3513+if $tracelevel then {
3514+ strace $tracelevel
3515+}
3516+
3517+load_lib "pascal.exp"
3518+
3519+set testfile "arrays"
3520+set srcfile ${testfile}.pas
28b292e9 3521+set binfile [standard_output_file ${testfile}$EXEEXT]
aa964043
KK
3522+
3523+# These tests only work with fpc, using the -gw3 compile-option
3524+pascal_init
3525+if { $pascal_compiler_is_fpc != 1 } {
3526+ return -1
3527+}
3528+
3529+# Detect if the fpc version is below 2.3.0
3530+set fpc_generates_dwarf_for_dynamic_arrays 1
3531+if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} {
3532+ set fpc_generates_dwarf_for_dynamic_arrays 0
3533+}
3534+
3535+
3536+if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
3537+ return -1
3538+}
3539+
3540+gdb_exit
3541+gdb_start
3542+gdb_reinitialize_dir $srcdir/$subdir
3543+gdb_load ${binfile}
3544+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
3545+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
3546+
3547+
3548+if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
3549+ pass "setting breakpoint 1"
3550+}
3551+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
3552+ pass "setting breakpoint 2"
3553+}
3554+
3555+# Verify that "start" lands inside the right procedure.
3556+if { [gdb_start_cmd] < 0 } {
3557+ untested start
3558+ return -1
3559+}
3560+
3561+gdb_test "" ".* at .*${srcfile}.*" "start"
3562+
3563+gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
3564+
3565+gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type"
3566+gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer"
3567+
3568+gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
3569+
3570+gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char"
3571+gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer"
3572+
3573+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3574+ setup_xfail "*-*-*"
3575+}
3576+gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type"
3577+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3578+ setup_xfail "*-*-*"
3579+}
3580+gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
3581+
3582+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3583+ setup_xfail "*-*-*"
3584+}
3585+gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
3586+
3587+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3588+ setup_xfail "*-*-*"
3589+}
3590+gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
3591+
3592+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3593+ setup_xfail "*-*-*"
3594+}
3595+gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
3596+
3597+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3598+ setup_xfail "*-*-*"
3599+}
3600+gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
3601+
4b0e5c1b
AM
3602diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas
3603new file mode 100644
4b0e5c1b
AM
3604--- /dev/null
3605+++ b/gdb/testsuite/gdb.pascal/arrays.pas
aa964043
KK
3606@@ -0,0 +1,82 @@
3607+{
3608+ Copyright 2008, 2009 Free Software Foundation, Inc.
3609+
3610+ This program is free software; you can redistribute it and/or modify
3611+ it under the terms of the GNU General Public License as published by
3612+ the Free Software Foundation; either version 3 of the License, or
3613+ (at your option) any later version.
3614+
3615+ This program is distributed in the hope that it will be useful,
3616+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3617+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3618+ GNU General Public License for more details.
3619+
3620+ You should have received a copy of the GNU General Public License
3621+ along with this program. If not, see <http://www.gnu.org/licenses/>.
3622+}
3623+
3624+program arrays;
3625+
3626+{$mode objfpc}{$h+}
3627+
3628+uses sysutils;
3629+
3630+type TStatArrInt= array[0..11] of integer;
3631+ TDynArrInt= array of integer;
3632+ TStatArrStr= array[0..12] of string;
3633+ TDynArrStr= array of string;
3634+ TDynArrChar = array of char;
3635+ TStatArrChar = array [0..11] of char;
3636+
3637+ TStat2dArrInt = array[0..11,0..4] of integer;
3638+
3639+var StatArrInt: TStatArrInt;
3640+ StatArrInt_: Array[0..11] of integer;
3641+ DynArrInt: TDynArrInt;
3642+ DynArrInt_: Array of integer;
3643+ StatArrStr: TStatArrStr;
3644+ DynArrStr: TDynArrStr;
3645+ StatArrChar: TStatArrChar;
3646+ DynArrChar: TDynArrChar;
3647+
3648+ Stat2dArrInt: TStat2dArrInt;
3649+
3650+ s: string;
3651+
3652+ i,j : integer;
3653+
3654+begin
3655+ for i := 0 to 11 do
3656+ begin
3657+ StatArrInt[i]:= i+50;
3658+ StatArrInt_[i]:= i+50;
3659+ StatArrChar[i]:= chr(ord('a')+i);
3660+ for j := 0 to 4 do
3661+ Stat2dArrInt[i,j]:=i+j;
3662+ end;
3663+ writeln(StatArrInt_[0]);
3664+ writeln(StatArrInt[0]); { set breakpoint 1 here }
3665+ writeln(StatArrChar[0]);
3666+ writeln(Stat2dArrInt[0,0]);
3667+
3668+ setlength(DynArrInt,13);
3669+ setlength(DynArrInt_,13);
3670+ setlength(DynArrStr,13);
3671+ setlength(DynArrChar,13);
3672+ for i := 0 to 12 do
3673+ begin
3674+ DynArrInt[i]:= i+50;
3675+ DynArrInt_[i]:= i+50;
3676+ DynArrChar[i]:= chr(ord('a')+i);
3677+ StatArrStr[i]:='str'+inttostr(i);
3678+ DynArrStr[i]:='dstr'+inttostr(i);
3679+ end;
3680+ writeln(DynArrInt_[1]);
3681+ writeln(DynArrInt[1]);
3682+ writeln(DynArrStr[1]);
3683+ writeln(StatArrStr[1]);
3684+ writeln(DynArrChar[1]);
3685+
3686+ s := 'test'#0'string';
3687+ writeln(s); { set breakpoint 2 here }
3688+end.
4b0e5c1b 3689diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
4b0e5c1b
AM
3690--- a/gdb/testsuite/lib/gdb.exp
3691+++ b/gdb/testsuite/lib/gdb.exp
ed003b1c 3692@@ -170,6 +170,11 @@ proc gdb_unload {} {
e28f2cc1 3693 send_gdb "y\n" answer
aa964043
KK
3694 exp_continue
3695 }
3696+ -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
3697+ { send_gdb "y\n"
3698+ verbose "\t\tUnloading symbols for program being debugged"
3699+ exp_continue
3700+ }
3701 -re "Discard symbol table from .*y or n.*$" {
e28f2cc1 3702 send_gdb "y\n" answer
aa964043 3703 exp_continue
4b0e5c1b 3704diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp
4b0e5c1b
AM
3705--- a/gdb/testsuite/lib/pascal.exp
3706+++ b/gdb/testsuite/lib/pascal.exp
3707@@ -37,6 +37,9 @@ proc pascal_init {} {
aa964043
KK
3708 global pascal_compiler_is_fpc
3709 global gpc_compiler
3710 global fpc_compiler
3711+ global fpcversion_major
3712+ global fpcversion_minor
3713+ global fpcversion_release
3714 global env
3715
3716 if { $pascal_init_done == 1 } {
4b0e5c1b 3717@@ -64,6 +67,20 @@ proc pascal_init {} {
aa964043
KK
3718 set pascal_compiler_is_fpc 1
3719 verbose -log "Free Pascal compiler found"
3720 }
3721+
3722+ # Detect the fpc-version
3723+ if { $pascal_compiler_is_fpc == 1 } {
3724+ set fpcversion_major 1
3725+ set fpcversion_minor 0
3726+ set fpcversion_release 0
3727+ set fpcversion [ remote_exec host $fpc_compiler "-iV" ]
3728+ if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] {
3729+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major
3730+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor
3731+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release
3732+ }
3733+ verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
3734+ }
3735 }
3736 set pascal_init_done 1
3737 }
This page took 0.558713 seconds and 4 git commands to generate.