1 [PATCH 00/23] Fortran dynamic array support
2 https://sourceware.org/ml/gdb-patches/2014-06/msg00108.html
3 https://github.com/intel-gdb/vla/tree/vla-fortran
6 commit 511bff520372ffc10fa2ff569c176bdf1e6e475d
9 Index: gdb-7.8.90.20150126/gdb/c-valprint.c
10 ===================================================================
11 --- gdb-7.8.90.20150126.orig/gdb/c-valprint.c 2015-01-26 07:47:25.832758314 +0100
12 +++ gdb-7.8.90.20150126/gdb/c-valprint.c 2015-01-26 07:47:42.394829861 +0100
13 @@ -537,7 +537,16 @@ c_value_print (struct value *val, struct
16 fprintf_filtered (stream, "(");
17 - type_print (value_type (val), "", stream, -1);
18 + if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
22 + v = value_ind (val);
24 + type_print (value_type (v), "", stream, -1);
27 + type_print (value_type (val), "", stream, -1);
28 fprintf_filtered (stream, ") ");
31 Index: gdb-7.8.90.20150126/gdb/dwarf2loc.h
32 ===================================================================
33 --- gdb-7.8.90.20150126.orig/gdb/dwarf2loc.h 2015-01-26 07:47:25.832758314 +0100
34 +++ gdb-7.8.90.20150126/gdb/dwarf2loc.h 2015-01-26 07:47:42.395829865 +0100
35 @@ -111,6 +111,11 @@ int dwarf2_evaluate_property (const stru
39 +/* Checks if a dwarf location definition is valid.
40 + Returns 1 if valid; 0 otherwise. */
42 +extern int dwarf2_address_data_valid (const struct type *type);
44 /* A helper for the compiler interface that compiles a single dynamic
47 Index: gdb-7.8.90.20150126/gdb/dwarf2read.c
48 ===================================================================
49 --- gdb-7.8.90.20150126.orig/gdb/dwarf2read.c 2015-01-26 07:47:25.845758371 +0100
50 +++ gdb-7.8.90.20150126/gdb/dwarf2read.c 2015-01-26 07:48:05.833931116 +0100
51 @@ -1855,6 +1855,12 @@ static void process_cu_includes (void);
52 static void check_producer (struct dwarf2_cu *cu);
54 static void free_line_header_voidp (void *arg);
57 +attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
58 + struct dwarf2_cu *cu, struct dynamic_prop *prop,
59 + const gdb_byte *additional_data, int additional_data_size);
62 /* Various complaints about symbol reading that don't abort the process. */
64 @@ -14354,29 +14360,92 @@ read_tag_string_type (struct die_info *d
65 struct gdbarch *gdbarch = get_objfile_arch (objfile);
66 struct type *type, *range_type, *index_type, *char_type;
67 struct attribute *attr;
68 - unsigned int length;
69 + unsigned int length = UINT_MAX;
71 + index_type = objfile_type (objfile)->builtin_int;
72 + range_type = create_static_range_type (NULL, index_type, 1, length);
74 + /* If DW_AT_string_length is defined, the length is stored at some location
76 attr = dwarf2_attr (die, DW_AT_string_length, cu);
79 - length = DW_UNSND (attr);
80 + if (attr_form_is_block (attr))
82 + struct attribute *byte_size, *bit_size;
83 + struct dynamic_prop high;
85 + byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
86 + bit_size = dwarf2_attr (die, DW_AT_bit_size, cu);
88 + /* DW_AT_byte_size should never occur together in combination with
89 + DW_AT_string_length. */
90 + if ((byte_size == NULL && bit_size != NULL) ||
91 + (byte_size != NULL && bit_size == NULL))
92 + complaint (&symfile_complaints, _("DW_AT_byte_size AND "
93 + "DW_AT_bit_size found together at the same time."));
95 + /* If DW_AT_string_length AND DW_AT_byte_size exist together, it
96 + describes the number of bytes that should be read from the length
98 + if (byte_size != NULL && bit_size == NULL)
100 + /* Build new dwarf2_locexpr_baton structure with additions to the
101 + data attribute, to reflect DWARF specialities to get address
103 + const gdb_byte append_ops[] = {
104 + /* DW_OP_deref_size: size of an address on the target machine
105 + (bytes), where the size will be specified by the next
108 + /* Operand for DW_OP_deref_size. */
109 + DW_UNSND (byte_size) };
111 + if (!attr_to_dynamic_prop (attr, die, cu, &high,
112 + append_ops, ARRAY_SIZE (append_ops)))
113 + complaint (&symfile_complaints,
114 + _("Could not parse DW_AT_byte_size"));
116 + else if (bit_size != NULL && byte_size == NULL)
117 + complaint (&symfile_complaints, _("DW_AT_string_length AND "
118 + "DW_AT_bit_size found but not supported yet."));
119 + /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default
120 + is the address size of the target machine. */
123 + const gdb_byte append_ops[] = { DW_OP_deref };
125 + if (!attr_to_dynamic_prop (attr, die, cu, &high, append_ops,
126 + ARRAY_SIZE (append_ops)))
127 + complaint (&symfile_complaints,
128 + _("Could not parse DW_AT_string_length"));
131 + TYPE_RANGE_DATA (range_type)->high = high;
135 + TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
136 + TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
141 - /* Check for the DW_AT_byte_size attribute. */
142 + /* Check for the DW_AT_byte_size attribute, which represents the length
144 attr = dwarf2_attr (die, DW_AT_byte_size, cu);
147 - length = DW_UNSND (attr);
148 + TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
149 + TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
154 + TYPE_HIGH_BOUND (range_type) = 1;
155 + TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
159 - index_type = objfile_type (objfile)->builtin_int;
160 - range_type = create_static_range_type (NULL, index_type, 1, length);
161 char_type = language_string_char_type (cu->language_defn, gdbarch);
162 type = create_string_type (NULL, char_type, range_type);
164 @@ -14693,13 +14762,15 @@ read_base_type (struct die_info *die, st
165 return set_die_type (die, type, cu);
169 /* Parse dwarf attribute if it's a block, reference or constant and put the
170 resulting value of the attribute into struct bound_prop.
171 Returns 1 if ATTR could be resolved into PROP, 0 otherwise. */
174 attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
175 - struct dwarf2_cu *cu, struct dynamic_prop *prop)
176 + struct dwarf2_cu *cu, struct dynamic_prop *prop,
177 + const gdb_byte *additional_data, int additional_data_size)
179 struct dwarf2_property_baton *baton;
180 struct obstack *obstack = &cu->objfile->objfile_obstack;
181 @@ -14712,8 +14783,25 @@ attr_to_dynamic_prop (const struct attri
182 baton = obstack_alloc (obstack, sizeof (*baton));
183 baton->referenced_type = NULL;
184 baton->locexpr.per_cu = cu->per_cu;
185 - baton->locexpr.size = DW_BLOCK (attr)->size;
186 - baton->locexpr.data = DW_BLOCK (attr)->data;
188 + if (additional_data != NULL && additional_data_size > 0)
192 + data = obstack_alloc (&cu->objfile->objfile_obstack,
193 + DW_BLOCK (attr)->size + additional_data_size);
194 + memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
195 + memcpy (data + DW_BLOCK (attr)->size,
196 + additional_data, additional_data_size);
198 + baton->locexpr.data = data;
199 + baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size;
203 + baton->locexpr.data = DW_BLOCK (attr)->data;
204 + baton->locexpr.size = DW_BLOCK (attr)->size;
206 prop->data.baton = baton;
207 prop->kind = PROP_LOCEXPR;
208 gdb_assert (prop->data.baton != NULL);
209 @@ -14743,8 +14831,28 @@ attr_to_dynamic_prop (const struct attri
210 baton = obstack_alloc (obstack, sizeof (*baton));
211 baton->referenced_type = die_type (target_die, target_cu);
212 baton->locexpr.per_cu = cu->per_cu;
213 - baton->locexpr.size = DW_BLOCK (target_attr)->size;
214 - baton->locexpr.data = DW_BLOCK (target_attr)->data;
216 + if (additional_data != NULL && additional_data_size > 0)
220 + data = obstack_alloc (&cu->objfile->objfile_obstack,
221 + DW_BLOCK (target_attr)->size + additional_data_size);
222 + memcpy (data, DW_BLOCK (target_attr)->data,
223 + DW_BLOCK (target_attr)->size);
224 + memcpy (data + DW_BLOCK (target_attr)->size,
225 + additional_data, additional_data_size);
227 + baton->locexpr.data = data;
228 + baton->locexpr.size = (DW_BLOCK (target_attr)->size
229 + + additional_data_size);
233 + baton->locexpr.data = DW_BLOCK (target_attr)->data;
234 + baton->locexpr.size = DW_BLOCK (target_attr)->size;
237 prop->data.baton = baton;
238 prop->kind = PROP_LOCEXPR;
239 gdb_assert (prop->data.baton != NULL);
240 @@ -14779,7 +14887,7 @@ read_subrange_type (struct die_info *die
241 struct type *base_type, *orig_base_type;
242 struct type *range_type;
243 struct attribute *attr;
244 - struct dynamic_prop low, high;
245 + struct dynamic_prop low, high, stride;
246 int low_default_is_valid;
247 int high_bound_is_count = 0;
249 @@ -14799,7 +14907,9 @@ read_subrange_type (struct die_info *die
251 low.kind = PROP_CONST;
252 high.kind = PROP_CONST;
253 + stride.kind = PROP_CONST;
254 high.data.const_val = 0;
255 + stride.data.const_val = 0;
257 /* Set LOW_DEFAULT_IS_VALID if current language and DWARF version allow
258 omitting DW_AT_lower_bound. */
259 @@ -14832,19 +14942,26 @@ read_subrange_type (struct die_info *die
263 + attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
265 + if (!attr_to_dynamic_prop (attr, die, cu, &stride, NULL, 0))
266 + complaint (&symfile_complaints, _("Missing DW_AT_byte_stride "
267 + "- DIE at 0x%x [in module %s]"),
268 + die->offset.sect_off, objfile_name (cu->objfile));
270 attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
272 - attr_to_dynamic_prop (attr, die, cu, &low);
273 + attr_to_dynamic_prop (attr, die, cu, &low, NULL, 0);
274 else if (!low_default_is_valid)
275 complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
276 "- DIE at 0x%x [in module %s]"),
277 die->offset.sect_off, objfile_name (cu->objfile));
279 attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
280 - if (!attr_to_dynamic_prop (attr, die, cu, &high))
281 + if (!attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
283 attr = dwarf2_attr (die, DW_AT_count, cu);
284 - if (attr_to_dynamic_prop (attr, die, cu, &high))
285 + if (attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
287 /* If bounds are constant do the final calculation here. */
288 if (low.kind == PROP_CONST && high.kind == PROP_CONST)
289 @@ -14908,7 +15025,7 @@ read_subrange_type (struct die_info *die
290 && !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask))
291 high.data.const_val |= negative_mask;
293 - range_type = create_range_type (NULL, orig_base_type, &low, &high);
294 + range_type = create_range_type (NULL, orig_base_type, &low, &high, &stride);
296 if (high_bound_is_count)
297 TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1;
298 @@ -21994,7 +22111,44 @@ set_die_type (struct die_info *die, stru
300 /* Read DW_AT_data_location and set in type. */
301 attr = dwarf2_attr (die, DW_AT_data_location, cu);
302 - if (attr_to_dynamic_prop (attr, die, cu, &prop))
303 + if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
305 + TYPE_DATA_LOCATION (type)
306 + = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
307 + *TYPE_DATA_LOCATION (type) = prop;
310 + /* Read DW_AT_allocated and set in type. */
311 + attr = dwarf2_attr (die, DW_AT_allocated, cu);
312 + if (attr_form_is_block (attr))
314 + struct dynamic_prop prop;
316 + if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
318 + TYPE_ALLOCATED_PROP (type)
319 + = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
320 + *TYPE_ALLOCATED_PROP (type) = prop;
324 + /* Read DW_AT_associated and set in type. */
325 + attr = dwarf2_attr (die, DW_AT_associated, cu);
326 + if (attr_form_is_block (attr))
328 + struct dynamic_prop prop;
330 + if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
332 + TYPE_ASSOCIATED_PROP (type)
333 + = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
334 + *TYPE_ASSOCIATED_PROP (type) = prop;
338 + /* Read DW_AT_data_location and set in type. */
339 + attr = dwarf2_attr (die, DW_AT_data_location, cu);
340 + if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
342 TYPE_DATA_LOCATION (type)
343 = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
344 Index: gdb-7.8.90.20150126/gdb/f-typeprint.c
345 ===================================================================
346 --- gdb-7.8.90.20150126.orig/gdb/f-typeprint.c 2015-01-26 07:47:25.846758375 +0100
347 +++ gdb-7.8.90.20150126/gdb/f-typeprint.c 2015-01-26 07:47:42.402829895 +0100
352 +#include "valprint.h"
354 #if 0 /* Currently unused. */
355 static void f_type_print_args (struct type *, struct ui_file *);
356 @@ -53,6 +54,17 @@ f_print_type (struct type *type, const c
360 + if (TYPE_NOT_ASSOCIATED (type))
362 + val_print_not_associated (stream);
365 + if (TYPE_NOT_ALLOCATED (type))
367 + val_print_not_allocated (stream);
371 f_type_print_base (type, stream, show, level);
372 code = TYPE_CODE (type);
373 if ((varstring != NULL && *varstring != '\0')
374 @@ -167,28 +179,36 @@ f_type_print_varspec_suffix (struct type
375 if (arrayprint_recurse_level == 1)
376 fprintf_filtered (stream, "(");
378 - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
379 - f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
380 - arrayprint_recurse_level);
382 - lower_bound = f77_get_lowerbound (type);
383 - if (lower_bound != 1) /* Not the default. */
384 - fprintf_filtered (stream, "%d:", lower_bound);
386 - /* Make sure that, if we have an assumed size array, we
387 - print out a warning and print the upperbound as '*'. */
389 - if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
390 - fprintf_filtered (stream, "*");
391 + if (TYPE_NOT_ASSOCIATED (type))
392 + val_print_not_associated (stream);
393 + else if (TYPE_NOT_ALLOCATED (type))
394 + val_print_not_allocated (stream);
397 - upper_bound = f77_get_upperbound (type);
398 - fprintf_filtered (stream, "%d", upper_bound);
401 - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
402 - f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
403 - arrayprint_recurse_level);
406 + if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
407 + f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
408 + arrayprint_recurse_level);
410 + lower_bound = f77_get_lowerbound (type);
411 + if (lower_bound != 1) /* Not the default. */
412 + fprintf_filtered (stream, "%d:", lower_bound);
414 + /* Make sure that, if we have an assumed size array, we
415 + print out a warning and print the upperbound as '*'. */
417 + if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
418 + fprintf_filtered (stream, "*");
421 + upper_bound = f77_get_upperbound (type);
422 + fprintf_filtered (stream, "%d", upper_bound);
425 + if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
426 + f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
427 + arrayprint_recurse_level);
429 if (arrayprint_recurse_level == 1)
430 fprintf_filtered (stream, ")");
432 Index: gdb-7.8.90.20150126/gdb/f-valprint.c
433 ===================================================================
434 --- gdb-7.8.90.20150126.orig/gdb/f-valprint.c 2015-01-26 07:47:25.847758379 +0100
435 +++ gdb-7.8.90.20150126/gdb/f-valprint.c 2015-01-26 07:47:42.403829900 +0100
438 extern void _initialize_f_valprint (void);
439 static void info_common_command (char *, int);
440 -static void f77_create_arrayprint_offset_tbl (struct type *,
442 static void f77_get_dynamic_length_of_aggregate (struct type *);
444 int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
445 @@ -45,15 +43,6 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIM
446 /* Array which holds offsets to be applied to get a row's elements
447 for a given array. Array also holds the size of each subarray. */
449 -/* The following macro gives us the size of the nth dimension, Where
452 -#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
454 -/* The following gives us the offset for row n where n is 1-based. */
456 -#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
459 f77_get_lowerbound (struct type *type)
461 @@ -111,47 +100,6 @@ f77_get_dynamic_length_of_aggregate (str
462 * TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
465 -/* Function that sets up the array offset,size table for the array
469 -f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
471 - struct type *tmp_type;
478 - while (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
480 - upper = f77_get_upperbound (tmp_type);
481 - lower = f77_get_lowerbound (tmp_type);
483 - F77_DIM_SIZE (ndimen) = upper - lower + 1;
485 - tmp_type = TYPE_TARGET_TYPE (tmp_type);
489 - /* Now we multiply eltlen by all the offsets, so that later we
490 - can print out array elements correctly. Up till now we
491 - know an offset to apply to get the item but we also
492 - have to know how much to add to get to the next item. */
495 - eltlen = TYPE_LENGTH (tmp_type);
496 - F77_DIM_OFFSET (ndimen) = eltlen;
497 - while (--ndimen > 0)
499 - eltlen *= F77_DIM_SIZE (ndimen + 1);
500 - F77_DIM_OFFSET (ndimen) = eltlen;
506 /* Actual function which prints out F77 arrays, Valaddr == address in
507 the superior. Address == the address in the inferior. */
509 @@ -164,41 +112,62 @@ f77_print_array_1 (int nss, int ndimensi
510 const struct value_print_options *options,
513 + struct type *range_type = TYPE_INDEX_TYPE (check_typedef (type));
514 + CORE_ADDR addr = address + embedded_offset;
515 + LONGEST lowerbound, upperbound;
518 + get_discrete_bounds (range_type, &lowerbound, &upperbound);
520 if (nss != ndimensions)
523 - (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max);
526 + LONGEST byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
529 + dim_size = byte_stride;
531 + dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
533 + for (i = lowerbound;
534 + (i < upperbound + 1 && (*elts) < options->print_max);
537 + struct value *subarray = value_from_contents_and_address
538 + (TYPE_TARGET_TYPE (type), value_contents_for_printing_const (val)
539 + + offs, addr + offs);
541 fprintf_filtered (stream, "( ");
542 - f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
544 - embedded_offset + i * F77_DIM_OFFSET (nss),
546 - stream, recurse, val, options, elts);
547 + f77_print_array_1 (nss + 1, ndimensions, value_type (subarray),
548 + value_contents_for_printing (subarray),
549 + value_embedded_offset (subarray),
550 + value_address (subarray),
551 + stream, recurse, subarray, options, elts);
553 fprintf_filtered (stream, ") ");
555 - if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
556 + if (*elts >= options->print_max && i < upperbound)
557 fprintf_filtered (stream, "...");
561 - for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
562 + for (i = lowerbound; i < upperbound + 1 && (*elts) < options->print_max;
565 - val_print (TYPE_TARGET_TYPE (type),
567 - embedded_offset + i * F77_DIM_OFFSET (ndimensions),
568 - address, stream, recurse,
569 - val, options, current_language);
570 + struct value *elt = value_subscript ((struct value *)val, i);
572 + val_print (value_type (elt),
573 + value_contents_for_printing (elt),
574 + value_embedded_offset (elt),
575 + value_address (elt), stream, recurse,
576 + elt, options, current_language);
578 - if (i != (F77_DIM_SIZE (nss) - 1))
579 + if (i != upperbound)
580 fprintf_filtered (stream, ", ");
582 if ((*elts == options->print_max - 1)
583 - && (i != (F77_DIM_SIZE (nss) - 1)))
584 + && (i != upperbound))
585 fprintf_filtered (stream, "...");
588 @@ -225,12 +194,6 @@ f77_print_array (struct type *type, cons
589 Type node corrupt! F77 arrays cannot have %d subscripts (%d Max)"),
590 ndimensions, MAX_FORTRAN_DIMS);
592 - /* Since F77 arrays are stored column-major, we set up an
593 - offset table to get at the various row's elements. The
594 - offset table contains entries for both offset and subarray size. */
596 - f77_create_arrayprint_offset_tbl (type, stream);
598 f77_print_array_1 (1, ndimensions, type, valaddr, embedded_offset,
599 address, stream, recurse, val, options, &elts);
601 @@ -375,12 +338,15 @@ f_val_print (struct type *type, const gd
602 fprintf_filtered (stream, "( ");
603 for (index = 0; index < TYPE_NFIELDS (type); index++)
605 - int offset = TYPE_FIELD_BITPOS (type, index) / 8;
606 + struct value *field = value_field
607 + ((struct value *)original_value, index);
609 + val_print (value_type (field),
610 + value_contents_for_printing (field),
611 + value_embedded_offset (field),
612 + value_address (field), stream, recurse + 1,
613 + field, options, current_language);
615 - val_print (TYPE_FIELD_TYPE (type, index), valaddr,
616 - embedded_offset + offset,
617 - address, stream, recurse + 1,
618 - original_value, options, current_language);
619 if (index != TYPE_NFIELDS (type) - 1)
620 fputs_filtered (", ", stream);
622 Index: gdb-7.8.90.20150126/gdb/gdbtypes.c
623 ===================================================================
624 --- gdb-7.8.90.20150126.orig/gdb/gdbtypes.c 2015-01-26 07:47:25.850758392 +0100
625 +++ gdb-7.8.90.20150126/gdb/gdbtypes.c 2015-01-26 07:47:42.404829904 +0100
626 @@ -815,7 +815,8 @@ allocate_stub_method (struct type *type)
628 create_range_type (struct type *result_type, struct type *index_type,
629 const struct dynamic_prop *low_bound,
630 - const struct dynamic_prop *high_bound)
631 + const struct dynamic_prop *high_bound,
632 + const struct dynamic_prop *stride)
634 if (result_type == NULL)
635 result_type = alloc_type_copy (index_type);
636 @@ -830,6 +831,7 @@ create_range_type (struct type *result_t
637 TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
638 TYPE_RANGE_DATA (result_type)->low = *low_bound;
639 TYPE_RANGE_DATA (result_type)->high = *high_bound;
640 + TYPE_RANGE_DATA (result_type)->stride = *stride;
642 if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0)
643 TYPE_UNSIGNED (result_type) = 1;
644 @@ -858,7 +860,7 @@ struct type *
645 create_static_range_type (struct type *result_type, struct type *index_type,
646 LONGEST low_bound, LONGEST high_bound)
648 - struct dynamic_prop low, high;
649 + struct dynamic_prop low, high, stride;
651 low.kind = PROP_CONST;
652 low.data.const_val = low_bound;
653 @@ -866,7 +868,11 @@ create_static_range_type (struct type *r
654 high.kind = PROP_CONST;
655 high.data.const_val = high_bound;
657 - result_type = create_range_type (result_type, index_type, &low, &high);
658 + stride.kind = PROP_CONST;
659 + stride.data.const_val = 0;
661 + result_type = create_range_type (result_type, index_type,
662 + &low, &high, &stride);
666 @@ -1020,18 +1026,24 @@ create_array_type_with_stride (struct ty
668 TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
669 TYPE_TARGET_TYPE (result_type) = element_type;
670 - if (has_static_range (TYPE_RANGE_DATA (range_type)))
671 + if (has_static_range (TYPE_RANGE_DATA (range_type))
672 + && dwarf2_address_data_valid (result_type))
674 - LONGEST low_bound, high_bound;
675 + LONGEST low_bound, high_bound, byte_stride;
677 if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
678 low_bound = high_bound = 0;
679 CHECK_TYPEDEF (element_type);
681 + byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
683 /* Be careful when setting the array length. Ada arrays can be
684 empty arrays with the high_bound being smaller than the low_bound.
685 In such cases, the array length should be zero. */
686 if (high_bound < low_bound)
687 TYPE_LENGTH (result_type) = 0;
688 + else if (byte_stride > 0)
689 + TYPE_LENGTH (result_type) = byte_stride * (high_bound - low_bound + 1);
690 else if (bit_stride > 0)
691 TYPE_LENGTH (result_type) =
692 (bit_stride * (high_bound - low_bound + 1) + 7) / 8;
693 @@ -1630,12 +1642,31 @@ stub_noname_complaint (void)
695 is_dynamic_type_internal (struct type *type, int top_level)
702 type = check_typedef (type);
704 /* We only want to recognize references at the outermost level. */
705 if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
706 type = check_typedef (TYPE_TARGET_TYPE (type));
708 + if (TYPE_ASSOCIATED_PROP (type))
711 + if (TYPE_ALLOCATED_PROP (type))
714 + /* Scan field types in the Fortran case for nested dynamic types.
715 + This will be done only for Fortran as in the C++ case an endless recursion
716 + can occur in the area of classes. */
717 + if (current_language->la_language == language_fortran)
718 + for (index = 0; index < TYPE_NFIELDS (type); index++)
719 + if (is_dynamic_type (TYPE_FIELD_TYPE (type, index)))
722 /* Types that have a dynamic TYPE_DATA_LOCATION are considered
723 dynamic, even if the type itself is statically defined.
724 From a user's point of view, this may appear counter-intuitive;
725 @@ -1656,11 +1687,19 @@ is_dynamic_type_internal (struct type *t
727 gdb_assert (TYPE_NFIELDS (type) == 1);
729 - /* The array is dynamic if either the bounds are dynamic,
730 - or the elements it contains have a dynamic contents. */
731 + /* The array is dynamic if either
732 + - the bounds are dynamic,
733 + - the elements it contains have a dynamic contents
734 + - a data_locaton attribute was found. */
735 if (is_dynamic_type_internal (TYPE_INDEX_TYPE (type), 0))
737 - return is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0);
738 + else if (TYPE_DATA_LOCATION (type) != NULL
739 + && (TYPE_DATA_LOCATION_KIND (type) == PROP_LOCEXPR
740 + || TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST))
743 + return is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0);
747 case TYPE_CODE_STRUCT:
748 @@ -1673,6 +1712,17 @@ is_dynamic_type_internal (struct type *t
749 && is_dynamic_type_internal (TYPE_FIELD_TYPE (type, i), 0))
752 + case TYPE_CODE_PTR:
754 + if (TYPE_TARGET_TYPE (type)
755 + && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRING)
756 + return is_dynamic_type (check_typedef (TYPE_TARGET_TYPE (type)));
766 @@ -1701,7 +1751,8 @@ resolve_dynamic_range (struct type *dyn_
767 struct type *static_range_type;
768 const struct dynamic_prop *prop;
769 const struct dwarf2_locexpr_baton *baton;
770 - struct dynamic_prop low_bound, high_bound;
771 + struct dynamic_prop low_bound, high_bound, stride;
772 + struct type *range_copy = copy_type (dyn_range_type);
774 gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE);
776 @@ -1732,10 +1783,17 @@ resolve_dynamic_range (struct type *dyn_
777 high_bound.kind = PROP_UNDEFINED;
778 high_bound.data.const_val = 0;
781 + prop = &TYPE_RANGE_DATA (dyn_range_type)->stride;
782 + if (dwarf2_evaluate_property (prop, addr, &value))
784 + stride.kind = PROP_CONST;
785 + stride.data.const_val = value;
788 - static_range_type = create_range_type (copy_type (dyn_range_type),
789 - TYPE_TARGET_TYPE (dyn_range_type),
790 - &low_bound, &high_bound);
791 + static_range_type = create_range_type (range_copy,
792 + TYPE_TARGET_TYPE (range_copy),
793 + &low_bound, &high_bound, &stride);
794 TYPE_RANGE_DATA (static_range_type)->flag_bound_evaluated = 1;
795 return static_range_type;
797 @@ -1751,23 +1809,46 @@ resolve_dynamic_array (struct type *type
798 struct type *elt_type;
799 struct type *range_type;
800 struct type *ary_dim;
801 + struct dynamic_prop *prop;
802 + struct type *copy = copy_type (type);
804 - gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
805 + gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY
806 + || TYPE_CODE (type) == TYPE_CODE_STRING);
809 range_type = check_typedef (TYPE_INDEX_TYPE (elt_type));
810 range_type = resolve_dynamic_range (range_type, addr);
812 + prop = TYPE_ALLOCATED_PROP (type);
813 + if (dwarf2_evaluate_property (prop, addr, &value))
815 + TYPE_ALLOCATED_PROP (copy)->kind = PROP_CONST;
816 + TYPE_ALLOCATED_PROP (copy)->data.const_val = value;
819 + prop = TYPE_ASSOCIATED_PROP (type);
820 + if (dwarf2_evaluate_property (prop, addr, &value))
822 + TYPE_ASSOCIATED_PROP (copy)->kind = PROP_CONST;
823 + TYPE_ASSOCIATED_PROP (copy)->data.const_val = value;
826 ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
828 - if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
829 - elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (type), addr);
830 + if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY
831 + || TYPE_CODE (ary_dim) == TYPE_CODE_STRING))
832 + elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (copy), addr);
834 elt_type = TYPE_TARGET_TYPE (type);
836 - return create_array_type (copy_type (type),
839 + if (TYPE_CODE (type) == TYPE_CODE_STRING)
840 + return create_string_type (copy,
844 + return create_array_type (copy,
849 /* Resolve dynamic bounds of members of the union TYPE to static
850 @@ -1938,6 +2019,25 @@ resolve_dynamic_type_internal (struct ty
852 TYPE_DATA_LOCATION (resolved_type) = NULL;
854 + /* Resolve data_location attribute. */
855 + prop = TYPE_DATA_LOCATION (resolved_type);
856 + if (dwarf2_evaluate_property (prop, addr, &value))
858 + struct type *range_type = TYPE_INDEX_TYPE (resolved_type);
860 + /* Adjust the data location with the value of byte stride if set, which
861 + can describe the separation between successive elements along the
863 + if (TYPE_BYTE_STRIDE (range_type) < 0)
864 + value += (TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type))
865 + * TYPE_BYTE_STRIDE (range_type);
867 + TYPE_DATA_LOCATION_ADDR (resolved_type) = value;
868 + TYPE_DATA_LOCATION_KIND (resolved_type) = PROP_CONST;
871 + TYPE_DATA_LOCATION (resolved_type) = NULL;
873 return resolved_type;
876 @@ -4174,6 +4274,27 @@ copy_type_recursive (struct objfile *obj
877 sizeof (struct dynamic_prop));
880 + /* Copy the data location information. */
881 + if (TYPE_DATA_LOCATION (type) != NULL)
883 + TYPE_DATA_LOCATION (new_type) = xmalloc (sizeof (struct dynamic_prop));
884 + *TYPE_DATA_LOCATION (new_type) = *TYPE_DATA_LOCATION (type);
887 + /* Copy allocated information. */
888 + if (TYPE_ALLOCATED_PROP (type) != NULL)
890 + TYPE_ALLOCATED_PROP (new_type) = xmalloc (sizeof (struct dynamic_prop));
891 + *TYPE_ALLOCATED_PROP (new_type) = *TYPE_ALLOCATED_PROP (type);
894 + /* Copy associated information. */
895 + if (TYPE_ASSOCIATED_PROP (type) != NULL)
897 + TYPE_ASSOCIATED_PROP (new_type) = xmalloc (sizeof (struct dynamic_prop));
898 + *TYPE_ASSOCIATED_PROP (new_type) = *TYPE_ASSOCIATED_PROP (type);
901 /* Copy pointers to other types. */
902 if (TYPE_TARGET_TYPE (type))
903 TYPE_TARGET_TYPE (new_type) =
904 @@ -4227,6 +4348,44 @@ copy_type (const struct type *type)
905 sizeof (struct dynamic_prop));
908 + if (TYPE_ALLOCATED_PROP (type))
910 + TYPE_ALLOCATED_PROP (new_type)
911 + = OBSTACK_ZALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
912 + struct dynamic_prop);
913 + memcpy (TYPE_ALLOCATED_PROP (new_type), TYPE_ALLOCATED_PROP (type),
914 + sizeof (struct dynamic_prop));
917 + if (TYPE_ASSOCIATED_PROP (type))
919 + TYPE_ASSOCIATED_PROP (new_type)
920 + = OBSTACK_ZALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
921 + struct dynamic_prop);
922 + memcpy (TYPE_ASSOCIATED_PROP (new_type), TYPE_ASSOCIATED_PROP (type),
923 + sizeof (struct dynamic_prop));
926 + if (TYPE_DATA_LOCATION (type))
928 + TYPE_DATA_LOCATION (new_type)
929 + = OBSTACK_ZALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
930 + struct dynamic_prop);
931 + memcpy (TYPE_DATA_LOCATION (new_type), TYPE_DATA_LOCATION (type),
932 + sizeof (struct dynamic_prop));
935 + if (TYPE_NFIELDS (type))
937 + int nfields = TYPE_NFIELDS (type);
939 + TYPE_FIELDS (new_type)
940 + = OBSTACK_CALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
941 + nfields, struct field);
942 + memcpy (TYPE_FIELDS (new_type), TYPE_FIELDS (type),
943 + nfields * sizeof (struct field));
949 Index: gdb-7.8.90.20150126/gdb/gdbtypes.h
950 ===================================================================
951 --- gdb-7.8.90.20150126.orig/gdb/gdbtypes.h 2015-01-26 07:47:25.852758401 +0100
952 +++ gdb-7.8.90.20150126/gdb/gdbtypes.h 2015-01-26 07:47:42.405829908 +0100
953 @@ -660,6 +660,10 @@ struct main_type
955 struct dynamic_prop high;
957 + /* * Stride of range. */
959 + struct dynamic_prop stride;
961 /* True if HIGH range bound contains the number of elements in the
962 subrange. This affects how the final hight bound is computed. */
964 @@ -720,6 +724,18 @@ struct main_type
965 this field yields to the location of the data for an object. */
967 struct dynamic_prop *data_location;
969 + /* Structure for DW_AT_allocated.
970 + The presence of this attribute indicates that the object of the type
971 + can be allocated/deallocated. The value can be a dwarf expression,
972 + reference, or a constant. */
973 + struct dynamic_prop *allocated;
975 + /* Structure for DW_AT_associated.
976 + The presence of this attribute indicated that the object of the type
977 + can be associated. The value can be a dwarf expression,
978 + reference, or a constant. */
979 + struct dynamic_prop *associated;
982 /* * A ``struct type'' describes a particular instance of a type, with
983 @@ -1198,6 +1214,39 @@ extern void allocate_gnat_aux_type (stru
984 TYPE_RANGE_DATA(range_type)->high.kind
985 #define TYPE_LOW_BOUND_KIND(range_type) \
986 TYPE_RANGE_DATA(range_type)->low.kind
987 +#define TYPE_BYTE_STRIDE(range_type) \
988 + TYPE_RANGE_DATA(range_type)->stride.data.const_val
989 +#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
990 + TYPE_RANGE_DATA(range_type)->stride.data.locexpr
991 +#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \
992 + TYPE_RANGE_DATA(range_type)->stride.data.loclist
993 +#define TYPE_BYTE_STRIDE_KIND(range_type) \
994 + TYPE_RANGE_DATA(range_type)->stride.kind
997 +/* Attribute accessors for the type data location. */
998 +#define TYPE_DATA_LOCATION(thistype) \
999 + TYPE_MAIN_TYPE(thistype)->data_location
1000 +#define TYPE_DATA_LOCATION_BATON(thistype) \
1001 + TYPE_DATA_LOCATION (thistype)->data.baton
1002 +#define TYPE_DATA_LOCATION_ADDR(thistype) \
1003 + TYPE_DATA_LOCATION (thistype)->data.const_val
1004 +#define TYPE_DATA_LOCATION_KIND(thistype) \
1005 + TYPE_DATA_LOCATION (thistype)->kind
1006 +#define TYPE_ALLOCATED_PROP(thistype) TYPE_MAIN_TYPE(thistype)->allocated
1007 +#define TYPE_ASSOCIATED_PROP(thistype) TYPE_MAIN_TYPE(thistype)->associated
1009 +/* Allocated status of type object. If set to non-zero it means the object
1010 + is allocated. A zero value means it is not allocated. */
1011 +#define TYPE_NOT_ALLOCATED(t) (TYPE_ALLOCATED_PROP (t) \
1012 + && TYPE_ALLOCATED_PROP (t)->kind == PROP_CONST \
1013 + && !TYPE_ALLOCATED_PROP (t)->data.const_val)
1015 +/* Associated status of type object. If set to non-zero it means the object
1016 + is associated. A zero value means it is not associated. */
1017 +#define TYPE_NOT_ASSOCIATED(t) (TYPE_ASSOCIATED_PROP (t) \
1018 + && TYPE_ASSOCIATED_PROP (t)->kind == PROP_CONST \
1019 + && !TYPE_ASSOCIATED_PROP (t)->data.const_val)
1021 /* Attribute accessors for the type data location. */
1022 #define TYPE_DATA_LOCATION(thistype) \
1023 @@ -1215,6 +1264,9 @@ extern void allocate_gnat_aux_type (stru
1024 TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
1025 #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
1026 TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
1027 +#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \
1028 + (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0)
1031 #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
1032 (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
1033 @@ -1685,6 +1737,7 @@ extern struct type *create_array_type_wi
1035 extern struct type *create_range_type (struct type *, struct type *,
1036 const struct dynamic_prop *,
1037 + const struct dynamic_prop *,
1038 const struct dynamic_prop *);
1040 extern struct type *create_array_type (struct type *, struct type *,
1041 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
1042 ===================================================================
1043 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1044 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp 2015-01-26 07:47:42.405829908 +0100
1046 +# Copyright 2014 Free Software Foundation, Inc.
1048 +# This program is free software; you can redistribute it and/or modify
1049 +# it under the terms of the GNU General Public License as published by
1050 +# the Free Software Foundation; either version 3 of the License, or
1051 +# (at your option) any later version.
1053 +# This program is distributed in the hope that it will be useful,
1054 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1055 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1056 +# GNU General Public License for more details.
1058 +# You should have received a copy of the GNU General Public License
1059 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1061 +standard_testfile "vla.f90"
1063 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1064 + {debug f90 quiet}] } {
1068 +if ![runto MAIN__] then {
1069 + perror "couldn't run to breakpoint MAIN__"
1073 +# Check the association status of various types of VLA's
1074 +# and pointer to VLA's.
1075 +gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
1076 +gdb_continue_to_breakpoint "vla1-allocated"
1077 +gdb_test "print l" " = \\.TRUE\\." \
1078 + "print vla1 allocation status (allocated)"
1080 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
1081 +gdb_continue_to_breakpoint "vla2-allocated"
1082 +gdb_test "print l" " = \\.TRUE\\." \
1083 + "print vla2 allocation status (allocated)"
1085 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
1086 +gdb_continue_to_breakpoint "pvla-associated"
1087 +gdb_test "print l" " = \\.TRUE\\." \
1088 + "print pvla associated status (associated)"
1090 +gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
1091 +gdb_continue_to_breakpoint "pvla-re-associated"
1092 +gdb_test "print l" " = \\.TRUE\\." \
1093 + "print pvla associated status (re-associated)"
1095 +gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
1096 +gdb_continue_to_breakpoint "pvla-deassociated"
1097 +gdb_test "print l" " = \\.FALSE\\." \
1098 + "print pvla allocation status (deassociated)"
1100 +gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
1101 +gdb_continue_to_breakpoint "vla1-deallocated"
1102 +gdb_test "print l" " = \\.FALSE\\." \
1103 + "print vla1 allocation status (deallocated)"
1104 +gdb_test "print vla1" " = <not allocated>" \
1105 + "print deallocated vla1"
1107 +gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
1108 +gdb_continue_to_breakpoint "vla2-deallocated"
1109 +gdb_test "print l" " = \\.FALSE\\." "print vla2 deallocated"
1110 +gdb_test "print vla2" " = <not allocated>" "print deallocated vla2"
1111 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-datatypes.exp
1112 ===================================================================
1113 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1114 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-datatypes.exp 2015-01-26 07:47:42.405829908 +0100
1116 +# Copyright 2014 Free Software Foundation, Inc.
1118 +# This program is free software; you can redistribute it and/or modify
1119 +# it under the terms of the GNU General Public License as published by
1120 +# the Free Software Foundation; either version 3 of the License, or
1121 +# (at your option) any later version.
1123 +# This program is distributed in the hope that it will be useful,
1124 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1125 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1126 +# GNU General Public License for more details.
1128 +# You should have received a copy of the GNU General Public License
1129 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1131 +standard_testfile ".f90"
1133 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1134 + {debug f90 quiet}] } {
1138 +# check that all fortran standard datatypes will be
1139 +# handled correctly when using as VLA's
1141 +if ![runto MAIN__] then {
1142 + perror "couldn't run to breakpoint MAIN__"
1146 +gdb_breakpoint [gdb_get_line_number "vlas-allocated"]
1147 +gdb_continue_to_breakpoint "vlas-allocated"
1148 +gdb_test "next" " = allocated\\\(realvla\\\)" \
1149 + "next to allocation status of intvla"
1150 +gdb_test "print l" " = \\.TRUE\\." "intvla allocated"
1151 +gdb_test "next" " = allocated\\\(complexvla\\\)" \
1152 + "next to allocation status of realvla"
1153 +gdb_test "print l" " = \\.TRUE\\." "realvla allocated"
1154 +gdb_test "next" " = allocated\\\(logicalvla\\\)" \
1155 + "next to allocation status of complexvla"
1156 +gdb_test "print l" " = \\.TRUE\\." "complexvla allocated"
1157 +gdb_test "next" " = allocated\\\(charactervla\\\)" \
1158 + "next to allocation status of logicalvla"
1159 +gdb_test "print l" " = \\.TRUE\\." "logicalvla allocated"
1160 +gdb_test "next" "intvla\\\(:,:,:\\\) = 1" \
1161 + "next to allocation status of charactervla"
1162 +gdb_test "print l" " = \\.TRUE\\." "charactervla allocated"
1164 +gdb_breakpoint [gdb_get_line_number "vlas-initialized"]
1165 +gdb_continue_to_breakpoint "vlas-initialized"
1166 +gdb_test "ptype intvla" "type = integer\\\(kind=4\\\) \\\(11,22,33\\\)" \
1168 +gdb_test "ptype realvla" "type = real\\\(kind=4\\\) \\\(11,22,33\\\)" \
1170 +gdb_test "ptype complexvla" "type = complex\\\(kind=4\\\) \\\(11,22,33\\\)" \
1171 + "ptype complexvla"
1172 +gdb_test "ptype logicalvla" "type = logical\\\(kind=4\\\) \\\(11,22,33\\\)" \
1173 + "ptype logicalvla"
1174 +gdb_test "ptype charactervla" "type = character\\\*1 \\\(11,22,33\\\)" \
1175 + "ptype charactervla"
1177 +gdb_test "print intvla(5,5,5)" " = 1" "print intvla(5,5,5) (1st)"
1178 +gdb_test "print realvla(5,5,5)" " = 3.14\\d+" \
1179 + "print realvla(5,5,5) (1st)"
1180 +gdb_test "print complexvla(5,5,5)" " = \\\(2,-3\\\)" \
1181 + "print complexvla(5,5,5) (1st)"
1182 +gdb_test "print logicalvla(5,5,5)" " = \\.TRUE\\." \
1183 + "print logicalvla(5,5,5) (1st)"
1184 +gdb_test "print charactervla(5,5,5)" " = 'K'" \
1185 + "print charactervla(5,5,5) (1st)"
1187 +gdb_breakpoint [gdb_get_line_number "vlas-modified"]
1188 +gdb_continue_to_breakpoint "vlas-modified"
1189 +gdb_test "print intvla(5,5,5)" " = 42" "print intvla(5,5,5) (2nd)"
1190 +gdb_test "print realvla(5,5,5)" " = 4.13\\d+" \
1191 + "print realvla(5,5,5) (2nd)"
1192 +gdb_test "print complexvla(5,5,5)" " = \\\(-3,2\\\)" \
1193 + "print complexvla(5,5,5) (2nd)"
1194 +gdb_test "print logicalvla(5,5,5)" " = \\.FALSE\\." \
1195 + "print logicalvla(5,5,5) (2nd)"
1196 +gdb_test "print charactervla(5,5,5)" " = 'X'" \
1197 + "print charactervla(5,5,5) (2nd)"
1198 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-datatypes.f90
1199 ===================================================================
1200 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1201 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-datatypes.f90 2015-01-26 07:47:42.405829908 +0100
1203 +! Copyright 2014 Free Software Foundation, Inc.
1205 +! This program is free software; you can redistribute it and/or modify
1206 +! it under the terms of the GNU General Public License as published by
1207 +! the Free Software Foundation; either version 2 of the License, or
1208 +! (at your option) any later version.
1210 +! This program is distributed in the hope that it will be useful,
1211 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1213 +! GNU General Public License for more details.
1215 +! You should have received a copy of the GNU General Public License
1216 +! along with this program; if not, write to the Free Software
1217 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1219 +program vla_primitives
1220 + integer, allocatable :: intvla(:, :, :)
1221 + real, allocatable :: realvla(:, :, :)
1222 + complex, allocatable :: complexvla(:, :, :)
1223 + logical, allocatable :: logicalvla(:, :, :)
1224 + character, allocatable :: charactervla(:, :, :)
1227 + allocate (intvla (11,22,33))
1228 + allocate (realvla (11,22,33))
1229 + allocate (complexvla (11,22,33))
1230 + allocate (logicalvla (11,22,33))
1231 + allocate (charactervla (11,22,33))
1233 + l = allocated(intvla) ! vlas-allocated
1234 + l = allocated(realvla)
1235 + l = allocated(complexvla)
1236 + l = allocated(logicalvla)
1237 + l = allocated(charactervla)
1240 + realvla(:,:,:) = 3.14
1241 + complexvla(:,:,:) = cmplx(2.0,-3.0)
1242 + logicalvla(:,:,:) = .TRUE.
1243 + charactervla(:,:,:) = char(75)
1245 + intvla(5,5,5) = 42 ! vlas-initialized
1246 + realvla(5,5,5) = 4.13
1247 + complexvla(5,5,5) = cmplx(-3.0,2.0)
1248 + logicalvla(5,5,5) = .FALSE.
1249 + charactervla(5,5,5) = 'X'
1251 + ! dummy statement for bp
1252 + l = .FALSE. ! vlas-modified
1253 +end program vla_primitives
1254 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-func.exp
1255 ===================================================================
1256 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1257 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-func.exp 2015-01-26 07:47:42.406829913 +0100
1259 +# Copyright 2014 Free Software Foundation, Inc.
1261 +# This program is free software; you can redistribute it and/or modify
1262 +# it under the terms of the GNU General Public License as published by
1263 +# the Free Software Foundation; either version 3 of the License, or
1264 +# (at your option) any later version.
1266 +# This program is distributed in the hope that it will be useful,
1267 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1268 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1269 +# GNU General Public License for more details.
1271 +# You should have received a copy of the GNU General Public License
1272 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1274 +standard_testfile ".f90"
1276 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1277 + {debug f90 quiet}] } {
1281 +if ![runto MAIN__] then {
1282 + perror "couldn't run to breakpoint MAIN__"
1286 +# Check VLA passed to first Fortran function.
1287 +gdb_breakpoint [gdb_get_line_number "func1-vla-passed"]
1288 +gdb_continue_to_breakpoint "func1-vla-passed"
1289 +gdb_test "print vla" " = \\( *\\( *22, *22, *22,\[()22, .\]*\\)" \
1290 + "print vla (func1)"
1291 +gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10,10\\\)" \
1292 + "ptype vla (func1)"
1294 +gdb_breakpoint [gdb_get_line_number "func1-vla-modified"]
1295 +gdb_continue_to_breakpoint "func1-vla-modified"
1296 +gdb_test "print vla(5,5)" " = 55" "print vla(5,5) (func1)"
1297 +gdb_test "print vla(7,7)" " = 77" "print vla(5,5) (func1)"
1299 +# Check if the values are correct after returning from func1
1300 +gdb_breakpoint [gdb_get_line_number "func1-returned"]
1301 +gdb_continue_to_breakpoint "func1-returned"
1302 +gdb_test "print ret" " = .TRUE." "print ret after func1 returned"
1304 +# Check VLA passed to second Fortran function
1305 +gdb_breakpoint [gdb_get_line_number "func2-vla-passed"]
1306 +gdb_continue_to_breakpoint "func2-vla-passed"
1307 +gdb_test "print vla" \
1308 + " = \\\(44, 44, 44, 44, 44, 44, 44, 44, 44, 44\\\)" \
1309 + "print vla (func2)"
1310 +gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
1311 + "ptype vla (func2)"
1313 +# Check if the returned VLA has the correct values and ptype.
1314 +gdb_breakpoint [gdb_get_line_number "func2-returned"]
1315 +gdb_continue_to_breakpoint "func2-returned"
1316 +gdb_test "print vla3" " = \\\(1, 2, 44, 4, 44, 44, 44, 8, 44, 44\\\)" \
1317 + "print vla3 (after func2)"
1318 +gdb_test "ptype vla3" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
1319 + "ptype vla3 (after func2)"
1320 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-func.f90
1321 ===================================================================
1322 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1323 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-func.f90 2015-01-26 07:47:42.406829913 +0100
1325 +! Copyright 2014 Free Software Foundation, Inc.
1327 +! This program is free software; you can redistribute it and/or modify
1328 +! it under the terms of the GNU General Public License as published by
1329 +! the Free Software Foundation; either version 2 of the License, or
1330 +! (at your option) any later version.
1332 +! This program is distributed in the hope that it will be useful,
1333 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1334 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1335 +! GNU General Public License for more details.
1337 +! You should have received a copy of the GNU General Public License
1338 +! along with this program; if not, write to the Free Software
1339 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1341 +logical function func1 (vla)
1343 + integer, allocatable :: vla (:, :)
1344 + func1 = allocated(vla)
1345 + vla(5,5) = 55 ! func1-vla-passed
1347 + return ! func1-vla-modified
1350 +function func2(vla)
1352 + integer :: vla (:)
1353 + integer :: func2(size(vla))
1356 + vla(1) = 1 ! func2-vla-passed
1367 + logical function func1 (vla)
1368 + integer :: vla (:, :)
1372 + function func2 (vla)
1373 + integer :: vla (:)
1374 + integer func2(size(vla))
1379 + integer, allocatable :: vla1 (:, :)
1380 + integer, allocatable :: vla2 (:)
1381 + integer, allocatable :: vla3 (:)
1385 + allocate (vla1 (10,10))
1388 + allocate (vla2 (10))
1392 + vla3 = func2(vla2) ! func1-returned
1394 + ret = .TRUE. ! func2-returned
1395 +end program vla_func
1396 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-history.exp
1397 ===================================================================
1398 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1399 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-history.exp 2015-01-26 07:47:42.406829913 +0100
1401 +# Copyright 2014 Free Software Foundation, Inc.
1403 +# This program is free software; you can redistribute it and/or modify
1404 +# it under the terms of the GNU General Public License as published by
1405 +# the Free Software Foundation; either version 3 of the License, or
1406 +# (at your option) any later version.
1408 +# This program is distributed in the hope that it will be useful,
1409 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1410 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1411 +# GNU General Public License for more details.
1413 +# You should have received a copy of the GNU General Public License
1414 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1416 +standard_testfile "vla.f90"
1418 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1419 + {debug f90 quiet}] } {
1423 +if ![runto MAIN__] then {
1424 + perror "couldn't run to breakpoint MAIN__"
1428 +# Set some breakpoints and print complete vla.
1429 +gdb_breakpoint [gdb_get_line_number "vla1-init"]
1430 +gdb_continue_to_breakpoint "vla1-init"
1431 +gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
1433 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
1434 +gdb_continue_to_breakpoint "vla2-allocated"
1435 +gdb_test "print vla1" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
1436 + "print vla1 allocated"
1437 +gdb_test "print vla2" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
1438 + "print vla2 allocated"
1440 +gdb_breakpoint [gdb_get_line_number "vla1-filled"]
1441 +gdb_continue_to_breakpoint "vla1-filled"
1442 +gdb_test "print vla1" \
1443 + " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" \
1444 + "print vla1 filled"
1446 +# Try to access history values for full vla prints.
1447 +gdb_test "print \$1" " = <not allocated>" "print \$1"
1448 +gdb_test "print \$2" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
1450 +gdb_test "print \$3" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
1452 +gdb_test "print \$4" \
1453 + " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" "print \$4"
1455 +gdb_breakpoint [gdb_get_line_number "vla2-filled"]
1456 +gdb_continue_to_breakpoint "vla2-filled"
1457 +gdb_test "print vla2(1,43,20)" " = 1311" "print vla2(1,43,20)"
1458 +gdb_test "print vla1(1,3,8)" " = 1001" "print vla2(1,3,8)"
1460 +# Try to access history values for vla values.
1461 +gdb_test "print \$9" " = 1311" "print \$9"
1462 +gdb_test "print \$10" " = 1001" "print \$10"
1463 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
1464 ===================================================================
1465 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1466 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp 2015-01-26 07:47:42.406829913 +0100
1468 +# Copyright 2014 Free Software Foundation, Inc.
1470 +# This program is free software; you can redistribute it and/or modify
1471 +# it under the terms of the GNU General Public License as published by
1472 +# the Free Software Foundation; either version 3 of the License, or
1473 +# (at your option) any later version.
1475 +# This program is distributed in the hope that it will be useful,
1476 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1477 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1478 +# GNU General Public License for more details.
1480 +# You should have received a copy of the GNU General Public License
1481 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1483 +standard_testfile "vla-sub.f90"
1485 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1486 + {debug f90 quiet}] } {
1490 +if ![runto MAIN__] then {
1491 + perror "couldn't run to breakpoint MAIN__"
1495 +# Pass fixed array to function and handle them as vla in function.
1496 +gdb_breakpoint [gdb_get_line_number "not-filled"]
1497 +gdb_continue_to_breakpoint "not-filled (1st)"
1498 +gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(42,42\\\)" \
1499 + "ptype array1 (passed fixed)"
1500 +gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(42,42,42\\\)" \
1501 + "ptype array2 (passed fixed)"
1502 +gdb_test "ptype array1(40, 10)" "type = integer\\\(kind=4\\\)" \
1503 + "ptype array1(40, 10) (passed fixed)"
1504 +gdb_test "ptype array2(13, 11, 5)" "type = real\\\(kind=4\\\)" \
1505 + "ptype array2(13, 11, 5) (passed fixed)"
1507 +# Pass sub arrays to function and handle them as vla in function.
1508 +gdb_continue_to_breakpoint "not-filled (2nd)"
1509 +gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(6,6\\\)" \
1510 + "ptype array1 (passed sub-array)"
1511 +gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(6,6,6\\\)" \
1512 + "ptype array2 (passed sub-array)"
1513 +gdb_test "ptype array1(3, 3)" "type = integer\\\(kind=4\\\)" \
1514 + "ptype array1(3, 3) (passed sub-array)"
1515 +gdb_test "ptype array2(4, 4, 4)" "type = real\\\(kind=4\\\)" \
1516 + "ptype array2(4, 4, 4) (passed sub-array)"
1518 +# Check ptype outside of bounds. This should not crash GDB.
1519 +gdb_test "ptype array1(100, 100)" "no such vector element" \
1520 + "ptype array1(100, 100) subarray do not crash (passed sub-array)"
1521 +gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
1522 + "ptype array2(100, 100, 100) subarray do not crash (passed sub-array)"
1524 +# Pass vla to function.
1525 +gdb_continue_to_breakpoint "not-filled (3rd)"
1526 +gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(20,20\\\)" \
1527 + "ptype array1 (passed vla)"
1528 +gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
1529 + "ptype array2 (passed vla)"
1530 +gdb_test "ptype array1(3, 3)" "type = integer\\\(kind=4\\\)" \
1531 + "ptype array1(3, 3) (passed vla)"
1532 +gdb_test "ptype array2(4, 4, 4)" "type = real\\\(kind=4\\\)" \
1533 + "ptype array2(4, 4, 4) (passed vla)"
1535 +# Check ptype outside of bounds. This should not crash GDB.
1536 +gdb_test "ptype array1(100, 100)" "no such vector element" \
1537 + "ptype array1(100, 100) VLA do not crash (passed vla)"
1538 +gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
1539 + "ptype array2(100, 100, 100) VLA do not crash (passed vla)"
1541 +# Pass fixed array to function and handle it as VLA of arbitrary length in
1543 +gdb_breakpoint [gdb_get_line_number "end-of-bar"]
1544 +gdb_continue_to_breakpoint "end-of-bar"
1545 +gdb_test "ptype array1" \
1546 + "type = (PTR TO -> \\( )?integer(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" \
1547 + "ptype array1 (arbitrary length)"
1548 +gdb_test "ptype array2" \
1549 + "type = (PTR TO -> \\( )?integer(\\(kind=4\\)|\\*4) \\(4:9,10:\\*\\)\\)?" \
1550 + "ptype array2 (arbitrary length)"
1551 +gdb_test "ptype array1(100)" "type = integer\\\(kind=4\\\)" \
1552 + "ptype array1(100) (arbitrary length)"
1553 +gdb_test "ptype array2(4,100)" "type = integer\\\(kind=4\\\)" \
1554 + "ptype array2(4,100) (arbitrary length)"
1555 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-ptype.exp
1556 ===================================================================
1557 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1558 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-ptype.exp 2015-01-26 07:47:42.406829913 +0100
1560 +# Copyright 2014 Free Software Foundation, Inc.
1562 +# This program is free software; you can redistribute it and/or modify
1563 +# it under the terms of the GNU General Public License as published by
1564 +# the Free Software Foundation; either version 3 of the License, or
1565 +# (at your option) any later version.
1567 +# This program is distributed in the hope that it will be useful,
1568 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1569 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1570 +# GNU General Public License for more details.
1572 +# You should have received a copy of the GNU General Public License
1573 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1575 +standard_testfile "vla.f90"
1577 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1578 + {debug f90 quiet}] } {
1582 +if ![runto MAIN__] then {
1583 + perror "couldn't run to breakpoint MAIN__"
1587 +# Check the ptype of various VLA states and pointer to VLA's.
1588 +gdb_breakpoint [gdb_get_line_number "vla1-init"]
1589 +gdb_continue_to_breakpoint "vla1-init"
1590 +gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not initialized"
1591 +gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not initialized"
1592 +gdb_test "ptype pvla" "type = <not associated>" "ptype pvla not initialized"
1593 +gdb_test "ptype vla1(3, 6, 9)" "no such vector element because not allocated" \
1594 + "ptype vla1(3, 6, 9) not initialized"
1595 +gdb_test "ptype vla2(5, 45, 20)" \
1596 + "no such vector element because not allocated" \
1597 + "ptype vla1(5, 45, 20) not initialized"
1599 +gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
1600 +gdb_continue_to_breakpoint "vla1-allocated"
1601 +gdb_test "ptype vla1" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
1602 + "ptype vla1 allocated"
1604 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
1605 +gdb_continue_to_breakpoint "vla2-allocated"
1606 +gdb_test "ptype vla2" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
1607 + "ptype vla2 allocated"
1609 +gdb_breakpoint [gdb_get_line_number "vla1-filled"]
1610 +gdb_continue_to_breakpoint "vla1-filled"
1611 +gdb_test "ptype vla1" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
1612 + "ptype vla1 filled"
1613 +gdb_test "ptype vla1(3, 6, 9)" "type = real\\\(kind=4\\\)" \
1614 + "ptype vla1(3, 6, 9)"
1616 +gdb_breakpoint [gdb_get_line_number "vla2-filled"]
1617 +gdb_continue_to_breakpoint "vla2-filled"
1618 +gdb_test "ptype vla2" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
1619 + "ptype vla2 filled"
1620 +gdb_test "ptype vla2(5, 45, 20)" "type = real\\\(kind=4\\\)" \
1621 + "ptype vla1(5, 45, 20) filled"
1623 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
1624 +gdb_continue_to_breakpoint "pvla-associated"
1625 +gdb_test "ptype pvla" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
1626 + "ptype pvla associated"
1627 +gdb_test "ptype pvla(3, 6, 9)" "type = real\\\(kind=4\\\)" \
1628 + "ptype pvla(3, 6, 9)"
1630 +gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
1631 +gdb_continue_to_breakpoint "pvla-re-associated"
1632 +gdb_test "ptype pvla" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
1633 + "ptype pvla re-associated"
1634 +gdb_test "ptype vla2(5, 45, 20)" "type = real\\\(kind=4\\\)" \
1635 + "ptype vla1(5, 45, 20) re-associated"
1637 +gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
1638 +gdb_continue_to_breakpoint "pvla-deassociated"
1639 +gdb_test "ptype pvla" "type = <not associated>" "ptype pvla deassociated"
1640 +gdb_test "ptype pvla(5, 45, 20)" \
1641 + "no such vector element because not associated" \
1642 + "ptype pvla(5, 45, 20) not associated"
1644 +gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
1645 +gdb_continue_to_breakpoint "vla1-deallocated"
1646 +gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not allocated"
1647 +gdb_test "ptype vla1(3, 6, 9)" "no such vector element because not allocated" \
1648 + "ptype vla1(3, 6, 9) not allocated"
1650 +gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
1651 +gdb_continue_to_breakpoint "vla2-deallocated"
1652 +gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not allocated"
1653 +gdb_test "ptype vla2(5, 45, 20)" \
1654 + "no such vector element because not allocated" \
1655 + "ptype vla2(5, 45, 20) not allocated"
1656 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-sizeof.exp
1657 ===================================================================
1658 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1659 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-sizeof.exp 2015-01-26 07:47:42.406829913 +0100
1661 +# Copyright 2014 Free Software Foundation, Inc.
1663 +# This program is free software; you can redistribute it and/or modify
1664 +# it under the terms of the GNU General Public License as published by
1665 +# the Free Software Foundation; either version 3 of the License, or
1666 +# (at your option) any later version.
1668 +# This program is distributed in the hope that it will be useful,
1669 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1670 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1671 +# GNU General Public License for more details.
1673 +# You should have received a copy of the GNU General Public License
1674 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1676 +standard_testfile "vla.f90"
1678 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1679 + {debug f90 quiet}] } {
1683 +if ![runto MAIN__] then {
1684 + perror "couldn't run to breakpoint MAIN__"
1688 +# Try to access values in non allocated VLA
1689 +gdb_breakpoint [gdb_get_line_number "vla1-init"]
1690 +gdb_continue_to_breakpoint "vla1-init"
1691 +gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1"
1693 +# Try to access value in allocated VLA
1694 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
1695 +gdb_continue_to_breakpoint "vla2-allocated"
1696 +gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1"
1698 +# Try to access values in undefined pointer to VLA (dangling)
1699 +gdb_breakpoint [gdb_get_line_number "vla1-filled"]
1700 +gdb_continue_to_breakpoint "vla1-filled"
1701 +gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
1703 +# Try to access values in pointer to VLA and compare them
1704 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
1705 +gdb_continue_to_breakpoint "pvla-associated"
1706 +gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
1707 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-stride.exp
1708 ===================================================================
1709 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1710 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-stride.exp 2015-01-26 07:47:42.407829917 +0100
1712 +# Copyright 2014 Free Software Foundation, Inc.
1714 +# This program is free software; you can redistribute it and/or modify
1715 +# it under the terms of the GNU General Public License as published by
1716 +# the Free Software Foundation; either version 3 of the License, or
1717 +# (at your option) any later version.
1719 +# This program is distributed in the hope that it will be useful,
1720 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1721 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1722 +# GNU General Public License for more details.
1724 +# You should have received a copy of the GNU General Public License
1725 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1727 +standard_testfile ".f90"
1729 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1730 + {debug f90 quiet}] } {
1734 +if ![runto MAIN__] then {
1735 + perror "couldn't run to breakpoint MAIN__"
1739 +gdb_breakpoint [gdb_get_line_number "re-reverse-elements"]
1740 +gdb_continue_to_breakpoint "re-reverse-elements"
1741 +gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \
1742 + "print re-reverse-elements"
1743 +gdb_test "print pvla(1)" " = 1" "print first re-reverse-element"
1744 +gdb_test "print pvla(10)" " = 10" "print last re-reverse-element"
1746 +gdb_breakpoint [gdb_get_line_number "odd-elements"]
1747 +gdb_continue_to_breakpoint "odd-elements"
1748 +gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements"
1749 +gdb_test "print pvla(1)" " = 1" "print first odd-element"
1750 +gdb_test "print pvla(5)" " = 9" "print last odd-element"
1752 +gdb_breakpoint [gdb_get_line_number "single-element"]
1753 +gdb_continue_to_breakpoint "single-element"
1754 +gdb_test "print pvla" " = \\\(5\\\)" "print single-element"
1755 +gdb_test "print pvla(1)" " = 5" "print one single-element"
1756 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-stride.f90
1757 ===================================================================
1758 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1759 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-stride.f90 2015-01-26 07:47:42.407829917 +0100
1761 +! Copyright 2014 Free Software Foundation, Inc.
1763 +! This program is free software; you can redistribute it and/or modify
1764 +! it under the terms of the GNU General Public License as published by
1765 +! the Free Software Foundation; either version 2 of the License, or
1766 +! (at your option) any later version.
1768 +! This program is distributed in the hope that it will be useful,
1769 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1770 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1771 +! GNU General Public License for more details.
1773 +! You should have received a copy of the GNU General Public License
1774 +! along with this program; if not, write to the Free Software
1775 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1778 + integer, target, allocatable :: vla (:)
1779 + integer, pointer :: pvla (:)
1782 + vla = (/ (I, I = 1,10) /)
1784 + pvla => vla(10:1:-1)
1785 + pvla => pvla(10:1:-1)
1786 + pvla => vla(1:10:2) ! re-reverse-elements
1787 + pvla => vla(5:4:-2) ! odd-elements
1789 + pvla => null() ! single-element
1790 +end program vla_stride
1791 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-strings.exp
1792 ===================================================================
1793 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1794 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-strings.exp 2015-01-26 07:47:42.407829917 +0100
1796 +# Copyright 2014 Free Software Foundation, Inc.
1798 +# This program is free software; you can redistribute it and/or modify
1799 +# it under the terms of the GNU General Public License as published by
1800 +# the Free Software Foundation; either version 3 of the License, or
1801 +# (at your option) any later version.
1803 +# This program is distributed in the hope that it will be useful,
1804 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1805 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1806 +# GNU General Public License for more details.
1808 +# You should have received a copy of the GNU General Public License
1809 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1811 +standard_testfile ".f90"
1813 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1814 + {debug f90 quiet}] } {
1818 +# check that all fortran standard datatypes will be
1819 +# handled correctly when using as VLA's
1821 +if ![runto MAIN__] then {
1822 + perror "couldn't run to breakpoint MAIN__"
1826 +gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
1827 +gdb_continue_to_breakpoint "var_char-allocated-1"
1828 +gdb_test "print var_char" \
1829 + " = \\(PTR TO -> \\( character\\*10 \\)\\) ${hex}" \
1830 + "print var_char after allocated first time"
1831 +gdb_test "print *var_char" \
1832 + " = '\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000'" \
1833 + "print *var_char after allocated first time"
1834 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*10 \\)" \
1835 + "whatis var_char first time"
1836 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*10 \\)" \
1837 + "ptype var_char first time"
1838 +gdb_test "next" "\\d+.*var_char = 'foo'.*" \
1839 + "next to allocation status of var_char"
1840 +gdb_test "print l" " = .TRUE." "print allocation status first time"
1842 +gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
1843 +gdb_continue_to_breakpoint "var_char-filled-1"
1844 +gdb_test "print var_char" \
1845 + " = \\(PTR TO -> \\( character\\*3 \\)\\) ${hex}" \
1846 + "print var_char after filled first time"
1847 +gdb_test "print *var_char" " = 'foo'" \
1848 + "print *var_char after filled first time"
1849 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*3 \\)" \
1850 + "whatis var_char after filled first time"
1851 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*3 \\)" \
1852 + "ptype var_char after filled first time"
1853 +gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
1854 +gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
1856 +gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
1857 +gdb_continue_to_breakpoint "var_char-filled-2"
1858 +gdb_test "print var_char" \
1859 + " = \\(PTR TO -> \\( character\\*6 \\)\\) ${hex}" \
1860 + "print var_char after allocated second time"
1861 +gdb_test "print *var_char" " = 'foobar'" \
1862 + "print *var_char after allocated second time"
1863 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*6 \\)" \
1864 + "whatis var_char second time"
1865 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*6 \\)" \
1866 + "ptype var_char second time"
1868 +gdb_breakpoint [gdb_get_line_number "var_char-empty"]
1869 +gdb_continue_to_breakpoint "var_char-empty"
1870 +gdb_test "print var_char" \
1871 + " = \\(PTR TO -> \\( character\\*0 \\)\\) ${hex}" \
1872 + "print var_char after set empty"
1873 +gdb_test "print *var_char" " = \"\"" "print *var_char after set empty"
1874 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*0 \\)" \
1875 + "whatis var_char after set empty"
1876 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*0 \\)" \
1877 + "ptype var_char after set empty"
1879 +gdb_breakpoint [gdb_get_line_number "var_char-allocated-3"]
1880 +gdb_continue_to_breakpoint "var_char-allocated-3"
1881 +gdb_test "print var_char" \
1882 + " = \\(PTR TO -> \\( character\\*21 \\)\\) ${hex}" \
1883 + "print var_char after allocated third time"
1884 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*21 \\)" \
1885 + "whatis var_char after allocated third time"
1886 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*21 \\)" \
1887 + "ptype var_char after allocated third time"
1889 +gdb_breakpoint [gdb_get_line_number "var_char_p-associated"]
1890 +gdb_continue_to_breakpoint "var_char_p-associated"
1891 +gdb_test "print var_char_p" \
1892 + " = \\(PTR TO -> \\( character\\*7 \\)\\) ${hex}" \
1893 + "print var_char_p after associated"
1894 +gdb_test "print *var_char_p" " = 'johndoe'" \
1895 + "print *var_char_ after associated"
1896 +gdb_test "whatis var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
1897 + "whatis var_char_p after associated"
1898 +gdb_test "ptype var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
1899 + "ptype var_char_p after associated"
1900 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-strings.f90
1901 ===================================================================
1902 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1903 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-strings.f90 2015-01-26 07:47:42.407829917 +0100
1905 +! Copyright 2014 Free Software Foundation, Inc.
1907 +! This program is free software; you can redistribute it and/or modify
1908 +! it under the terms of the GNU General Public License as published by
1909 +! the Free Software Foundation; either version 2 of the License, or
1910 +! (at your option) any later version.
1912 +! This program is distributed in the hope that it will be useful,
1913 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1914 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1915 +! GNU General Public License for more details.
1917 +! You should have received a copy of the GNU General Public License
1918 +! along with this program; if not, write to the Free Software
1919 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1921 +program vla_strings
1922 + character(len=:), target, allocatable :: var_char
1923 + character(len=:), pointer :: var_char_p
1926 + allocate(character(len=10) :: var_char)
1927 + l = allocated(var_char) ! var_char-allocated-1
1929 + deallocate(var_char) ! var_char-filled-1
1930 + l = allocated(var_char) ! var_char-deallocated
1931 + allocate(character(len=42) :: var_char)
1932 + l = allocated(var_char)
1933 + var_char = 'foobar'
1934 + var_char = '' ! var_char-filled-2
1935 + var_char = 'bar' ! var_char-empty
1936 + deallocate(var_char)
1937 + allocate(character(len=21) :: var_char)
1938 + l = allocated(var_char) ! var_char-allocated-3
1939 + var_char = 'johndoe'
1940 + var_char_p => var_char
1941 + l = associated(var_char_p) ! var_char_p-associated
1942 + var_char_p => null()
1943 + l = associated(var_char_p) ! var_char_p-not-associated
1944 +end program vla_strings
1945 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-sub.f90
1946 ===================================================================
1947 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1948 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-sub.f90 2015-01-26 07:47:42.407829917 +0100
1950 +! Copyright 2014 Free Software Foundation, Inc.
1952 +! This program is free software; you can redistribute it and/or modify
1953 +! it under the terms of the GNU General Public License as published by
1954 +! the Free Software Foundation; either version 2 of the License, or
1955 +! (at your option) any later version.
1957 +! This program is distributed in the hope that it will be useful,
1958 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1959 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1960 +! GNU General Public License for more details.
1962 +! You should have received a copy of the GNU General Public License
1963 +! along with this program; if not, write to the Free Software
1964 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1966 +! Original file written by Jakub Jelinek <jakub@redhat.com> and
1967 +! Jan Kratochvil <jan.kratochvil@redhat.com>.
1968 +! Modified for the GDB testcases by Keven Boell <keven.boell@intel.com>.
1970 +subroutine foo (array1, array2)
1971 + integer :: array1 (:, :)
1972 + real :: array2 (:, :, :)
1974 + array1(:,:) = 5 ! not-filled
1977 + array2(:,:,:) = 6 ! array1-filled
1979 + array2(1,1,1) = 30
1980 + array2(3,3,3) = 90 ! array2-almost-filled
1983 +subroutine bar (array1, array2)
1984 + integer :: array1 (*)
1985 + integer :: array2 (4:9, 10:*)
1987 + array1(5:10) = 1311
1990 + array2(4,10) = array1(7)
1991 + array2(4,100) = array1(7)
1992 + return ! end-of-bar
1997 + subroutine foo (array1, array2)
1998 + integer :: array1 (:, :)
1999 + real :: array2 (:, :, :)
2003 + subroutine bar (array1, array2)
2004 + integer :: array1 (*)
2005 + integer :: array2 (4:9, 10:*)
2009 + real, allocatable :: vla1 (:, :, :)
2010 + integer, allocatable :: vla2 (:, :)
2012 + ! used for subroutine
2013 + integer :: sub_arr1(42, 42)
2014 + real :: sub_arr2(42, 42, 42)
2015 + integer :: sub_arr3(42)
2017 + sub_arr1(:,:) = 1 ! vla2-deallocated
2018 + sub_arr2(:,:,:) = 2
2021 + call foo(sub_arr1, sub_arr2)
2022 + call foo(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))
2024 + allocate (vla1 (10,10,10))
2025 + allocate (vla2 (20,20))
2026 + vla1(:,:,:) = 1311
2028 + call foo(vla2, vla1)
2030 + call bar(sub_arr3, sub_arr1)
2031 +end program vla_sub
2032 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
2033 ===================================================================
2034 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2035 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp 2015-01-26 07:47:42.407829917 +0100
2037 +# Copyright 2014 Free Software Foundation, Inc.
2039 +# This program is free software; you can redistribute it and/or modify
2040 +# it under the terms of the GNU General Public License as published by
2041 +# the Free Software Foundation; either version 3 of the License, or
2042 +# (at your option) any later version.
2044 +# This program is distributed in the hope that it will be useful,
2045 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2046 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2047 +# GNU General Public License for more details.
2049 +# You should have received a copy of the GNU General Public License
2050 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2052 +standard_testfile "vla-sub.f90"
2054 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
2055 + {debug f90 quiet}] } {
2059 +if ![runto MAIN__] then {
2060 + perror "couldn't run to breakpoint MAIN__"
2064 +# Check VLA with arbitary length and check that elements outside of
2065 +# bounds of the passed VLA can be accessed correctly.
2066 +gdb_breakpoint [gdb_get_line_number "end-of-bar"]
2067 +gdb_continue_to_breakpoint "end-of-bar"
2068 +gdb_test "p array1(42)" " = 3" "print arbitary array1(42)"
2069 +gdb_test "p array1(100)" " = 100" "print arbitary array1(100)"
2070 +gdb_test "p array2(4,10)" " = 1" "print arbitary array2(4,10)"
2071 +gdb_test "p array2(4,100)" " = 1" "print arbitary array2(4,100)"
2072 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
2073 ===================================================================
2074 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2075 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp 2015-01-26 07:47:42.407829917 +0100
2077 +# Copyright 2014 Free Software Foundation, Inc.
2079 +# This program is free software; you can redistribute it and/or modify
2080 +# it under the terms of the GNU General Public License as published by
2081 +# the Free Software Foundation; either version 3 of the License, or
2082 +# (at your option) any later version.
2084 +# This program is distributed in the hope that it will be useful,
2085 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2086 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2087 +# GNU General Public License for more details.
2089 +# You should have received a copy of the GNU General Public License
2090 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2092 +standard_testfile "vla-sub.f90"
2094 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
2095 + {debug f90 quiet}] } {
2099 +if ![runto MAIN__] then {
2100 + perror "couldn't run to breakpoint MAIN__"
2104 +# "up" works with GCC but other Fortran compilers may copy the values into the
2105 +# outer function only on the exit of the inner function.
2106 +# We need both variants as depending on the arch we optionally may still be
2107 +# executing the caller line or not after `finish'.
2109 +gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
2110 +gdb_continue_to_breakpoint "array2-almost-filled"
2111 +gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
2112 + "print array2 in foo after it was filled"
2113 +gdb_test "print array2(2,1,1)=20" " = 20" \
2114 + "set array(2,2,2) to 20 in subroutine"
2115 +gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
2116 + "print array2 in foo after it was mofified in debugger"
2118 +gdb_test "finish" \
2119 + ".*foo\\\(sub_arr1\\\(5:10, 5:10\\\), sub_arr2\\\(10:15,10:15,10:15\\\)\\\)" \
2121 +gdb_test "p sub_arr1(5, 7)" " = 5" "sub_arr1(5, 7) after finish"
2122 +gdb_test "p sub_arr1(1, 1)" " = 30" "sub_arr1(1, 1) after finish"
2123 +gdb_test "p sub_arr2(1, 1, 1)" " = 30" "sub_arr2(1, 1, 1) after finish"
2124 +gdb_test "p sub_arr2(2, 1, 1)" " = 20" "sub_arr2(2, 1, 1) after finish"
2126 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-value-sub.exp
2127 ===================================================================
2128 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2129 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-value-sub.exp 2015-01-26 07:47:42.408829922 +0100
2131 +# Copyright 2014 Free Software Foundation, Inc.
2133 +# This program is free software; you can redistribute it and/or modify
2134 +# it under the terms of the GNU General Public License as published by
2135 +# the Free Software Foundation; either version 3 of the License, or
2136 +# (at your option) any later version.
2138 +# This program is distributed in the hope that it will be useful,
2139 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2140 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2141 +# GNU General Public License for more details.
2143 +# You should have received a copy of the GNU General Public License
2144 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2146 +standard_testfile "vla-sub.f90"
2148 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
2149 + {debug f90 quiet}] } {
2153 +if ![runto MAIN__] then {
2154 + perror "couldn't run to breakpoint MAIN__"
2158 +# Check the values of VLA's in subroutine can be evaluated correctly
2160 +# Try to access values from a fixed array handled as VLA in subroutine.
2161 +gdb_breakpoint [gdb_get_line_number "not-filled"]
2162 +gdb_continue_to_breakpoint "not-filled (1st)"
2163 +gdb_test "print array1" " = \\(\[()1, .\]*\\)" \
2164 + "print passed array1 in foo (passed fixed array)"
2166 +gdb_breakpoint [gdb_get_line_number "array1-filled"]
2167 +gdb_continue_to_breakpoint "array1-filled (1st)"
2168 +gdb_test "print array1(5, 7)" " = 5" \
2169 + "print array1(5, 7) after filled in foo (passed fixed array)"
2170 +gdb_test "print array1(1, 1)" " = 30" \
2171 + "print array1(1, 1) after filled in foo (passed fixed array)"
2173 +gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
2174 +gdb_continue_to_breakpoint "array2-almost-filled (1st)"
2175 +gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
2176 + "print array2 in foo after it was filled (passed fixed array)"
2177 +gdb_test "print array2(2,1,1)=20" " = 20" \
2178 + "set array(2,2,2) to 20 in subroutine (passed fixed array)"
2179 +gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
2180 + "print array2 in foo after it was mofified in debugger (passed fixed array)"
2183 +# Try to access values from a fixed sub-array handled as VLA in subroutine.
2184 +gdb_continue_to_breakpoint "not-filled (2nd)"
2185 +gdb_test "print array1" " = \\(\[()5, .\]*\\)" \
2186 + "print passed array1 in foo (passed sub-array)"
2188 +gdb_continue_to_breakpoint "array1-filled (2nd)"
2189 +gdb_test "print array1(5, 5)" " = 5" \
2190 + "print array1(5, 5) after filled in foo (passed sub-array)"
2191 +gdb_test "print array1(1, 1)" " = 30" \
2192 + "print array1(1, 1) after filled in foo (passed sub-array)"
2194 +gdb_continue_to_breakpoint "array2-almost-filled (2nd)"
2195 +gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
2196 + "print array2 in foo after it was filled (passed sub-array)"
2197 +gdb_test "print array2(2,1,1)=20" " = 20" \
2198 + "set array(2,2,2) to 20 in subroutine (passed sub-array)"
2199 +gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
2200 + "print array2 in foo after it was mofified in debugger (passed sub-array)"
2203 +# Try to access values from a VLA passed to subroutine.
2204 +gdb_continue_to_breakpoint "not-filled (3rd)"
2205 +gdb_test "print array1" " = \\(\[()42, .\]*\\)" \
2206 + "print passed array1 in foo (passed vla)"
2208 +gdb_continue_to_breakpoint "array1-filled (3rd)"
2209 +gdb_test "print array1(5, 5)" " = 5" \
2210 + "print array1(5, 5) after filled in foo (passed vla)"
2211 +gdb_test "print array1(1, 1)" " = 30" \
2212 + "print array1(1, 1) after filled in foo (passed vla)"
2214 +gdb_continue_to_breakpoint "array2-almost-filled (3rd)"
2215 +gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
2216 + "print array2 in foo after it was filled (passed vla)"
2217 +gdb_test "print array2(2,1,1)=20" " = 20" \
2218 + "set array(2,2,2) to 20 in subroutine (passed vla)"
2219 +gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
2220 + "print array2 in foo after it was mofified in debugger (passed vla)"
2221 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-value.exp
2222 ===================================================================
2223 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2224 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla-value.exp 2015-01-26 07:47:42.408829922 +0100
2226 +# Copyright 2014 Free Software Foundation, Inc.
2228 +# This program is free software; you can redistribute it and/or modify
2229 +# it under the terms of the GNU General Public License as published by
2230 +# the Free Software Foundation; either version 3 of the License, or
2231 +# (at your option) any later version.
2233 +# This program is distributed in the hope that it will be useful,
2234 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2235 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2236 +# GNU General Public License for more details.
2238 +# You should have received a copy of the GNU General Public License
2239 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2241 +standard_testfile "vla.f90"
2243 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
2244 + {debug f90 quiet}] } {
2248 +if ![runto MAIN__] then {
2249 + perror "couldn't run to breakpoint MAIN__"
2253 +# Try to access values in non allocated VLA
2254 +gdb_breakpoint [gdb_get_line_number "vla1-init"]
2255 +gdb_continue_to_breakpoint "vla1-init"
2256 +gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
2257 +gdb_test "print &vla1" \
2258 + " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not allocated>\\\)\\\)\\\) $hex" \
2259 + "print non-allocated &vla1"
2260 +gdb_test "print vla1(1,1,1)" "no such vector element because not allocated" \
2261 + "print member in non-allocated vla1 (1)"
2262 +gdb_test "print vla1(101,202,303)" \
2263 + "no such vector element because not allocated" \
2264 + "print member in non-allocated vla1 (2)"
2265 +gdb_test "print vla1(5,2,18)=1" "no such vector element because not allocated" \
2266 + "set member in non-allocated vla1"
2268 +# Try to access value in allocated VLA
2269 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
2270 +gdb_continue_to_breakpoint "vla2-allocated"
2271 +gdb_test "next" "\\d+(\\t|\\s)+vla1\\\(3, 6, 9\\\) = 42" \
2272 + "step over value assignment of vla1"
2273 +gdb_test "print &vla1" \
2274 + " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
2275 + "print allocated &vla1"
2276 +gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
2277 +gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
2278 +gdb_test "print vla1(9, 9, 9) = 999" " = 999" \
2279 + "print allocated vla1(9,9,9)=1"
2281 +# Try to access values in allocated VLA after specific assignment
2282 +gdb_breakpoint [gdb_get_line_number "vla1-filled"]
2283 +gdb_continue_to_breakpoint "vla1-filled"
2284 +gdb_test "print vla1(3, 6, 9)" " = 42" \
2285 + "print allocated vla1(3,6,9) after specific assignment (filled)"
2286 +gdb_test "print vla1(1, 3, 8)" " = 1001" \
2287 + "print allocated vla1(1,3,8) after specific assignment (filled)"
2288 +gdb_test "print vla1(9, 9, 9)" " = 999" \
2289 + "print allocated vla1(9,9,9) after assignment in debugger (filled)"
2291 +# Try to access values in undefined pointer to VLA (dangling)
2292 +gdb_test "print pvla" " = <not associated>" "print undefined pvla"
2293 +gdb_test "print &pvla" \
2294 + " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not associated>\\\)\\\)\\\) $hex" \
2295 + "print non-associated &pvla"
2296 +gdb_test "print pvla(1, 3, 8)" "no such vector element because not associated" \
2297 + "print undefined pvla(1,3,8)"
2299 +# Try to access values in pointer to VLA and compare them
2300 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
2301 +gdb_continue_to_breakpoint "pvla-associated"
2302 +gdb_test "print &pvla" \
2303 + " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
2304 + "print associated &pvla"
2305 +gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
2306 +gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
2307 +gdb_test "print pvla(9, 9, 9)" " = 999" "print associated pvla(9,9,9)"
2309 +# Fill values to VLA using pointer and check
2310 +gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
2311 +gdb_continue_to_breakpoint "pvla-re-associated"
2312 +gdb_test "print pvla(5, 45, 20)" \
2313 + " = 1" "print pvla(5, 45, 20) after filled using pointer"
2314 +gdb_test "print vla2(5, 45, 20)" \
2315 + " = 1" "print vla2(5, 45, 20) after filled using pointer"
2316 +gdb_test "print pvla(7, 45, 14)" " = 2" \
2317 + "print pvla(7, 45, 14) after filled using pointer"
2318 +gdb_test "print vla2(7, 45, 14)" " = 2" \
2319 + "print vla2(7, 45, 14) after filled using pointer"
2321 +# Try to access values of deassociated VLA pointer
2322 +gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
2323 +gdb_continue_to_breakpoint "pvla-deassociated"
2324 +gdb_test "print pvla(5, 45, 20)" \
2325 + "no such vector element because not associated" \
2326 + "print pvla(5, 45, 20) after deassociated"
2327 +gdb_test "print pvla(7, 45, 14)" \
2328 + "no such vector element because not associated" \
2329 + "print pvla(7, 45, 14) after dissasociated"
2330 +gdb_test "print pvla" " = <not associated>" \
2331 + "print vla1 after deassociated"
2333 +# Try to access values of deallocated VLA
2334 +gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
2335 +gdb_continue_to_breakpoint "vla1-deallocated"
2336 +gdb_test "print vla1(3, 6, 9)" "no such vector element because not allocated" \
2337 + "print allocated vla1(3,6,9) after specific assignment (deallocated)"
2338 +gdb_test "print vla1(1, 3, 8)" "no such vector element because not allocated" \
2339 + "print allocated vla1(1,3,8) after specific assignment (deallocated)"
2340 +gdb_test "print vla1(9, 9, 9)" "no such vector element because not allocated" \
2341 + "print allocated vla1(9,9,9) after assignment in debugger (deallocated)"
2344 +# Try to assign VLA to user variable
2345 +clean_restart ${testfile}
2347 +if ![runto MAIN__] then {
2348 + perror "couldn't run to breakpoint MAIN__"
2351 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
2352 +gdb_continue_to_breakpoint "vla2-allocated"
2353 +gdb_test "next" "\\d+.*vla1\\(3, 6, 9\\) = 42" "next (1)"
2355 +gdb_test_no_output "set \$myvar = vla1" "set \$myvar = vla1"
2356 +gdb_test "print \$myvar" \
2357 + " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" \
2358 + "print \$myvar set to vla1"
2360 +gdb_test "next" "\\d+.*vla1\\(1, 3, 8\\) = 1001" "next (2)"
2361 +gdb_test "print \$myvar(3,6,9)" " = 1311" "print \$myvar(3,6,9)"
2363 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
2364 +gdb_continue_to_breakpoint "pvla-associated"
2365 +gdb_test_no_output "set \$mypvar = pvla" "set \$mypvar = pvla"
2366 +gdb_test "print \$mypvar(1,3,8)" " = 1001" "print \$mypvar(1,3,8)"
2368 +# deallocate pointer and make sure user defined variable still has the
2370 +gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
2371 +gdb_continue_to_breakpoint "pvla-deassociated"
2372 +gdb_test "print \$mypvar(1,3,8)" " = 1001" \
2373 + "print \$mypvar(1,3,8) after deallocated"
2374 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla.f90
2375 ===================================================================
2376 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2377 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.fortran/vla.f90 2015-01-26 07:47:42.408829922 +0100
2379 +! Copyright 2014 Free Software Foundation, Inc.
2381 +! This program is free software; you can redistribute it and/or modify
2382 +! it under the terms of the GNU General Public License as published by
2383 +! the Free Software Foundation; either version 3 of the License, or
2384 +! (at your option) any later version.
2386 +! This program is distributed in the hope that it will be useful,
2387 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
2388 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2389 +! GNU General Public License for more details.
2391 +! You should have received a copy of the GNU General Public License
2392 +! along with this program. If not, see <http://www.gnu.org/licenses/>.
2395 + real, target, allocatable :: vla1 (:, :, :)
2396 + real, target, allocatable :: vla2 (:, :, :)
2397 + real, target, allocatable :: vla3 (:, :)
2398 + real, pointer :: pvla (:, :, :)
2401 + allocate (vla1 (10,10,10)) ! vla1-init
2402 + l = allocated(vla1)
2404 + allocate (vla2 (1:7,42:50,13:35)) ! vla1-allocated
2405 + l = allocated(vla2)
2407 + vla1(:, :, :) = 1311 ! vla2-allocated
2408 + vla1(3, 6, 9) = 42
2409 + vla1(1, 3, 8) = 1001
2410 + vla1(6, 2, 7) = 13
2412 + vla2(:, :, :) = 1311 ! vla1-filled
2413 + vla2(5, 45, 20) = 42
2415 + pvla => vla1 ! vla2-filled
2416 + l = associated(pvla)
2418 + pvla => vla2 ! pvla-associated
2419 + l = associated(pvla)
2420 + pvla(5, 45, 20) = 1
2421 + pvla(7, 45, 14) = 2
2423 + pvla => null() ! pvla-re-associated
2424 + l = associated(pvla)
2426 + deallocate (vla1) ! pvla-deassociated
2427 + l = allocated(vla1)
2429 + deallocate (vla2) ! vla1-deallocated
2430 + l = allocated(vla2)
2432 + allocate (vla3 (2,2)) ! vla2-deallocated
2435 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
2436 ===================================================================
2437 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2438 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.mi/mi-vla-fortran.exp 2015-01-26 07:47:42.408829922 +0100
2440 +# Copyright 2014 Free Software Foundation, Inc.
2442 +# This program is free software; you can redistribute it and/or modify
2443 +# it under the terms of the GNU General Public License as published by
2444 +# the Free Software Foundation; either version 3 of the License, or
2445 +# (at your option) any later version.
2447 +# This program is distributed in the hope that it will be useful,
2448 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2449 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2450 +# GNU General Public License for more details.
2452 +# You should have received a copy of the GNU General Public License
2453 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2455 +# Verify that, using the MI, we can evaluate a simple C Variable Length
2458 +load_lib mi-support.exp
2459 +set MIFLAGS "-i=mi"
2462 +if [mi_gdb_start] {
2466 +standard_testfile vla.f90
2468 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
2469 + {debug f90}] != "" } {
2470 + untested mi-vla-fortran.exp
2474 +mi_delete_breakpoints
2475 +mi_gdb_reinitialize_dir $srcdir/$subdir
2476 +mi_gdb_load ${binfile}
2478 +set bp_lineno [gdb_get_line_number "vla1-not-allocated"]
2479 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 1 "del" "vla" \
2480 + ".*vla.f90" $bp_lineno $hex \
2481 + "insert breakpoint at line $bp_lineno (vla not allocated)"
2483 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2484 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2485 +mi_gdb_test "500-data-evaluate-expression vla1" \
2486 + "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
2488 +mi_create_varobj_checked vla1_not_allocated vla1 "<not allocated>" \
2489 + "create local variable vla1_not_allocated"
2490 +mi_gdb_test "501-var-info-type vla1_not_allocated" \
2491 + "501\\^done,type=\"<not allocated>\"" \
2492 + "info type variable vla1_not_allocated"
2493 +mi_gdb_test "502-var-show-format vla1_not_allocated" \
2494 + "502\\^done,format=\"natural\"" \
2495 + "show format variable vla1_not_allocated"
2496 +mi_gdb_test "503-var-evaluate-expression vla1_not_allocated" \
2497 + "503\\^done,value=\"\\\[0\\\]\"" \
2498 + "eval variable vla1_not_allocated"
2499 +mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
2500 + "real\\\(kind=4\\\)" "get children of vla1_not_allocated"
2504 +set bp_lineno [gdb_get_line_number "vla1-allocated"]
2505 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 2 "del" "vla" ".*vla.f90" \
2506 + $bp_lineno $hex "insert breakpoint at line $bp_lineno (vla allocated)"
2508 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2509 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2510 +mi_gdb_test "510-data-evaluate-expression vla1" \
2511 + "510\\^done,value=\"\\(0, 0, 0, 0, 0\\)\"" "evaluate allocated vla"
2513 +mi_create_varobj_checked vla1_allocated vla1 "real\\\(kind=4\\\) \\\(5\\\)" \
2514 + "create local variable vla1_allocated"
2515 +mi_gdb_test "511-var-info-type vla1_allocated" \
2516 + "511\\^done,type=\"real\\\(kind=4\\\) \\\(5\\\)\"" \
2517 + "info type variable vla1_allocated"
2518 +mi_gdb_test "512-var-show-format vla1_allocated" \
2519 + "512\\^done,format=\"natural\"" \
2520 + "show format variable vla1_allocated"
2521 +mi_gdb_test "513-var-evaluate-expression vla1_allocated" \
2522 + "513\\^done,value=\"\\\[5\\\]\"" \
2523 + "eval variable vla1_allocated"
2524 +mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
2525 + "real\\\(kind=4\\\)" "get children of vla1_allocated"
2528 +set bp_lineno [gdb_get_line_number "vla1-filled"]
2529 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 3 "del" "vla" ".*vla.f90" \
2530 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2532 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2533 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2534 +mi_gdb_test "520-data-evaluate-expression vla1" \
2535 + "520\\^done,value=\"\\(1, 1, 1, 1, 1\\)\"" "evaluate filled vla"
2538 +set bp_lineno [gdb_get_line_number "vla1-modified"]
2539 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 4 "del" "vla" ".*vla.f90" \
2540 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2542 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2543 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2544 +mi_gdb_test "530-data-evaluate-expression vla1" \
2545 + "530\\^done,value=\"\\(1, 42, 1, 24, 1\\)\"" "evaluate filled vla"
2546 +mi_gdb_test "540-data-evaluate-expression vla1(1)" \
2547 + "540\\^done,value=\"1\"" "evaluate filled vla"
2548 +mi_gdb_test "550-data-evaluate-expression vla1(2)" \
2549 + "550\\^done,value=\"42\"" "evaluate filled vla"
2550 +mi_gdb_test "560-data-evaluate-expression vla1(4)" \
2551 + "560\\^done,value=\"24\"" "evaluate filled vla"
2554 +set bp_lineno [gdb_get_line_number "vla1-deallocated"]
2555 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 5 "del" "vla" ".*vla.f90" \
2556 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2558 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2559 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2560 +mi_gdb_test "570-data-evaluate-expression vla1" \
2561 + "570\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
2564 +set bp_lineno [gdb_get_line_number "pvla2-not-associated"]
2565 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 6 "del" "vla" ".*vla.f90" \
2566 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2568 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2569 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2570 +mi_gdb_test "580-data-evaluate-expression pvla2" \
2571 + "580\\^done,value=\"<not associated>\"" "evaluate not associated vla"
2573 +mi_create_varobj_checked pvla2_not_associated pvla2 "<not associated>" \
2574 + "create local variable pvla2_not_associated"
2575 +mi_gdb_test "581-var-info-type pvla2_not_associated" \
2576 + "581\\^done,type=\"<not associated>\"" \
2577 + "info type variable pvla2_not_associated"
2578 +mi_gdb_test "582-var-show-format pvla2_not_associated" \
2579 + "582\\^done,format=\"natural\"" \
2580 + "show format variable pvla2_not_associated"
2581 +mi_gdb_test "583-var-evaluate-expression pvla2_not_associated" \
2582 + "583\\^done,value=\"\\\[0\\\]\"" \
2583 + "eval variable pvla2_not_associated"
2584 +mi_list_array_varobj_children_with_index "pvla2_not_associated" "0" "1" \
2585 + "real\\\(kind=4\\\)" "get children of pvla2_not_associated"
2588 +set bp_lineno [gdb_get_line_number "pvla2-associated"]
2589 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 7 "del" "vla" ".*vla.f90" \
2590 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2592 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2593 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2594 +mi_gdb_test "590-data-evaluate-expression pvla2" \
2595 + "590\\^done,value=\"\\(\\( 2, 2, 2, 2, 2\\) \\( 2, 2, 2, 2, 2\\) \\)\"" \
2596 + "evaluate associated vla"
2598 +mi_create_varobj_checked pvla2_associated pvla2 \
2599 + "real\\\(kind=4\\\) \\\(5,2\\\)" "create local variable pvla2_associated"
2600 +mi_gdb_test "591-var-info-type pvla2_associated" \
2601 + "591\\^done,type=\"real\\\(kind=4\\\) \\\(5,2\\\)\"" \
2602 + "info type variable pvla2_associated"
2603 +mi_gdb_test "592-var-show-format pvla2_associated" \
2604 + "592\\^done,format=\"natural\"" \
2605 + "show format variable pvla2_associated"
2606 +mi_gdb_test "593-var-evaluate-expression pvla2_associated" \
2607 + "593\\^done,value=\"\\\[2\\\]\"" \
2608 + "eval variable pvla2_associated"
2611 +set bp_lineno [gdb_get_line_number "pvla2-set-to-null"]
2612 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 8 "del" "vla" ".*vla.f90" \
2613 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2615 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2616 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2617 +mi_gdb_test "600-data-evaluate-expression pvla2" \
2618 + "600\\^done,value=\"<not associated>\"" "evaluate vla pointer set to null"
2622 Index: gdb-7.8.90.20150126/gdb/testsuite/gdb.mi/vla.f90
2623 ===================================================================
2624 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2625 +++ gdb-7.8.90.20150126/gdb/testsuite/gdb.mi/vla.f90 2015-01-26 07:47:42.409829926 +0100
2627 +! Copyright 2014 Free Software Foundation, Inc.
2629 +! This program is free software; you can redistribute it and/or modify
2630 +! it under the terms of the GNU General Public License as published by
2631 +! the Free Software Foundation; either version 3 of the License, or
2632 +! (at your option) any later version.
2634 +! This program is distributed in the hope that it will be useful,
2635 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
2636 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2637 +! GNU General Public License for more details.
2639 +! You should have received a copy of the GNU General Public License
2640 +! along with this program. If not, see <http://www.gnu.org/licenses/>.
2643 + real, allocatable :: vla1 (:)
2644 + real, target, allocatable :: vla2(:, :)
2645 + real, pointer :: pvla2 (:, :)
2648 + allocate (vla1 (5)) ! vla1-not-allocated
2649 + l = allocated(vla1) ! vla1-allocated
2652 + vla1(2) = 42 ! vla1-filled
2655 + deallocate (vla1) ! vla1-modified
2656 + l = allocated(vla1) ! vla1-deallocated
2658 + allocate (vla2 (5, 2))
2661 + pvla2 => vla2 ! pvla2-not-associated
2662 + l = associated(pvla2) ! pvla2-associated
2667 + l = associated(pvla2) ! pvla2-set-to-null
2669 Index: gdb-7.8.90.20150126/gdb/typeprint.c
2670 ===================================================================
2671 --- gdb-7.8.90.20150126.orig/gdb/typeprint.c 2015-01-26 07:47:25.856758418 +0100
2672 +++ gdb-7.8.90.20150126/gdb/typeprint.c 2015-01-26 07:47:42.409829926 +0100
2673 @@ -456,6 +456,13 @@ whatis_exp (char *exp, int show)
2675 type = value_type (val);
2677 + if (TYPE_CODE (type) == TYPE_CODE_PTR)
2678 + if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
2680 + val = value_addr (value_ind (val));
2681 + type = value_type (val);
2684 get_user_print_options (&opts);
2685 if (opts.objectprint)
2687 Index: gdb-7.8.90.20150126/gdb/valarith.c
2688 ===================================================================
2689 --- gdb-7.8.90.20150126.orig/gdb/valarith.c 2015-01-26 07:47:25.857758422 +0100
2690 +++ gdb-7.8.90.20150126/gdb/valarith.c 2015-01-26 07:47:42.409829926 +0100
2691 @@ -193,12 +193,31 @@ value_subscripted_rvalue (struct value *
2692 struct type *array_type = check_typedef (value_type (array));
2693 struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
2694 unsigned int elt_size = TYPE_LENGTH (elt_type);
2695 - unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
2696 + unsigned int elt_offs = longest_to_int (index - lowerbound);
2697 + LONGEST elt_stride = TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type));
2700 + if (elt_stride > 0)
2701 + elt_offs *= elt_stride;
2702 + else if (elt_stride < 0)
2704 + int offs = (elt_offs + 1) * elt_stride;
2706 + elt_offs = TYPE_LENGTH (array_type) + offs;
2709 + elt_offs *= elt_size;
2711 if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
2712 && elt_offs >= TYPE_LENGTH (array_type)))
2713 - error (_("no such vector element"));
2715 + if (TYPE_NOT_ASSOCIATED (array_type))
2716 + error (_("no such vector element because not associated"));
2717 + else if (TYPE_NOT_ALLOCATED (array_type))
2718 + error (_("no such vector element because not allocated"));
2720 + error (_("no such vector element"));
2723 if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
2724 v = allocate_value_lazy (elt_type);
2725 Index: gdb-7.8.90.20150126/gdb/valprint.c
2726 ===================================================================
2727 --- gdb-7.8.90.20150126.orig/gdb/valprint.c 2015-01-26 07:47:25.858758427 +0100
2728 +++ gdb-7.8.90.20150126/gdb/valprint.c 2015-01-26 07:47:42.410829930 +0100
2729 @@ -303,6 +303,18 @@ valprint_check_validity (struct ui_file
2731 CHECK_TYPEDEF (type);
2733 + if (TYPE_NOT_ASSOCIATED (type))
2735 + val_print_not_associated (stream);
2739 + if (TYPE_NOT_ALLOCATED (type))
2741 + val_print_not_allocated (stream);
2745 if (TYPE_CODE (type) != TYPE_CODE_UNION
2746 && TYPE_CODE (type) != TYPE_CODE_STRUCT
2747 && TYPE_CODE (type) != TYPE_CODE_ARRAY)
2748 @@ -359,6 +371,18 @@ val_print_invalid_address (struct ui_fil
2749 fprintf_filtered (stream, _("<invalid address>"));
2753 +val_print_not_allocated (struct ui_file *stream)
2755 + fprintf_filtered (stream, _("<not allocated>"));
2759 +val_print_not_associated (struct ui_file *stream)
2761 + fprintf_filtered (stream, _("<not associated>"));
2764 /* A generic val_print that is suitable for use by language
2765 implementations of the la_val_print method. This function can
2766 handle most type codes, though not all, notably exception
2767 @@ -800,12 +824,16 @@ static int
2768 value_check_printable (struct value *val, struct ui_file *stream,
2769 const struct value_print_options *options)
2771 + const struct type *type;
2775 fprintf_filtered (stream, _("<address of value unknown>"));
2779 + type = value_type (val);
2781 if (value_entirely_optimized_out (val))
2783 if (options->summary && !val_print_scalar_type_p (value_type (val)))
2784 @@ -831,6 +859,18 @@ value_check_printable (struct value *val
2788 + if (TYPE_NOT_ASSOCIATED (type))
2790 + val_print_not_associated (stream);
2794 + if (TYPE_NOT_ALLOCATED (type))
2796 + val_print_not_allocated (stream);
2803 Index: gdb-7.8.90.20150126/gdb/valprint.h
2804 ===================================================================
2805 --- gdb-7.8.90.20150126.orig/gdb/valprint.h 2015-01-26 07:47:25.859758431 +0100
2806 +++ gdb-7.8.90.20150126/gdb/valprint.h 2015-01-26 07:47:42.410829930 +0100
2807 @@ -217,4 +217,8 @@ extern void output_command_const (const
2809 extern int val_print_scalar_type_p (struct type *type);
2811 +extern void val_print_not_allocated (struct ui_file *stream);
2813 +extern void val_print_not_associated (struct ui_file *stream);
2816 Index: gdb-7.8.90.20150126/gdb/value.c
2817 ===================================================================
2818 --- gdb-7.8.90.20150126.orig/gdb/value.c 2015-01-26 07:47:25.860758435 +0100
2819 +++ gdb-7.8.90.20150126/gdb/value.c 2015-01-26 07:47:42.411829935 +0100
2821 #include "tracepoint.h"
2823 #include "user-regs.h"
2824 +#include "dwarf2loc.h"
2826 /* Prototypes for exported functions. */
2828 @@ -1755,6 +1756,25 @@ set_value_component_location (struct val
2829 if (funcs->copy_closure)
2830 component->location.computed.closure = funcs->copy_closure (whole);
2833 + /* For dynamic types compute the address of the component value location in
2834 + sub range types based on the location of the sub range type, if not being
2835 + an internal GDB variable or parts of it. */
2836 + if (VALUE_LVAL (component) != lval_internalvar
2837 + && VALUE_LVAL (component) != lval_internalvar_component)
2840 + struct type *type = value_type (whole);
2842 + addr = value_raw_address (component);
2844 + if (TYPE_DATA_LOCATION (type)
2845 + && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
2847 + addr = TYPE_DATA_LOCATION_ADDR (type);
2848 + set_value_address (component, addr);
2854 @@ -3041,13 +3061,22 @@ value_primitive_field (struct value *arg
2855 v = allocate_value_lazy (type);
2858 - v = allocate_value (type);
2859 - value_contents_copy_raw (v, value_embedded_offset (v),
2860 - arg1, value_embedded_offset (arg1) + offset,
2861 - TYPE_LENGTH (type));
2862 + if (TYPE_DATA_LOCATION (type)
2863 + && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
2864 + v = value_at_lazy (type, value_address (arg1) + offset);
2867 + v = allocate_value (type);
2868 + value_contents_copy_raw (v, value_embedded_offset (v),
2869 + arg1, value_embedded_offset (arg1) + offset,
2870 + TYPE_LENGTH (type));
2873 - v->offset = (value_offset (arg1) + offset
2874 - + value_embedded_offset (arg1));
2876 + if (!TYPE_DATA_LOCATION (type)
2877 + || !TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
2878 + v->offset = (value_offset (arg1) + offset
2879 + + value_embedded_offset (arg1));
2881 set_value_component_location (v, arg1);
2882 VALUE_REGNUM (v) = VALUE_REGNUM (arg1);
2883 @@ -3635,7 +3664,8 @@ readjust_indirect_value_type (struct val
2884 struct value *original_value)
2886 /* Re-adjust type. */
2887 - deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type));
2888 + if (!is_dynamic_type (TYPE_TARGET_TYPE (original_type)))
2889 + deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type));
2891 /* Add embedding info. */
2892 set_value_enclosing_type (value, enc_type);
2893 @@ -3652,6 +3682,12 @@ coerce_ref (struct value *arg)
2894 struct value *retval;
2895 struct type *enc_type;
2897 + if (current_language->la_language != language_fortran
2898 + && TYPE_DATA_LOCATION (value_type_arg_tmp) != NULL
2899 + && TYPE_DATA_LOCATION_KIND (value_type_arg_tmp) == PROP_CONST)
2900 + arg = value_at_lazy (value_type_arg_tmp,
2901 + TYPE_DATA_LOCATION_ADDR (value_type_arg_tmp));
2903 retval = coerce_ref_if_computed (arg);
2906 @@ -3786,8 +3822,14 @@ value_fetch_lazy (struct value *val)
2908 else if (VALUE_LVAL (val) == lval_memory)
2910 - CORE_ADDR addr = value_address (val);
2911 struct type *type = check_typedef (value_enclosing_type (val));
2914 + if (TYPE_DATA_LOCATION (type) != NULL
2915 + && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
2916 + addr = TYPE_DATA_LOCATION_ADDR (type);
2918 + addr = value_address (val);
2920 if (TYPE_LENGTH (type))
2921 read_value_memory (val, 0, value_stack (val),
2922 Index: gdb-7.8.90.20150126/gdb/dwarf2loc.c
2923 ===================================================================
2924 --- gdb-7.8.90.20150126.orig/gdb/dwarf2loc.c 2015-01-26 07:47:25.862758444 +0100
2925 +++ gdb-7.8.90.20150126/gdb/dwarf2loc.c 2015-01-26 07:47:42.412829939 +0100
2926 @@ -2293,6 +2293,11 @@ dwarf2_evaluate_loc_desc_full (struct ty
2927 int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0);
2929 do_cleanups (value_chain);
2931 + /* Select right frame to correctly evaluate VLA's during a backtrace. */
2932 + if (is_dynamic_type (type))
2933 + select_frame (frame);
2935 retval = value_at_lazy (type, address + byte_offset);
2936 if (in_stack_memory)
2937 set_value_stack (retval, 1);
2938 @@ -2552,6 +2557,19 @@ dwarf2_compile_property_to_c (struct ui_
2939 data, data + size, per_cu);
2942 +/* See dwarf2loc.h. */
2945 +dwarf2_address_data_valid (const struct type *type)
2947 + if (TYPE_NOT_ASSOCIATED (type))
2950 + if (TYPE_NOT_ALLOCATED (type))
2956 /* Helper functions and baton for dwarf2_loc_desc_needs_frame. */