]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-archer-vla-tests.patch
up to 10.2
[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)
174fe25c 83+# SUCC: 4 [100.0%]
140f8057
JR
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
174fe25c 101+# PRED: 3 (FALLTHRU,DFS_BACK) 2 [100.0%]
140f8057
JR
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
174fe25c 122+# SUCC: EXIT [100.0%]
140f8057
JR
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
174fe25c 1534@@ -0,0 +1,179 @@
140f8057
JR
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.
174fe25c 1563+ void function1()
140f8057
JR
1564+ {
1565+ throw 20;
1566+ }
1567+
1568+ // Throw an exception in another function.
174fe25c 1569+ void function2()
140f8057
JR
1570+ {
1571+ function1();
1572+ }
1573+
1574+ // Throw an exception in another function, but handle it
1575+ // locally.
174fe25c 1576+ void function3 ()
140f8057
JR
1577+ {
1578+ {
1579+ try
1580+ {
1581+ function1 ();
1582+ }
174fe25c 1583+ catch (...)
140f8057
JR
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+
174fe25c
JP
1626+int main ()
1627+{
140f8057
JR
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+}
4b0e5c1b
AM
1714diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp
1715new file mode 100644
4b0e5c1b
AM
1716--- /dev/null
1717+++ b/gdb/testsuite/gdb.cp/gdb9593.exp
174fe25c 1718@@ -0,0 +1,189 @@
140f8057
JR
1719+# Copyright 2008, 2009 Free Software Foundation, Inc.
1720+
1721+# This program is free software; you can redistribute it and/or modify
1722+# it under the terms of the GNU General Public License as published by
1723+# the Free Software Foundation; either version 3 of the License, or
1724+# (at your option) any later version.
1725+#
1726+# This program is distributed in the hope that it will be useful,
1727+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1728+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1729+# GNU General Public License for more details.
1730+#
1731+# You should have received a copy of the GNU General Public License
1732+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1733+
1734+
1735+if $tracelevel then {
1736+ strace $tracelevel
1737+}
1738+
1739+if { [skip_cplus_tests] } { continue }
1740+
1741+set testfile "gdb9593"
1742+set srcfile ${testfile}.cc
1743+set binfile [standard_output_file $testfile]
1744+
1745+# Create and source the file that provides information about the compiler
1746+# used to compile the test case.
1747+if [get_compiler_info "c++"] {
1748+ untested gdb9593.exp
1749+ return -1
1750+}
1751+
1752+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
1753+ untested gdb9593.exp
1754+ return -1
1755+}
1756+
1757+# Some targets can't do function calls, so don't even bother with this
1758+# test.
1759+if [target_info exists gdb,cannot_call_functions] {
1760+ setup_xfail "*-*-*" 9593
1761+ fail "This target can not call functions"
1762+ continue
1763+}
1764+
1765+gdb_exit
1766+gdb_start
1767+gdb_reinitialize_dir $srcdir/$subdir
1768+gdb_load ${binfile}
1769+
1770+if ![runto_main] then {
1771+ perror "couldn't run to main"
1772+ continue
174fe25c 1773+}
140f8057
JR
1774+
1775+# See whether we have the needed unwinder hooks.
1776+set ok 1
1777+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
1778+ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
1779+ pass "check for unwinder hook"
1780+ }
1781+ -re "No symbol .* in current context.\r\n$gdb_prompt $" {
1782+ # Pass the test so we don't get bogus fails in the results.
1783+ pass "check for unwinder hook"
1784+ set ok 0
1785+ }
1786+}
1787+if {!$ok} {
1788+ untested gdb9593.exp
1789+ return -1
1790+}
1791+
1792+# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
1793+
1794+gdb_test "next" \
1795+ ".*catch (...).*" \
1796+ "next over a throw 1"
1797+
1798+gdb_test "next" \
1799+ ".*next_cases.function2.*" \
1800+ "next past catch 1"
1801+
1802+gdb_test "next" \
1803+ ".*catch (...).*" \
1804+ "next over a throw 2"
1805+
1806+gdb_test "next" \
1807+ ".*next_cases.function2.*" \
1808+ "next past catch 2"
1809+
1810+gdb_test "step" \
1811+ ".*function1().*" \
1812+ "step into function2 1"
1813+
1814+gdb_test "next" \
1815+ ".*catch (...).*" \
1816+ "next over a throw 3"
1817+
1818+gdb_test "next" \
1819+ ".*next_cases.function3.*" \
1820+ "next past catch 3"
1821+
1822+gdb_test "next" \
1823+ ".*next_cases.rethrow.*" \
1824+ "next over a throw 4"
1825+
1826+gdb_test "next" \
1827+ ".*catch (...).*" \
1828+ "next over a rethrow"
1829+
1830+gdb_test "next" \
1831+ ".*next_cases.function2.*" \
1832+ "next after a rethrow"
1833+
1834+gdb_test "step" \
1835+ ".*function1().*" \
1836+ "step into function2 2"
1837+
1838+gdb_test "finish" \
1839+ ".*catch (...).*" \
1840+ "finish 1"
1841+
1842+gdb_test "next" \
1843+ ".*next_cases.finish ().*" \
1844+ "next past catch 4"
1845+
1846+gdb_test "step" \
1847+ ".*function1 ().*" \
1848+ "step into finish method"
1849+
1850+gdb_test "finish" \
1851+ ".*catch (...).*" \
1852+ "finish 2"
1853+
1854+gdb_test "next" \
1855+ ".*next_cases.finish ().*" \
1856+ "next past catch 5"
1857+
1858+gdb_test "step" \
1859+ ".*function1 ().*" \
1860+ "step into finish, for until"
1861+
174fe25c
JP
1862+gdb_test_multiple "until" "until with no argument 1" {
1863+ -re -wrap ".*function1 ().*" {
1864+ pass $gdb_test_name
1865+ }
1866+ -re -wrap ".*$hex\t80\t \}" {
1867+ # PR gcc/97774 - "Incorrect line info for try/catch"
1868+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97774
1869+ xfail $gdb_test_name
1870+ }
1871+}
140f8057
JR
1872+
1873+set line [gdb_get_line_number "marker for until" $testfile.cc]
1874+
1875+gdb_test "until $line" \
1876+ ".*function1 ().*" \
1877+ "next past catch 6"
1878+
1879+gdb_test "until" \
1880+ ".*catch (...).*" \
1881+ "until with no argument 2"
1882+
1883+set line [gdb_get_line_number "until here" $testfile.cc]
1884+
1885+gdb_test "next" \
1886+ ".*next_cases.until ().*" \
1887+ "next past catch 6"
1888+
1889+gdb_test "step" \
1890+ ".*function1 ().*" \
1891+ "step into until"
1892+
1893+gdb_test "until $line" \
1894+ ".*catch (...).*" \
1895+ "until-over-throw"
1896+
1897+gdb_test "next" \
1898+ ".*next_cases.until ().*" \
1899+ "next past catch 7"
1900+
1901+gdb_test "step" \
1902+ ".*function1 ().*" \
1903+ "step into until, for advance"
1904+
1905+gdb_test "advance $line" \
1906+ ".*catch (...).*" \
1907+ "advance-over-throw"
4b0e5c1b
AM
1908diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
1909new file mode 100644
4b0e5c1b
AM
1910--- /dev/null
1911+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
aa964043
KK
1912@@ -0,0 +1,246 @@
1913+/* This testcase is part of GDB, the GNU debugger.
1914+
1915+ Copyright 2010 Free Software Foundation, Inc.
1916+
1917+ This program is free software; you can redistribute it and/or modify
1918+ it under the terms of the GNU General Public License as published by
1919+ the Free Software Foundation; either version 3 of the License, or
1920+ (at your option) any later version.
1921+
1922+ This program is distributed in the hope that it will be useful,
1923+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1924+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1925+ GNU General Public License for more details.
1926+
1927+ You should have received a copy of the GNU General Public License
1928+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
1929+
1930+/* Debug information */
1931+
1932+/* We will `break *main' at the very first instruction. */
1933+#define main_length 1
1934+
1935+ .section .data
1936+vardata:
1937+ /* See DW_OP_lit3 + 1 (0-based). */
1938+ .string "seennotseen"
1939+
1940+ .section .debug_info
1941+.Lcu1_begin:
1942+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
1943+.Lcu1_start:
1944+ .2byte 2 /* DWARF version number */
1945+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
1946+ .byte 4 /* Pointer Size (in bytes) */
1947+
1948+ /* CU die */
1949+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
1950+ .4byte .Lproducer /* DW_AT_producer */
1951+ /* Use C++ to exploit a bug in parsing DW_AT_name "". */
1952+ .byte 4 /* DW_AT_language (C++) - */
1953+ .4byte main /* DW_AT_low_pc */
1954+ .byte main_length /* DW_AT_high_pc */
1955+
1956+.Larray_type:
1957+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
1958+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1959+
1960+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
1961+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1962+ .byte 0 /* DW_AT_lower_bound */
1963+ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */
1964+ .byte 0 /* End of children of die */
1965+
1966+ /* DW_AT_upper_bound is referencing an optimized-out variable. */
1967+.Larrayb_type:
1968+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
1969+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1970+
1971+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
1972+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1973+ .byte 0 /* DW_AT_lower_bound */
1974+ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */
1975+ .byte 0 /* End of children of die */
1976+
1977+ /* DW_AT_upper_bound is referencing register. */
1978+.Larrayreg_type:
1979+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
1980+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
1981+
1982+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */
1983+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
1984+ .byte 0 /* DW_AT_lower_bound */
1985+ .byte 2f - 1f /* DW_AT_upper_bound */
1986+1: .byte 0x50 /* DW_OP_reg0 */
1987+2:
1988+ .byte 0 /* End of children of die */
1989+
1990+.Luint_type:
1991+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
1992+ .4byte .Luint_str /* DW_AT_name */
1993+ .byte 4 /* DW_AT_byte_size */
1994+ .byte 7 /* DW_AT_encoding */
1995+
1996+.Lchar_type:
1997+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
1998+ .4byte .Lchar_str /* DW_AT_name */
1999+ .byte 1 /* DW_AT_byte_size */
2000+ .byte 6 /* DW_AT_encoding */
2001+
2002+.Llen_var:
2003+ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */
2004+ .byte 1 /* DW_AT_artificial */
2005+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2006+ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */
2007+
2008+ /* optimized-out variable for b_string. */
2009+.Llenb_var:
2010+ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */
2011+ .byte 1 /* DW_AT_artificial */
2012+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
2013+
2014+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2015+ .string "a_string" /* DW_AT_name */
2016+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
2017+ .byte 2f - 1f /* DW_AT_location */
2018+1: .byte 3 /* DW_OP_addr */
2019+ .4byte vardata /* <addr> */
2020+2:
2021+
2022+ /* DW_AT_upper_bound is referencing an optimized-out variable. */
2023+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2024+ .string "b_string" /* DW_AT_name */
2025+ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */
2026+ .byte 2f - 1f /* DW_AT_location */
2027+1: .byte 3 /* DW_OP_addr */
2028+ .4byte vardata /* <addr> */
2029+2:
2030+
2031+ /* DW_AT_upper_bound is referencing register. */
2032+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2033+ .string "reg_string" /* DW_AT_name */
2034+ .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */
2035+ .byte 2f - 1f /* DW_AT_location */
2036+1: .byte 3 /* DW_OP_addr */
2037+ .4byte vardata /* <addr> */
2038+2:
2039+
2040+ .byte 0 /* End of children of CU */
2041+.Lcu1_end:
2042+
2043+ .section .debug_loc
2044+.Lloclist:
2045+.Llen_loclist:
2046+ .4byte 0 # Location list begin address
2047+ .4byte main_length # Location list end address
2048+ .value 2f-1f # Location expression size
2049+1: .byte 0x33 # DW_OP_lit3
2050+ .byte 0x9f # DW_OP_stack_value
2051+2:
2052+ .quad 0x0 # Location list terminator begin (*.LLST2)
2053+ .quad 0x0 # Location list terminator end (*.LLST2)
2054+
2055+ .section .debug_abbrev
2056+.Ldebug_abbrev0:
2057+ .uleb128 1 /* Abbrev code */
2058+ .uleb128 0x11 /* DW_TAG_compile_unit */
2059+ .byte 0x1 /* has_children */
2060+ .uleb128 0x25 /* DW_AT_producer */
2061+ .uleb128 0xe /* DW_FORM_strp */
2062+ .uleb128 0x13 /* DW_AT_language */
2063+ .uleb128 0xb /* DW_FORM_data1 */
2064+ .uleb128 0x11 /* DW_AT_low_pc */
2065+ .uleb128 0x1 /* DW_FORM_addr */
2066+ .uleb128 0x12 /* DW_AT_high_pc */
2067+ .uleb128 0xb /* DW_FORM_data1 */
2068+ .byte 0x0 /* Terminator */
2069+ .byte 0x0 /* Terminator */
2070+
2071+ .uleb128 2 /* Abbrev code */
2072+ .uleb128 0x1 /* TAG: DW_TAG_array_type */
2073+ .byte 0x1 /* DW_children_yes */
2074+ .uleb128 0x49 /* DW_AT_type */
2075+ .uleb128 0x13 /* DW_FORM_ref4 */
2076+ .byte 0x0 /* Terminator */
2077+ .byte 0x0 /* Terminator */
2078+
2079+ .uleb128 3 /* Abbrev code */
2080+ .uleb128 0x21 /* DW_TAG_subrange_type */
2081+ .byte 0x0 /* no children */
2082+ .uleb128 0x49 /* DW_AT_type */
2083+ .uleb128 0x13 /* DW_FORM_ref4 */
2084+ .uleb128 0x22 /* DW_AT_lower_bound */
2085+ .uleb128 0xb /* DW_FORM_data1 */
2086+ .uleb128 0x2f /* DW_AT_upper_bound */
2087+ .uleb128 0x13 /* DW_FORM_ref4 */
2088+ .byte 0x0 /* Terminator */
2089+ .byte 0x0 /* Terminator */
2090+
2091+ .uleb128 4 /* Abbrev code */
2092+ .uleb128 0x24 /* DW_TAG_base_type */
2093+ .byte 0x0 /* no_children */
2094+ .uleb128 0x3 /* DW_AT_name */
2095+ .uleb128 0xe /* DW_FORM_strp */
2096+ .uleb128 0xb /* DW_AT_byte_size */
2097+ .uleb128 0xb /* DW_FORM_data1 */
2098+ .uleb128 0x3e /* DW_AT_encoding */
2099+ .uleb128 0xb /* DW_FORM_data1 */
2100+ .byte 0x0 /* Terminator */
2101+ .byte 0x0 /* Terminator */
2102+
2103+ .uleb128 5 /* Abbrev code */
2104+ .uleb128 0x34 /* DW_TAG_variable */
2105+ .byte 0x0 /* no_children */
2106+ .uleb128 0x34 /* DW_AT_artificial */
2107+ .uleb128 0x0c /* DW_FORM_flag */
2108+ .uleb128 0x49 /* DW_AT_type */
2109+ .uleb128 0x13 /* DW_FORM_ref4 */
2110+ .uleb128 0x02 /* DW_AT_location */
2111+ .uleb128 0x06 /* DW_FORM_data4 */
2112+ .byte 0x0 /* Terminator */
2113+ .byte 0x0 /* Terminator */
2114+
2115+ .uleb128 6 /* Abbrev code */
2116+ .uleb128 0x34 /* DW_TAG_variable */
2117+ .byte 0x0 /* no_children */
2118+ .uleb128 0x3 /* DW_AT_name */
2119+ .uleb128 0x8 /* DW_FORM_string */
2120+ .uleb128 0x49 /* DW_AT_type */
2121+ .uleb128 0x13 /* DW_FORM_ref4 */
2122+ .uleb128 0x2 /* DW_AT_location */
2123+ .uleb128 0xa /* DW_FORM_block1 */
2124+ .byte 0x0 /* Terminator */
2125+ .byte 0x0 /* Terminator */
2126+
2127+ .uleb128 7 /* Abbrev code */
2128+ .uleb128 0x34 /* DW_TAG_variable */
2129+ .byte 0x0 /* no_children */
2130+ .uleb128 0x34 /* DW_AT_artificial */
2131+ .uleb128 0x0c /* DW_FORM_flag */
2132+ .uleb128 0x49 /* DW_AT_type */
2133+ .uleb128 0x13 /* DW_FORM_ref4 */
2134+ .byte 0x0 /* Terminator */
2135+ .byte 0x0 /* Terminator */
2136+
2137+ .uleb128 8 /* Abbrev code */
2138+ .uleb128 0x21 /* DW_TAG_subrange_type with block */
2139+ .byte 0x0 /* no children */
2140+ .uleb128 0x49 /* DW_AT_type */
2141+ .uleb128 0x13 /* DW_FORM_ref4 */
2142+ .uleb128 0x22 /* DW_AT_lower_bound */
2143+ .uleb128 0xb /* DW_FORM_data1 */
2144+ .uleb128 0x2f /* DW_AT_upper_bound */
2145+ .uleb128 0xa /* DW_FORM_block1 */
2146+ .byte 0x0 /* Terminator */
2147+ .byte 0x0 /* Terminator */
2148+
2149+ .byte 0x0 /* Terminator */
2150+
2151+/* String table */
2152+ .section .debug_str
2153+.Lproducer:
2154+ .string "GNU C 3.3.3"
2155+.Lchar_str:
2156+ .string "char"
2157+.Luint_str:
2158+ .string "unsigned int"
4b0e5c1b
AM
2159diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
2160new file mode 100644
4b0e5c1b
AM
2161--- /dev/null
2162+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
28b292e9 2163@@ -0,0 +1,66 @@
aa964043
KK
2164+# Copyright 2010 Free Software Foundation, Inc.
2165+
2166+# This program is free software; you can redistribute it and/or modify
2167+# it under the terms of the GNU General Public License as published by
2168+# the Free Software Foundation; either version 3 of the License, or
2169+# (at your option) any later version.
2170+#
2171+# This program is distributed in the hope that it will be useful,
2172+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2173+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2174+# GNU General Public License for more details.
2175+#
2176+# You should have received a copy of the GNU General Public License
2177+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2178+
2179+# Test printing variable with dynamic bounds which reference a different
2180+# (artificial in the GCC case) variable containing loclist as its location.
2181+# This testcase uses value (not address) of the referenced variable:
2182+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
2183+
2184+# This test can only be run on targets which support DWARF-2 and use gas.
2185+# For now pick a sampling of likely targets.
2186+if {![istarget *-*-linux*]
2187+ && ![istarget *-*-gnu*]
2188+ && ![istarget *-*-elf*]
2189+ && ![istarget *-*-openbsd*]
2190+ && ![istarget arm-*-eabi*]
2191+ && ![istarget powerpc-*-eabi*]} {
2192+ return 0
2193+}
2194+
2195+set testfile dw2-bound-loclist
2196+if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
2197+ return -1
2198+}
2199+
2200+# Verify it behaves at least as an unbound array without inferior.
2201+
28b292e9
AM
2202+# FIXME: FSF GDB crashes due to !has_stack_frames ().
2203+# But in practice that should not happen.
2204+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
2205+#set test "p a_string"
2206+#gdb_test_multiple $test $test {
2207+# -re " = 0x\[0-9a-f\]+ \"seennotseen\"\r\n$gdb_prompt $" {
2208+# pass $test
2209+# }
2210+# -re "No registers\\.\r\n$gdb_prompt $" {
2211+# kfail "vlaregression" $test
2212+# }
2213+#}
2214+#
2215+#gdb_test "ptype a_string" {type = char \[variable length\]}
aa964043
KK
2216+
2217+# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
2218+if ![runto "*main"] {
2219+ return -1
2220+}
2221+
2222+gdb_test "p a_string" { = "seen"}
2223+gdb_test "ptype a_string" {type = char \[4\]}
2224+
2225+gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
2226+gdb_test "ptype b_string" {type = char \[\]}
2227+
2228+# The register contains unpredictable value - the array size.
2229+gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]}
4b0e5c1b
AM
2230diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
2231new file mode 100644
4b0e5c1b
AM
2232--- /dev/null
2233+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
aa964043
KK
2234@@ -0,0 +1,42 @@
2235+/* This testcase is part of GDB, the GNU debugger.
2236+
2237+ Copyright 2004 Free Software Foundation, Inc.
2238+
2239+ This program is free software; you can redistribute it and/or modify
2240+ it under the terms of the GNU General Public License as published by
2241+ the Free Software Foundation; either version 2 of the License, or
2242+ (at your option) any later version.
2243+
2244+ This program is distributed in the hope that it will be useful,
2245+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2246+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2247+ GNU General Public License for more details.
174fe25c 2248+
aa964043
KK
2249+ You should have received a copy of the GNU General Public License
2250+ along with this program; if not, write to the Free Software
2251+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2252+ USA. */
2253+
2254+
2255+/* The function `func1' traced into must have debug info on offset > 0;
2256+ (DW_UNSND (attr)). This is the reason of `func0' existence. */
2257+
2258+void
2259+func0(int a, int b)
2260+{
2261+}
2262+
2263+/* `func1' being traced into must have some arguments to dump. */
2264+
2265+void
2266+func1(int a, int b)
2267+{
2268+ func0 (a,b);
2269+}
2270+
2271+int
2272+main(void)
2273+{
2274+ func1 (1, 2);
2275+ return 0;
2276+}
4b0e5c1b
AM
2277diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
2278new file mode 100644
4b0e5c1b
AM
2279--- /dev/null
2280+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
174fe25c 2281@@ -0,0 +1,84 @@
aa964043
KK
2282+# Copyright 2006 Free Software Foundation, Inc.
2283+
2284+# This program is free software; you can redistribute it and/or modify
2285+# it under the terms of the GNU General Public License as published by
2286+# the Free Software Foundation; either version 2 of the License, or
2287+# (at your option) any later version.
174fe25c 2288+#
aa964043
KK
2289+# This program is distributed in the hope that it will be useful,
2290+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2291+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2292+# GNU General Public License for more details.
174fe25c 2293+#
aa964043
KK
2294+# You should have received a copy of the GNU General Public License
2295+# along with this program; if not, write to the Free Software
2296+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2297+
2298+# Minimal DWARF-2 unit test
2299+
2300+# This test can only be run on targets which support DWARF-2.
2301+# For now pick a sampling of likely targets.
2302+if {![istarget *-*-linux*]
2303+ && ![istarget *-*-gnu*]
2304+ && ![istarget *-*-elf*]
2305+ && ![istarget *-*-openbsd*]
2306+ && ![istarget arm-*-eabi*]
2307+ && ![istarget powerpc-*-eabi*]} {
174fe25c
JP
2308+ return 0
2309+}
2310+
2311+if {[use_gdb_stub]} {
2312+ untested "skipping test because of use_gdb_stub"
2313+ return -1
aa964043
KK
2314+}
2315+
2316+set testfile "dw2-stripped"
2317+set srcfile ${testfile}.c
140f8057 2318+set binfile [standard_output_file ${testfile}.x]
aa964043
KK
2319+
2320+remote_exec build "rm -f ${binfile}"
2321+
2322+# get the value of gcc_compiled
2323+if [get_compiler_info ${binfile}] {
2324+ return -1
2325+}
2326+
2327+# This test can only be run on gcc as we use additional_flags=FIXME
2328+if {$gcc_compiled == 0} {
2329+ return 0
2330+}
2331+
2332+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
2333+ return -1
2334+}
2335+
2336+remote_exec build "objcopy -R .debug_loc ${binfile}"
2337+set strip_output [remote_exec build "objdump -h ${binfile}"]
2338+
2339+set test "stripping test file preservation"
2340+if [ regexp ".debug_info " $strip_output] {
2341+ pass "$test (.debug_info preserved)"
2342+} else {
2343+ fail "$test (.debug_info got also stripped)"
2344+}
2345+
2346+set test "stripping test file functionality"
2347+if [ regexp ".debug_loc " $strip_output] {
2348+ fail "$test (.debug_loc still present)"
2349+} else {
2350+ pass "$test (.debug_loc stripped)"
2351+}
2352+
2353+gdb_exit
2354+gdb_start
2355+gdb_reinitialize_dir $srcdir/$subdir
2356+gdb_load ${binfile}
2357+
2358+# For C programs, "start" should stop in main().
2359+
2360+gdb_test "start" \
2361+ ".*main \\(\\) at .*" \
2362+ "start"
2363+gdb_test "step" \
2364+ "func.* \\(.*\\) at .*" \
2365+ "step"
4b0e5c1b
AM
2366diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
2367new file mode 100644
4b0e5c1b
AM
2368--- /dev/null
2369+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
aa964043
KK
2370@@ -0,0 +1,83 @@
2371+/* This testcase is part of GDB, the GNU debugger.
2372+
2373+ Copyright 2009 Free Software Foundation, Inc.
2374+
2375+ This program is free software; you can redistribute it and/or modify
2376+ it under the terms of the GNU General Public License as published by
2377+ the Free Software Foundation; either version 3 of the License, or
2378+ (at your option) any later version.
2379+
2380+ This program is distributed in the hope that it will be useful,
2381+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2382+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2383+ GNU General Public License for more details.
2384+
2385+ You should have received a copy of the GNU General Public License
2386+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2387+
2388+/* Debug information */
2389+
2390+ .section .debug_info
2391+.Lcu1_begin:
2392+ /* CU header */
2393+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2394+.Lcu1_start:
2395+ .2byte 2 /* DWARF Version */
2396+ .4byte .Labbrev1_begin /* Offset into abbrev section */
2397+ .byte 4 /* Pointer size */
2398+
2399+ /* CU die */
2400+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2401+ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */
2402+ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */
2403+ .byte 1 /* DW_AT_language (C) */
2404+
2405+.Ltype_uchar:
2406+ .uleb128 2 /* Abbrev: DW_TAG_structure_type */
2407+ .ascii "some_struct\0" /* DW_AT_name */
2408+
2409+ .uleb128 3 /* Abbrev: DW_TAG_member */
2410+ .ascii "field\0" /* DW_AT_name */
2411+ .byte 0 /* DW_AT_data_member_location */
2412+
2413+ .byte 0 /* End of children of some_struct */
2414+
2415+ .byte 0 /* End of children of CU */
2416+
2417+.Lcu1_end:
2418+
2419+/* Abbrev table */
2420+ .section .debug_abbrev
2421+.Labbrev1_begin:
2422+ .uleb128 1 /* Abbrev code */
2423+ .uleb128 0x11 /* DW_TAG_compile_unit */
2424+ .byte 1 /* has_children */
2425+ .uleb128 0x3 /* DW_AT_name */
2426+ .uleb128 0x8 /* DW_FORM_string */
2427+ .uleb128 0x25 /* DW_AT_producer */
2428+ .uleb128 0x8 /* DW_FORM_string */
2429+ .uleb128 0x13 /* DW_AT_language */
2430+ .uleb128 0xb /* DW_FORM_data1 */
2431+ .byte 0x0 /* Terminator */
2432+ .byte 0x0 /* Terminator */
2433+
2434+ .uleb128 2 /* Abbrev code */
2435+ .uleb128 0x13 /* DW_TAG_structure_type */
2436+ .byte 1 /* has_children */
2437+ .uleb128 0x3 /* DW_AT_name */
2438+ .uleb128 0x8 /* DW_FORM_string */
2439+ .byte 0x0 /* Terminator */
2440+ .byte 0x0 /* Terminator */
2441+
2442+ .uleb128 3 /* Abbrev code */
2443+ .uleb128 0x0d /* DW_TAG_member */
2444+ .byte 0 /* has_children */
2445+ .uleb128 0x3 /* DW_AT_name */
2446+ .uleb128 0x8 /* DW_FORM_string */
2447+ .uleb128 0x38 /* DW_AT_data_member_location */
2448+ .uleb128 0x0b /* DW_FORM_data1 */
2449+ .byte 0x0 /* Terminator */
2450+ .byte 0x0 /* Terminator */
2451+
2452+ .byte 0x0 /* Terminator */
2453+ .byte 0x0 /* Terminator */
4b0e5c1b
AM
2454diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
2455new file mode 100644
4b0e5c1b
AM
2456--- /dev/null
2457+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
aa964043
KK
2458@@ -0,0 +1,37 @@
2459+# Copyright 2009 Free Software Foundation, Inc.
2460+
2461+# This program is free software; you can redistribute it and/or modify
2462+# it under the terms of the GNU General Public License as published by
2463+# the Free Software Foundation; either version 3 of the License, or
2464+# (at your option) any later version.
2465+#
2466+# This program is distributed in the hope that it will be useful,
2467+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2468+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2469+# GNU General Public License for more details.
2470+#
2471+# You should have received a copy of the GNU General Public License
2472+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2473+
2474+# This test can only be run on targets which support DWARF-2 and use gas.
2475+# For now pick a sampling of likely targets.
2476+if {![istarget *-*-linux*]
2477+ && ![istarget *-*-gnu*]
2478+ && ![istarget *-*-elf*]
2479+ && ![istarget *-*-openbsd*]
2480+ && ![istarget arm-*-eabi*]
2481+ && ![istarget powerpc-*-eabi*]} {
174fe25c 2482+ return 0
aa964043
KK
2483+}
2484+
2485+set testfile "dw2-struct-member-data-location"
2486+set srcfile ${testfile}.S
2487+set binfile ${testfile}.x
2488+
2489+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "[standard_output_file ${binfile}]" object {nodebug}] != "" } {
2490+ return -1
2491+}
2492+
2493+clean_restart $binfile
2494+
2495+gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
4b0e5c1b
AM
2496diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
2497new file mode 100644
4b0e5c1b
AM
2498--- /dev/null
2499+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
aa964043
KK
2500@@ -0,0 +1,121 @@
2501+/* This testcase is part of GDB, the GNU debugger.
2502+
2503+ Copyright 2012 Free Software Foundation, Inc.
2504+
2505+ This program is free software; you can redistribute it and/or modify
2506+ it under the terms of the GNU General Public License as published by
2507+ the Free Software Foundation; either version 3 of the License, or
2508+ (at your option) any later version.
2509+
2510+ This program is distributed in the hope that it will be useful,
2511+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2512+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2513+ GNU General Public License for more details.
2514+
2515+ You should have received a copy of the GNU General Public License
2516+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2517+
2518+/* Debug information */
2519+
2520+ .section .data
2521+vardata:
2522+ .rept 129
2523+ .ascii "x"
2524+ .endr
2525+ .ascii "UNSEEN\0"
2526+
2527+ .section .debug_info
2528+.Lcu1_begin:
2529+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
2530+.Lcu1_start:
2531+ .2byte 2 /* DWARF version number */
2532+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
2533+ .byte 4 /* Pointer Size (in bytes) */
2534+
2535+ /* CU die */
2536+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
2537+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
2538+ .byte 2 /* DW_AT_language (C) - */
2539+
2540+.Larray_type:
2541+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
2542+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
2543+
2544+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */
2545+ .byte 0 /* DW_AT_lower_bound */
2546+ .byte 128 /* DW_AT_upper_bound */
2547+
2548+ .byte 0 /* End of children of die */
2549+
2550+.Lchar_type:
2551+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
2552+ .ascii "char\0" /* DW_AT_name */
2553+ .byte 1 /* DW_AT_byte_size */
2554+ .byte 6 /* DW_AT_encoding */
2555+
2556+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
2557+ .ascii "notype_string\0" /* DW_AT_name */
2558+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
2559+ .byte 2f - 1f /* DW_AT_location */
2560+1: .byte 3 /* DW_OP_addr */
2561+ .4byte vardata /* <addr> */
2562+2:
2563+
2564+ .byte 0 /* End of children of CU */
2565+.Lcu1_end:
2566+
2567+ .section .debug_abbrev
2568+.Ldebug_abbrev0:
2569+ .uleb128 1 /* Abbrev code */
2570+ .uleb128 0x11 /* DW_TAG_compile_unit */
2571+ .byte 0x1 /* has_children */
2572+ .uleb128 0x25 /* DW_AT_producer */
2573+ .uleb128 0x8 /* DW_FORM_string */
2574+ .uleb128 0x13 /* DW_AT_language */
2575+ .uleb128 0xb /* DW_FORM_data1 */
2576+ .byte 0x0 /* Terminator */
2577+ .byte 0x0 /* Terminator */
2578+
2579+ .uleb128 2 /* Abbrev code */
2580+ .uleb128 0x1 /* TAG: DW_TAG_array_type */
2581+ .byte 0x1 /* DW_children_yes */
2582+ .uleb128 0x49 /* DW_AT_type */
2583+ .uleb128 0x13 /* DW_FORM_ref4 */
2584+ .byte 0x0 /* Terminator */
2585+ .byte 0x0 /* Terminator */
2586+
2587+ .uleb128 4 /* Abbrev code */
2588+ .uleb128 0x24 /* DW_TAG_base_type */
2589+ .byte 0x0 /* no_children */
2590+ .uleb128 0x3 /* DW_AT_name */
2591+ .uleb128 0x8 /* DW_FORM_string */
2592+ .uleb128 0xb /* DW_AT_byte_size */
2593+ .uleb128 0xb /* DW_FORM_data1 */
2594+ .uleb128 0x3e /* DW_AT_encoding */
2595+ .uleb128 0xb /* DW_FORM_data1 */
2596+ .byte 0x0 /* Terminator */
2597+ .byte 0x0 /* Terminator */
2598+
2599+ .uleb128 6 /* Abbrev code */
2600+ .uleb128 0x34 /* DW_TAG_variable */
2601+ .byte 0x0 /* no_children */
2602+ .uleb128 0x3 /* DW_AT_name */
2603+ .uleb128 0x8 /* DW_FORM_string */
2604+ .uleb128 0x49 /* DW_AT_type */
2605+ .uleb128 0x13 /* DW_FORM_ref4 */
2606+ .uleb128 0x2 /* DW_AT_location */
2607+ .uleb128 0xa /* DW_FORM_block1 */
2608+ .byte 0x0 /* Terminator */
2609+ .byte 0x0 /* Terminator */
2610+
2611+ .uleb128 8 /* Abbrev code */
2612+ .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */
2613+ .byte 0x0 /* no children */
2614+ .uleb128 0x22 /* DW_AT_lower_bound */
2615+ .uleb128 0xb /* DW_FORM_data1 */
2616+ .uleb128 0x2f /* DW_AT_upper_bound */
2617+ .uleb128 0xb /* DW_FORM_data1 */
2618+ .byte 0x0 /* Terminator */
2619+ .byte 0x0 /* Terminator */
2620+
2621+ .byte 0x0 /* Terminator */
4b0e5c1b
AM
2622diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
2623new file mode 100644
4b0e5c1b
AM
2624--- /dev/null
2625+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
aa964043
KK
2626@@ -0,0 +1,39 @@
2627+# Copyright 2012 Free Software Foundation, Inc.
2628+
2629+# This program is free software; you can redistribute it and/or modify
2630+# it under the terms of the GNU General Public License as published by
2631+# the Free Software Foundation; either version 3 of the License, or
2632+# (at your option) any later version.
2633+#
2634+# This program is distributed in the hope that it will be useful,
2635+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2636+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2637+# GNU General Public License for more details.
2638+#
2639+# You should have received a copy of the GNU General Public License
2640+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2641+load_lib dwarf.exp
2642+
2643+# https://bugzilla.redhat.com/show_bug.cgi?id=806920
2644+# read_subrange_type <TYPE_CODE (base_type) == TYPE_CODE_VOID> reinitialization
2645+# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without
2646+# specified DW_AT_type, present only in XLF produced code.
2647+
2648+# This test can only be run on targets which support DWARF-2 and use gas.
2649+if {![dwarf2_support]} {
174fe25c 2650+ return 0
aa964043
KK
2651+}
2652+
2653+set testfile dw2-subrange-no-type
2654+set srcfile ${testfile}.S
2655+set executable ${testfile}.x
2656+set binfile [standard_output_file ${executable}]
2657+
2658+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
2659+ return -1
2660+}
2661+
2662+clean_restart $executable
2663+
2664+gdb_test "ptype notype_string" {type = char \[129\]}
2665+gdb_test "p notype_string" " = 'x' <repeats 129 times>"
4b0e5c1b
AM
2666diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
2667new file mode 100644
4b0e5c1b
AM
2668--- /dev/null
2669+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
aa964043
KK
2670@@ -0,0 +1,42 @@
2671+# Copyright 2009 Free Software Foundation, Inc.
2672+
2673+# This program is free software; you can redistribute it and/or modify
2674+# it under the terms of the GNU General Public License as published by
2675+# the Free Software Foundation; either version 2 of the License, or
2676+# (at your option) any later version.
174fe25c 2677+#
aa964043
KK
2678+# This program is distributed in the hope that it will be useful,
2679+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2680+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2681+# GNU General Public License for more details.
174fe25c 2682+#
aa964043
KK
2683+# You should have received a copy of the GNU General Public License
2684+# along with this program; if not, write to the Free Software
174fe25c 2685+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
aa964043
KK
2686+
2687+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2688+
2689+# This file is part of the gdb testsuite. Array element stride must not be
2690+# specified in the number of elements but in a number of bytes instead.
2691+# Original problem:
2692+# (gdb) p c40pt(1)
2693+# $1 = '0-hello', ' ' <repeats 33 times>
2694+# (gdb) p c40pt(2)
2695+# warning: Fortran array stride not divisible by the element size
2696+
2697+set testfile dwarf-stride
2698+set srcfile ${testfile}.f90
2699+
2700+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
2701+ return -1
2702+}
2703+
2704+if ![runto MAIN__] then {
2705+ perror "couldn't run to breakpoint MAIN__"
2706+ continue
2707+}
2708+
2709+gdb_breakpoint [gdb_get_line_number "break-here"]
2710+gdb_continue_to_breakpoint "break-here" ".*break-here.*"
2711+gdb_test "p c40pt(1)" " = '0-hello.*"
2712+gdb_test "p c40pt(2)" " = '1-hello.*"
4b0e5c1b
AM
2713diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
2714new file mode 100644
4b0e5c1b
AM
2715--- /dev/null
2716+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
aa964043
KK
2717@@ -0,0 +1,40 @@
2718+! Copyright 2009 Free Software Foundation, Inc.
2719+!
2720+! This program is free software; you can redistribute it and/or modify
2721+! it under the terms of the GNU General Public License as published by
2722+! the Free Software Foundation; either version 2 of the License, or
2723+! (at your option) any later version.
2724+!
2725+! This program is distributed in the hope that it will be useful,
2726+! but WITHOUT ANY WARRANTY; without even the implied warranty of
2727+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2728+! GNU General Public License for more details.
2729+!
2730+! You should have received a copy of the GNU General Public License
2731+! along with this program; if not, write to the Free Software
2732+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2733+!
2734+! File written by Alan Matsuoka.
2735+
2736+program repro
2737+
2738+ type small_stride
2739+ character*40 long_string
2740+ integer small_pad
2741+ end type small_stride
2742+
2743+ type(small_stride), dimension (20), target :: unpleasant
2744+ character*40, pointer, dimension(:):: c40pt
2745+
2746+ integer i
2747+
2748+ do i = 0,19
2749+ unpleasant(i+1)%small_pad = i+1
2750+ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
2751+ end do
2752+
2753+ c40pt => unpleasant%long_string
2754+
2755+ print *, c40pt ! break-here
2756+
2757+end program repro
4b0e5c1b
AM
2758diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
2759new file mode 100644
4b0e5c1b
AM
2760--- /dev/null
2761+++ b/gdb/testsuite/gdb.fortran/dynamic.exp
140f8057 2762@@ -0,0 +1,154 @@
aa964043
KK
2763+# Copyright 2007 Free Software Foundation, Inc.
2764+
2765+# This program is free software; you can redistribute it and/or modify
2766+# it under the terms of the GNU General Public License as published by
2767+# the Free Software Foundation; either version 2 of the License, or
2768+# (at your option) any later version.
174fe25c 2769+#
aa964043
KK
2770+# This program is distributed in the hope that it will be useful,
2771+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2772+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2773+# GNU General Public License for more details.
174fe25c 2774+#
aa964043
KK
2775+# You should have received a copy of the GNU General Public License
2776+# along with this program; if not, write to the Free Software
174fe25c 2777+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
aa964043
KK
2778+
2779+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2780+
2781+# This file is part of the gdb testsuite. It contains tests for dynamically
2782+# allocated Fortran arrays.
2783+# It depends on the GCC dynamic Fortran arrays DWARF support:
2784+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
2785+
2786+set testfile "dynamic"
2787+set srcfile ${testfile}.f90
28b292e9 2788+set binfile [standard_output_file ${testfile}]
aa964043
KK
2789+
2790+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
2791+ untested "Couldn't compile ${srcfile}"
2792+ return -1
2793+}
2794+
2795+gdb_exit
2796+gdb_start
2797+gdb_reinitialize_dir $srcdir/$subdir
2798+gdb_load ${binfile}
2799+
2800+if ![runto MAIN__] then {
2801+ perror "couldn't run to breakpoint MAIN__"
2802+ continue
2803+}
2804+
2805+gdb_breakpoint [gdb_get_line_number "varx-init"]
2806+gdb_continue_to_breakpoint "varx-init"
140f8057
JR
2807+
2808+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
2809+# Do not: gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx unallocated"
2810+# Do not: gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx unallocated"
2811+# Do not: gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) unallocated"
2812+# Do not: gdb_test "p varx(1,5,17)=1" {no such vector element \(vector not allocated\)} "p varx(1,5,17)=1 unallocated"
2813+# Do not: gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) unallocated"
aa964043
KK
2814+
2815+gdb_breakpoint [gdb_get_line_number "varx-allocated"]
2816+gdb_continue_to_breakpoint "varx-allocated"
2817+# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
e28f2cc1 2818+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4), allocatable \\(6,5:15,17:28\\)" "ptype varx allocated"
aa964043
KK
2819+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
2820+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
2821+
2822+gdb_breakpoint [gdb_get_line_number "varx-filled"]
2823+gdb_continue_to_breakpoint "varx-filled"
2824+gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
2825+gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
2826+gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
2827+gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
140f8057
JR
2828+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
2829+# Do not: gdb_test "p varv" "\\$\[0-9\]* = <not associated>" "p varv unassociated"
2830+# Do not: gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv unassociated"
aa964043
KK
2831+
2832+set test "output varx"
2833+gdb_test_multiple $test $test {
2834+ -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" {
2835+ pass $test
2836+ }
2837+}
2838+
2839+gdb_breakpoint [gdb_get_line_number "varv-associated"]
2840+gdb_continue_to_breakpoint "varv-associated"
2841+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
2842+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
2843+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
2844+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
e28f2cc1 2845+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4), allocatable \\(6,5:15,17:28\\)" "ptype varx with varv associated"
aa964043
KK
2846+# Intel Fortran Compiler 10.1.008 uses the pointer type.
2847+gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
2848+
2849+gdb_breakpoint [gdb_get_line_number "varv-filled"]
2850+gdb_continue_to_breakpoint "varv-filled"
2851+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
2852+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
2853+
2854+gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
2855+gdb_continue_to_breakpoint "varv-deassociated"
2856+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
2857+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 2858+gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv deassociated"
aa964043 2859+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
28b292e9
AM
2860+gdb_test "p varv(1,5,17)" {no such vector element \(vector not associated\)}
2861+gdb_test "ptype varv(1,5,17)" {no such vector element \(vector not associated\)}
aa964043
KK
2862+
2863+gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
2864+gdb_continue_to_breakpoint "varx-deallocated"
2865+gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx deallocated"
e28f2cc1 2866+gdb_test "ptype varx" {type = real\(kind=4\), allocatable \(:,:,:\)} "ptype varx deallocated"
aa964043 2867+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
28b292e9
AM
2868+gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) deallocated"
2869+gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) deallocated"
aa964043
KK
2870+
2871+gdb_breakpoint [gdb_get_line_number "vary-passed"]
2872+gdb_continue_to_breakpoint "vary-passed"
2873+# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
2874+gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
2875+
2876+gdb_breakpoint [gdb_get_line_number "vary-filled"]
2877+gdb_continue_to_breakpoint "vary-filled"
2878+gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
2879+gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
2880+gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
2881+gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
2882+# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
2883+gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
2884+
2885+gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
2886+gdb_continue_to_breakpoint "varw-almostfilled"
2887+gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
2888+gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
2889+# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
2890+gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
2891+# "up" works with GCC but other Fortran compilers may copy the values into the
2892+# outer function only on the exit of the inner function.
2893+# We need both variants as depending on the arch we optionally may still be
2894+# executing the caller line or not after `finish'.
2895+gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))"
2896+gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
2897+gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
2898+gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
2899+gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
2900+
2901+gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
2902+gdb_continue_to_breakpoint "varz-almostfilled"
2903+# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
2904+gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
2905+# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
2906+# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
2907+gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
2908+gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
2909+gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
2910+gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
2911+# maps to foo::vary(1,1)
2912+gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
2913+# maps to foo::vary(2,2)
2914+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
2915+# maps to foo::vary(1,3)
2916+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
4b0e5c1b
AM
2917diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
2918new file mode 100644
4b0e5c1b
AM
2919--- /dev/null
2920+++ b/gdb/testsuite/gdb.fortran/dynamic.f90
aa964043
KK
2921@@ -0,0 +1,98 @@
2922+! Copyright 2007 Free Software Foundation, Inc.
2923+!
2924+! This program is free software; you can redistribute it and/or modify
2925+! it under the terms of the GNU General Public License as published by
2926+! the Free Software Foundation; either version 2 of the License, or
2927+! (at your option) any later version.
2928+!
2929+! This program is distributed in the hope that it will be useful,
2930+! but WITHOUT ANY WARRANTY; without even the implied warranty of
2931+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2932+! GNU General Public License for more details.
2933+!
2934+! You should have received a copy of the GNU General Public License
2935+! along with this program; if not, write to the Free Software
2936+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2937+!
2938+! Ihis file is the Fortran source file for dynamic.exp.
2939+! Original file written by Jakub Jelinek <jakub@redhat.com>.
2940+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
2941+
2942+subroutine baz
2943+ real, target, allocatable :: varx (:, :, :)
2944+ real, pointer :: varv (:, :, :)
2945+ real, target :: varu (1, 2, 3)
2946+ logical :: l
2947+ allocate (varx (1:6, 5:15, 17:28)) ! varx-init
2948+ l = allocated (varx)
2949+ varx(:, :, :) = 6 ! varx-allocated
2950+ varx(1, 5, 17) = 7
2951+ varx(2, 6, 18) = 8
2952+ varx(6, 15, 28) = 9
2953+ varv => varx ! varx-filled
2954+ l = associated (varv)
2955+ varv(3, 7, 19) = 10 ! varv-associated
2956+ varv => null () ! varv-filled
2957+ l = associated (varv)
2958+ deallocate (varx) ! varv-deassociated
2959+ l = allocated (varx)
2960+ varu(:, :, :) = 10 ! varx-deallocated
2961+ allocate (varv (1:6, 5:15, 17:28))
2962+ l = associated (varv)
2963+ varv(:, :, :) = 6
2964+ varv(1, 5, 17) = 7
2965+ varv(2, 6, 18) = 8
2966+ varv(6, 15, 28) = 9
2967+ deallocate (varv)
2968+ l = associated (varv)
2969+ varv => varu
2970+ varv(1, 1, 1) = 6
2971+ varv(1, 2, 3) = 7
2972+ l = associated (varv)
2973+end subroutine baz
2974+subroutine foo (vary, varw)
2975+ real :: vary (:, :)
2976+ real :: varw (:, :, :)
2977+ vary(:, :) = 4 ! vary-passed
2978+ vary(1, 1) = 8
2979+ vary(2, 2) = 9
2980+ vary(1, 3) = 10
2981+ varw(:, :, :) = 5 ! vary-filled
2982+ varw(1, 1, 1) = 6
2983+ varw(2, 2, 2) = 7 ! varw-almostfilled
2984+end subroutine foo
2985+subroutine bar (varz, vart)
2986+ real :: varz (*)
2987+ real :: vart (2:11, 7:*)
2988+ varz(1:3) = 4
2989+ varz(2) = 5 ! varz-almostfilled
2990+ vart(2,7) = vart(2,7)
2991+end subroutine bar
2992+program test
2993+ interface
2994+ subroutine foo (vary, varw)
2995+ real :: vary (:, :)
2996+ real :: varw (:, :, :)
2997+ end subroutine
2998+ end interface
2999+ interface
3000+ subroutine bar (varz, vart)
3001+ real :: varz (*)
3002+ real :: vart (2:11, 7:*)
3003+ end subroutine
3004+ end interface
3005+ real :: x (10, 10), y (5), z(8, 8, 8)
3006+ x(:,:) = 1
3007+ y(:) = 2
3008+ z(:,:,:) = 3
3009+ call baz
3010+ call foo (x, z(2:6, 4:7, 6:8))
3011+ call bar (y, x)
3012+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
3013+ if (x (1, 3) .ne. 10) call abort
3014+ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
3015+ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
3016+ call foo (transpose (x), z)
3017+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
3018+ if (x (3, 1) .ne. 10) call abort
3019+end
4b0e5c1b
AM
3020diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
3021new file mode 100644
4b0e5c1b
AM
3022--- /dev/null
3023+++ b/gdb/testsuite/gdb.fortran/string.exp
174fe25c 3024@@ -0,0 +1,71 @@
aa964043
KK
3025+# Copyright 2008 Free Software Foundation, Inc.
3026+
3027+# This program is free software; you can redistribute it and/or modify
3028+# it under the terms of the GNU General Public License as published by
3029+# the Free Software Foundation; either version 2 of the License, or
3030+# (at your option) any later version.
174fe25c 3031+#
aa964043
KK
3032+# This program is distributed in the hope that it will be useful,
3033+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3034+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3035+# GNU General Public License for more details.
174fe25c 3036+#
aa964043
KK
3037+# You should have received a copy of the GNU General Public License
3038+# along with this program; if not, write to the Free Software
174fe25c 3039+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
aa964043
KK
3040+
3041+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
3042+
3043+# This file is part of the gdb testsuite. It contains tests for Fortran
3044+# strings with dynamic length.
3045+
3046+set testfile "string"
3047+set srcfile ${testfile}.f90
28b292e9 3048+set binfile [standard_output_file ${testfile}]
aa964043
KK
3049+
3050+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
3051+ untested "Couldn't compile ${srcfile}"
3052+ return -1
3053+}
3054+
3055+gdb_exit
3056+gdb_start
3057+gdb_reinitialize_dir $srcdir/$subdir
3058+gdb_load ${binfile}
3059+
3060+if ![runto MAIN__] then {
3061+ perror "couldn't run to breakpoint MAIN__"
3062+ continue
3063+}
3064+
3065+gdb_breakpoint [gdb_get_line_number "var-init"]
3066+gdb_continue_to_breakpoint "var-init"
3067+gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
3068+gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
174fe25c
JP
3069+# Fortran: Support pointers to dynamic types.
3070+setup_kfail gdb/nnnnn "*-*-*"
aa964043 3071+gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
174fe25c
JP
3072+# Fortran: Support pointers to dynamic types.
3073+setup_kfail gdb/nnnnn "*-*-*"
aa964043 3074+gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
174fe25c
JP
3075+# Fortran: Support pointers to dynamic types.
3076+setup_kfail gdb/nnnnn "*-*-*"
aa964043 3077+gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
174fe25c
JP
3078+# Fortran: Support pointers to dynamic types.
3079+setup_kfail gdb/nnnnn "*-*-*"
aa964043
KK
3080+gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
3081+gdb_test "p c" "\\$\[0-9\]* = 'c'"
3082+gdb_test "p d" "\\$\[0-9\]* = 'd '"
3083+gdb_test "p e" "\\$\[0-9\]* = 'g '"
174fe25c
JP
3084+# Fortran: Support pointers to dynamic types.
3085+setup_kfail gdb/nnnnn "*-*-*"
aa964043
KK
3086+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 '\\) \\)"
3087+gdb_test "p *e" "Attempt to take contents of a non-pointer value."
3088+gdb_test "p *f" "Attempt to take contents of a non-pointer value."
3089+
3090+gdb_breakpoint [gdb_get_line_number "var-finish"]
3091+gdb_continue_to_breakpoint "var-finish"
3092+gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set"
174fe25c
JP
3093+# Fortran: Support pointers to dynamic types.
3094+setup_kfail gdb/nnnnn "*-*-*"
aa964043 3095+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
3096diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
3097new file mode 100644
4b0e5c1b
AM
3098--- /dev/null
3099+++ b/gdb/testsuite/gdb.fortran/string.f90
aa964043
KK
3100@@ -0,0 +1,37 @@
3101+! Copyright 2008 Free Software Foundation, Inc.
3102+!
3103+! This program is free software; you can redistribute it and/or modify
3104+! it under the terms of the GNU General Public License as published by
3105+! the Free Software Foundation; either version 2 of the License, or
3106+! (at your option) any later version.
3107+!
3108+! This program is distributed in the hope that it will be useful,
3109+! but WITHOUT ANY WARRANTY; without even the implied warranty of
3110+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3111+! GNU General Public License for more details.
3112+!
3113+! You should have received a copy of the GNU General Public License
3114+! along with this program; if not, write to the Free Software
3115+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3116+!
3117+! Ihis file is the Fortran source file for dynamic.exp.
3118+! Original file written by Jakub Jelinek <jakub@redhat.com>.
3119+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3120+
3121+subroutine foo (e, f)
3122+ character (len=1) :: c
3123+ character (len=8) :: d
3124+ character (len=*) :: e
3125+ character (len=*) :: f (1:7, 8:10)
3126+ c = 'c'
3127+ d = 'd'
3128+ e = 'e' ! var-init
3129+ f = 'f'
3130+ f(1,9) = 'f2'
3131+ c = 'c' ! var-finish
3132+end subroutine foo
3133+ character (len=4) :: g, h (1:7, 8:10)
3134+ g = 'g'
3135+ h = 'h'
3136+ call foo (g, h)
3137+end
4b0e5c1b
AM
3138diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp
3139new file mode 100644
4b0e5c1b
AM
3140--- /dev/null
3141+++ b/gdb/testsuite/gdb.fortran/subrange.exp
aa964043
KK
3142@@ -0,0 +1,72 @@
3143+# Copyright 2011 Free Software Foundation, Inc.
3144+
3145+# This program is free software; you can redistribute it and/or modify
3146+# it under the terms of the GNU General Public License as published by
3147+# the Free Software Foundation; either version 3 of the License, or
3148+# (at your option) any later version.
3149+#
3150+# This program is distributed in the hope that it will be useful,
3151+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3152+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3153+# GNU General Public License for more details.
3154+#
3155+# You should have received a copy of the GNU General Public License
3156+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3157+
3158+if { [skip_fortran_tests] } { return -1 }
3159+
3160+set testfile "subrange"
3161+set srcfile ${testfile}.f90
3162+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
3163+ return -1
3164+}
3165+
3166+if ![runto MAIN__] {
3167+ perror "Couldn't run to MAIN__"
3168+ continue
3169+}
3170+
3171+# Depending on the compiler version being used, the name of the 4-byte integer
3172+# and real types can be printed differently. For instance, gfortran-4.1 uses
3173+# "int4" whereas gfortran-4.3 uses "int(kind=4)".
3174+set int4 "(int4|integer\\(kind=4\\))"
3175+
3176+gdb_breakpoint [gdb_get_line_number "break-static"]
3177+gdb_continue_to_breakpoint "break-static" ".*break-static.*"
3178+
3179+foreach var {a alloc ptr} {
3180+ global pf_prefix
3181+ set old_prefix $pf_prefix
3182+ lappend pf_prefix "$var:"
3183+
3184+ setup_kfail "*-*-*" "vlaregression/9999"
3185+ gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
3186+ setup_kfail "*-*-*" "vlaregression/9999"
3187+ gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
3188+ setup_kfail "*-*-*" "vlaregression/9999"
3189+ gdb_test "p $var (1, 2:)" { = \(21, 31\)}
3190+ setup_kfail "*-*-*" "vlaregression/9999"
3191+ gdb_test "p $var (2, :2)" { = \(12, 22\)}
3192+ setup_kfail "*-*-*" "vlaregression/9999"
3193+ gdb_test "p $var (3, 2:2)" { = \(23\)}
3194+ setup_kfail "*-*-*" "vlaregression/9999"
3195+ gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
3196+ setup_kfail "*-*-*" "vlaregression/9999"
3197+ gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
3198+ setup_kfail "*-*-*" "vlaregression/9999"
3199+ gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
3200+ setup_kfail "*-*-*" "vlaregression/9999"
3201+ gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
3202+ setup_kfail "*-*-*" "vlaregression/9999"
3203+ gdb_test "p $var (:)" "Wrong number of subscripts"
3204+ setup_kfail "*-*-*" "vlaregression/9999"
3205+ gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
3206+
3207+ set pf_prefix $old_prefix
3208+}
3209+
3210+gdb_test_no_output {set $a=a}
3211+delete_breakpoints
3212+gdb_unload
3213+setup_kfail "*-*-*" "vlaregression/9999"
3214+gdb_test {p $a (3, 2:2)} { = \(23\)}
4b0e5c1b
AM
3215diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90
3216new file mode 100644
4b0e5c1b
AM
3217--- /dev/null
3218+++ b/gdb/testsuite/gdb.fortran/subrange.f90
aa964043
KK
3219@@ -0,0 +1,28 @@
3220+! Copyright 2011 Free Software Foundation, Inc.
3221+!
3222+! This program is free software; you can redistribute it and/or modify
3223+! it under the terms of the GNU General Public License as published by
3224+! the Free Software Foundation; either version 3 of the License, or
3225+! (at your option) any later version.
174fe25c 3226+!
aa964043
KK
3227+! This program is distributed in the hope that it will be useful,
3228+! but WITHOUT ANY WARRANTY; without even the implied warranty of
3229+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3230+! GNU General Public License for more details.
174fe25c 3231+!
aa964043
KK
3232+! You should have received a copy of the GNU General Public License
3233+! along with this program. If not, see <http://www.gnu.org/licenses/>.
3234+
3235+program test
3236+ integer, target :: a (4, 3)
3237+ integer, allocatable :: alloc (:, :)
3238+ integer, pointer :: ptr (:, :)
3239+ do 1 i = 1, 4
3240+ do 1 j = 1, 3
3241+ a (i, j) = j * 10 + i
3242+1 continue
3243+ allocate (alloc (4, 3))
3244+ alloc = a
3245+ ptr => a
3246+ write (*,*) a ! break-static
3247+end
4b0e5c1b
AM
3248diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
3249new file mode 100644
4b0e5c1b
AM
3250--- /dev/null
3251+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
aa964043
KK
3252@@ -0,0 +1,26 @@
3253+/* Copyright 2011 Free Software Foundation, Inc.
3254+
3255+ This file is part of GDB.
3256+
3257+ This program is free software; you can redistribute it and/or modify
3258+ it under the terms of the GNU General Public License as published by
3259+ the Free Software Foundation; either version 3 of the License, or
3260+ (at your option) any later version.
3261+
3262+ This program is distributed in the hope that it will be useful,
3263+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3264+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3265+ GNU General Public License for more details.
3266+
3267+ You should have received a copy of the GNU General Public License
3268+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
3269+
3270+int
3271+main (int argc, char **argv)
3272+{
3273+ char vla[argc];
3274+
3275+ vla[0] = 0; /* break-here */
3276+
3277+ return 0;
3278+}
4b0e5c1b
AM
3279diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
3280new file mode 100644
4b0e5c1b
AM
3281--- /dev/null
3282+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
aa964043
KK
3283@@ -0,0 +1,57 @@
3284+# Copyright 2011 Free Software Foundation, Inc.
3285+#
3286+# This program is free software; you can redistribute it and/or modify
3287+# it under the terms of the GNU General Public License as published by
3288+# the Free Software Foundation; either version 3 of the License, or
3289+# (at your option) any later version.
3290+#
3291+# This program is distributed in the hope that it will be useful,
3292+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3293+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3294+# GNU General Public License for more details.
3295+#
3296+# You should have received a copy of the GNU General Public License
3297+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3298+
3299+load_lib mi-support.exp
3300+set MIFLAGS "-i=mi2"
3301+
3302+gdb_exit
3303+if [mi_gdb_start] {
3304+ continue
3305+}
3306+
3307+set testfile "mi2-var-stale-type"
3308+set srcfile ${testfile}.c
3309+set binfile [standard_output_file ${testfile}]
3310+if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
3311+ return -1
3312+}
3313+
3314+mi_delete_breakpoints
3315+mi_gdb_reinitialize_dir $srcdir/$subdir
3316+mi_gdb_load ${binfile}
3317+
3318+mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
3319+ {\^done} \
3320+ "maintenance set internal-error quit yes"
3321+
3322+mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
3323+ {\^done} \
3324+ "maintenance set internal-error corefile yes"
3325+
3326+set line [gdb_get_line_number "break-here"]
3327+set func "main"
3328+
3329+mi_gdb_test "-break-insert -t $srcfile:$line" \
3330+ "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",fullname=\".*\",line=\"$line\",\[^\r\n\]*,original-location=\".*\"\}" \
3331+ "breakpoint at $func"
3332+
3333+if { [mi_run_cmd] < 0 } {
3334+ return -1
3335+}
3336+mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
3337+
3338+mi_create_varobj "vla" "vla" "create local variable vla"
3339+
3340+mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *"
4b0e5c1b
AM
3341diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
3342new file mode 100644
4b0e5c1b
AM
3343--- /dev/null
3344+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
aa964043
KK
3345@@ -0,0 +1,22 @@
3346+/* This file is part of GDB, the GNU debugger.
3347+
3348+ Copyright 2009 Free Software Foundation, Inc.
3349+
3350+ This program is free software; you can redistribute it and/or modify
3351+ it under the terms of the GNU General Public License as published by
3352+ the Free Software Foundation; either version 3 of the License, or
3353+ (at your option) any later version.
3354+
3355+ This program is distributed in the hope that it will be useful,
3356+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3357+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3358+ GNU General Public License for more details.
3359+
3360+ You should have received a copy of the GNU General Public License
3361+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
3362+
3363+int
3364+func (int *arr)
3365+{
3366+ return arr[0];
3367+}
4b0e5c1b
AM
3368diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
3369new file mode 100644
4b0e5c1b
AM
3370--- /dev/null
3371+++ b/gdb/testsuite/gdb.opt/array-from-register.c
aa964043
KK
3372@@ -0,0 +1,28 @@
3373+/* This file is part of GDB, the GNU debugger.
3374+
3375+ Copyright 2009 Free Software Foundation, Inc.
3376+
3377+ This program is free software; you can redistribute it and/or modify
3378+ it under the terms of the GNU General Public License as published by
3379+ the Free Software Foundation; either version 3 of the License, or
3380+ (at your option) any later version.
3381+
3382+ This program is distributed in the hope that it will be useful,
3383+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3384+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3385+ GNU General Public License for more details.
3386+
3387+ You should have received a copy of the GNU General Public License
3388+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
3389+
3390+extern int func (int *arr);
3391+
3392+int
3393+main (void)
3394+{
3395+ int arr[] = { 42 };
3396+
3397+ func (arr);
3398+
3399+ return 0;
3400+}
4b0e5c1b
AM
3401diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
3402new file mode 100644
4b0e5c1b
AM
3403--- /dev/null
3404+++ b/gdb/testsuite/gdb.opt/array-from-register.exp
aa964043
KK
3405@@ -0,0 +1,33 @@
3406+# Copyright 2009 Free Software Foundation, Inc.
3407+#
3408+# This program is free software; you can redistribute it and/or modify
3409+# it under the terms of the GNU General Public License as published by
3410+# the Free Software Foundation; either version 2 of the License, or
3411+# (at your option) any later version.
3412+#
3413+# This program is distributed in the hope that it will be useful,
3414+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3415+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3416+# GNU General Public License for more details.
3417+#
3418+# You should have received a copy of the GNU General Public License
3419+# along with this program; if not, write to the Free Software
3420+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3421+#
3422+# This file is part of the gdb testsuite.
3423+
3424+if { [prepare_for_testing array-from-register.exp "array-from-register" \
3425+ {array-from-register.c array-from-register-func.c} \
3426+ {debug optimize=-O2}] } {
3427+ return -1
3428+}
3429+
3430+if ![runto func] then {
3431+ return -1
3432+}
3433+
3434+gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
3435+
3436+# Seen regression:
3437+# Address requested for identifier "arr" which is in register $rdi
3438+gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
4b0e5c1b
AM
3439diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp
3440new file mode 100644
4b0e5c1b
AM
3441--- /dev/null
3442+++ b/gdb/testsuite/gdb.opt/fortran-string.exp
174fe25c 3443@@ -0,0 +1,46 @@
140f8057
JR
3444+# Copyright 2009 Free Software Foundation, Inc.
3445+
3446+# This program is free software; you can redistribute it and/or modify
3447+# it under the terms of the GNU General Public License as published by
3448+# the Free Software Foundation; either version 2 of the License, or
3449+# (at your option) any later version.
174fe25c 3450+#
140f8057
JR
3451+# This program is distributed in the hope that it will be useful,
3452+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3453+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3454+# GNU General Public License for more details.
174fe25c 3455+#
140f8057
JR
3456+# You should have received a copy of the GNU General Public License
3457+# along with this program; if not, write to the Free Software
174fe25c 3458+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
140f8057
JR
3459+
3460+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
3461+
3462+# Test GDB can cope with Fortran strings having their length present in a CPU
3463+# register. With -O0 the string length is passed on the stack. To make this
3464+# test meaningful the follow assertion should pass. It is not being checked
3465+# here as the "_s" symbol is compiler dependent:
3466+# (gdb) info address _s
3467+# Symbol "_s" is a variable in register XX.
3468+
3469+set test fortran-string
3470+set srcfile ${test}.f90
3471+if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f90 additional_flags=-O2}] } {
3472+ return -1
3473+}
3474+
3475+if ![runto $srcfile:[gdb_get_line_number "s = s"]] then {
3476+ perror "couldn't run to breakpoint MAIN__"
3477+ continue
3478+}
3479+
174fe25c
JP
3480+gdb_test "info args" ".*s = 'foo'.*"
3481+gdb_test_multiple "ptype s" "" {
3482+ -re -wrap "type = character \\(3\\)" {
3483+ pass $gdb_test_name
3484+ }
3485+ -re -wrap "type = character\\*3" {
3486+ pass $gdb_test_name
3487+ }
3488+}
140f8057 3489+gdb_test "p s" "\\$\[0-9\]* = 'foo'"
4b0e5c1b
AM
3490diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90
3491new file mode 100644
4b0e5c1b
AM
3492--- /dev/null
3493+++ b/gdb/testsuite/gdb.opt/fortran-string.f90
174fe25c 3494@@ -0,0 +1,29 @@
140f8057
JR
3495+! Copyright 2009 Free Software Foundation, Inc.
3496+!
3497+! This program is free software; you can redistribute it and/or modify
3498+! it under the terms of the GNU General Public License as published by
3499+! the Free Software Foundation; either version 2 of the License, or
3500+! (at your option) any later version.
3501+!
3502+! This program is distributed in the hope that it will be useful,
3503+! but WITHOUT ANY WARRANTY; without even the implied warranty of
3504+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3505+! GNU General Public License for more details.
3506+!
3507+! You should have received a copy of the GNU General Public License
3508+! along with this program; if not, write to the Free Software
3509+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3510+!
3511+! Ihis file is the Fortran source file for dynamic.exp.
3512+! Original file written by Jakub Jelinek <jakub@redhat.com>.
3513+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
3514+
3515+ subroutine f(s)
3516+ character*(*) s
3517+ s = s
174fe25c 3518+ print *, s
140f8057
JR
3519+ end
3520+
3521+ program main
3522+ call f ('foo')
3523+ end
4b0e5c1b
AM
3524diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp
3525new file mode 100644
4b0e5c1b
AM
3526--- /dev/null
3527+++ b/gdb/testsuite/gdb.pascal/arrays.exp
174fe25c 3528@@ -0,0 +1,107 @@
aa964043
KK
3529+# Copyright 2008, 2009 Free Software Foundation, Inc.
3530+#
3531+# This program is free software; you can redistribute it and/or modify
3532+# it under the terms of the GNU General Public License as published by
3533+# the Free Software Foundation; either version 3 of the License, or
3534+# (at your option) any later version.
3535+#
3536+# This program is distributed in the hope that it will be useful,
3537+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3538+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3539+# GNU General Public License for more details.
3540+#
3541+# You should have received a copy of the GNU General Public License
3542+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3543+
3544+if $tracelevel then {
3545+ strace $tracelevel
3546+}
3547+
3548+load_lib "pascal.exp"
3549+
3550+set testfile "arrays"
3551+set srcfile ${testfile}.pas
28b292e9 3552+set binfile [standard_output_file ${testfile}$EXEEXT]
aa964043
KK
3553+
3554+# These tests only work with fpc, using the -gw3 compile-option
3555+pascal_init
3556+if { $pascal_compiler_is_fpc != 1 } {
3557+ return -1
3558+}
3559+
3560+# Detect if the fpc version is below 2.3.0
3561+set fpc_generates_dwarf_for_dynamic_arrays 1
3562+if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} {
3563+ set fpc_generates_dwarf_for_dynamic_arrays 0
3564+}
3565+
3566+
3567+if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
3568+ return -1
3569+}
3570+
3571+gdb_exit
3572+gdb_start
3573+gdb_reinitialize_dir $srcdir/$subdir
3574+gdb_load ${binfile}
3575+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
3576+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
3577+
3578+
3579+if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
3580+ pass "setting breakpoint 1"
3581+}
3582+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
3583+ pass "setting breakpoint 2"
3584+}
3585+
3586+# Verify that "start" lands inside the right procedure.
3587+if { [gdb_start_cmd] < 0 } {
3588+ untested start
3589+ return -1
3590+}
3591+
3592+gdb_test "" ".* at .*${srcfile}.*" "start"
3593+
3594+gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
3595+
3596+gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type"
3597+gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer"
3598+
3599+gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
3600+
3601+gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char"
3602+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"
3603+
3604+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3605+ setup_xfail "*-*-*"
3606+}
3607+gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type"
3608+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3609+ setup_xfail "*-*-*"
3610+}
3611+gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
3612+
3613+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3614+ setup_xfail "*-*-*"
3615+}
3616+gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
3617+
3618+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3619+ setup_xfail "*-*-*"
174fe25c
JP
3620+} else {
3621+ setup_kfail "*-*-*" pascal/26106
aa964043
KK
3622+}
3623+gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
3624+
3625+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3626+ setup_xfail "*-*-*"
174fe25c
JP
3627+} else {
3628+ setup_kfail "*-*-*" pascal/26855
aa964043
KK
3629+}
3630+gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
3631+
3632+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
3633+ setup_xfail "*-*-*"
3634+}
3635+gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
4b0e5c1b
AM
3636diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas
3637new file mode 100644
4b0e5c1b
AM
3638--- /dev/null
3639+++ b/gdb/testsuite/gdb.pascal/arrays.pas
aa964043
KK
3640@@ -0,0 +1,82 @@
3641+{
3642+ Copyright 2008, 2009 Free Software Foundation, Inc.
3643+
3644+ This program is free software; you can redistribute it and/or modify
3645+ it under the terms of the GNU General Public License as published by
3646+ the Free Software Foundation; either version 3 of the License, or
3647+ (at your option) any later version.
3648+
3649+ This program is distributed in the hope that it will be useful,
3650+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3651+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3652+ GNU General Public License for more details.
3653+
3654+ You should have received a copy of the GNU General Public License
3655+ along with this program. If not, see <http://www.gnu.org/licenses/>.
3656+}
3657+
3658+program arrays;
3659+
3660+{$mode objfpc}{$h+}
3661+
3662+uses sysutils;
3663+
3664+type TStatArrInt= array[0..11] of integer;
3665+ TDynArrInt= array of integer;
3666+ TStatArrStr= array[0..12] of string;
3667+ TDynArrStr= array of string;
3668+ TDynArrChar = array of char;
3669+ TStatArrChar = array [0..11] of char;
3670+
3671+ TStat2dArrInt = array[0..11,0..4] of integer;
3672+
3673+var StatArrInt: TStatArrInt;
3674+ StatArrInt_: Array[0..11] of integer;
3675+ DynArrInt: TDynArrInt;
3676+ DynArrInt_: Array of integer;
3677+ StatArrStr: TStatArrStr;
3678+ DynArrStr: TDynArrStr;
3679+ StatArrChar: TStatArrChar;
3680+ DynArrChar: TDynArrChar;
3681+
3682+ Stat2dArrInt: TStat2dArrInt;
3683+
3684+ s: string;
174fe25c 3685+
aa964043
KK
3686+ i,j : integer;
3687+
3688+begin
3689+ for i := 0 to 11 do
3690+ begin
3691+ StatArrInt[i]:= i+50;
3692+ StatArrInt_[i]:= i+50;
3693+ StatArrChar[i]:= chr(ord('a')+i);
3694+ for j := 0 to 4 do
3695+ Stat2dArrInt[i,j]:=i+j;
3696+ end;
3697+ writeln(StatArrInt_[0]);
3698+ writeln(StatArrInt[0]); { set breakpoint 1 here }
3699+ writeln(StatArrChar[0]);
3700+ writeln(Stat2dArrInt[0,0]);
3701+
3702+ setlength(DynArrInt,13);
3703+ setlength(DynArrInt_,13);
3704+ setlength(DynArrStr,13);
3705+ setlength(DynArrChar,13);
3706+ for i := 0 to 12 do
3707+ begin
3708+ DynArrInt[i]:= i+50;
3709+ DynArrInt_[i]:= i+50;
3710+ DynArrChar[i]:= chr(ord('a')+i);
3711+ StatArrStr[i]:='str'+inttostr(i);
3712+ DynArrStr[i]:='dstr'+inttostr(i);
3713+ end;
3714+ writeln(DynArrInt_[1]);
174fe25c
JP
3715+ writeln(DynArrInt[1]);
3716+ writeln(DynArrStr[1]);
aa964043
KK
3717+ writeln(StatArrStr[1]);
3718+ writeln(DynArrChar[1]);
3719+
3720+ s := 'test'#0'string';
3721+ writeln(s); { set breakpoint 2 here }
3722+end.
4b0e5c1b 3723diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
4b0e5c1b
AM
3724--- a/gdb/testsuite/lib/gdb.exp
3725+++ b/gdb/testsuite/lib/gdb.exp
174fe25c 3726@@ -224,6 +224,11 @@ proc gdb_unload {} {
e28f2cc1 3727 send_gdb "y\n" answer
aa964043
KK
3728 exp_continue
3729 }
3730+ -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
3731+ { send_gdb "y\n"
3732+ verbose "\t\tUnloading symbols for program being debugged"
3733+ exp_continue
3734+ }
3735 -re "Discard symbol table from .*y or n.*$" {
e28f2cc1 3736 send_gdb "y\n" answer
aa964043 3737 exp_continue
4b0e5c1b 3738diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp
4b0e5c1b
AM
3739--- a/gdb/testsuite/lib/pascal.exp
3740+++ b/gdb/testsuite/lib/pascal.exp
3741@@ -37,6 +37,9 @@ proc pascal_init {} {
174fe25c
JP
3742 gdb_persistent_global pascal_compiler_is_fpc
3743 gdb_persistent_global gpc_compiler
3744 gdb_persistent_global fpc_compiler
3745+ gdb_persistent_global fpcversion_major
3746+ gdb_persistent_global fpcversion_minor
3747+ gdb_persistent_global fpcversion_release
aa964043
KK
3748 global env
3749
3750 if { $pascal_init_done == 1 } {
4b0e5c1b 3751@@ -64,6 +67,20 @@ proc pascal_init {} {
aa964043
KK
3752 set pascal_compiler_is_fpc 1
3753 verbose -log "Free Pascal compiler found"
3754 }
3755+
3756+ # Detect the fpc-version
3757+ if { $pascal_compiler_is_fpc == 1 } {
3758+ set fpcversion_major 1
3759+ set fpcversion_minor 0
3760+ set fpcversion_release 0
174fe25c 3761+ set fpcversion [ remote_exec host $fpc_compiler "-iV" ]
aa964043
KK
3762+ if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] {
3763+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major
3764+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor
3765+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release
3766+ }
3767+ verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
3768+ }
3769 }
3770 set pascal_init_done 1
3771 }
This page took 0.469246 seconds and 4 git commands to generate.