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