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.9.50.20150520/gdb/c-valprint.c
10 ===================================================================
11 --- gdb-7.9.50.20150520.orig/gdb/c-valprint.c 2015-05-29 08:27:02.657717326 +0200
12 +++ gdb-7.9.50.20150520/gdb/c-valprint.c 2015-05-29 08:27:06.253740209 +0200
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.9.50.20150520/gdb/dwarf2loc.h
32 ===================================================================
33 --- gdb-7.9.50.20150520.orig/gdb/dwarf2loc.h 2015-05-29 08:27:02.658717333 +0200
34 +++ gdb-7.9.50.20150520/gdb/dwarf2loc.h 2015-05-29 08:27:06.253740209 +0200
35 @@ -131,6 +131,11 @@ int dwarf2_evaluate_property (const stru
36 struct property_addr_info *addr_stack,
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.9.50.20150520/gdb/dwarf2read.c
48 ===================================================================
49 --- gdb-7.9.50.20150520.orig/gdb/dwarf2read.c 2015-05-29 08:27:02.676717447 +0200
50 +++ gdb-7.9.50.20150520/gdb/dwarf2read.c 2015-05-29 10:04:52.272600212 +0200
51 @@ -1868,6 +1868,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 @@ -14431,29 +14437,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 @@ -14776,13 +14845,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 @@ -14795,8 +14866,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 @@ -14832,8 +14920,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 @@ -14887,7 +14995,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 @@ -14907,7 +15015,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 @@ -14940,19 +15050,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 @@ -15016,7 +15133,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 @@ -22128,9 +22245,37 @@ set_die_type (struct die_info *die, stru
299 && !HAVE_GNAT_AUX_INFO (type))
300 INIT_GNAT_SPECIFIC (type);
302 + /* Read DW_AT_allocated and set in type. */
303 + attr = dwarf2_attr (die, DW_AT_allocated, cu);
304 + if (attr_form_is_block (attr))
306 + struct dynamic_prop prop;
308 + if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
310 + TYPE_ALLOCATED_PROP (type)
311 + = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
312 + *TYPE_ALLOCATED_PROP (type) = prop;
316 + /* Read DW_AT_associated and set in type. */
317 + attr = dwarf2_attr (die, DW_AT_associated, cu);
318 + if (attr_form_is_block (attr))
320 + struct dynamic_prop prop;
322 + if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
324 + TYPE_ASSOCIATED_PROP (type)
325 + = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
326 + *TYPE_ASSOCIATED_PROP (type) = prop;
330 /* Read DW_AT_data_location and set in type. */
331 attr = dwarf2_attr (die, DW_AT_data_location, cu);
332 - if (attr_to_dynamic_prop (attr, die, cu, &prop))
333 + if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
334 add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type, objfile);
336 if (dwarf2_per_objfile->die_type_hash == NULL)
337 Index: gdb-7.9.50.20150520/gdb/f-typeprint.c
338 ===================================================================
339 --- gdb-7.9.50.20150520.orig/gdb/f-typeprint.c 2015-05-29 08:27:02.678717460 +0200
340 +++ gdb-7.9.50.20150520/gdb/f-typeprint.c 2015-05-29 08:27:06.261740260 +0200
345 +#include "valprint.h"
347 #if 0 /* Currently unused. */
348 static void f_type_print_args (struct type *, struct ui_file *);
349 @@ -53,6 +54,17 @@ f_print_type (struct type *type, const c
353 + if (TYPE_NOT_ASSOCIATED (type))
355 + val_print_not_associated (stream);
358 + if (TYPE_NOT_ALLOCATED (type))
360 + val_print_not_allocated (stream);
364 f_type_print_base (type, stream, show, level);
365 code = TYPE_CODE (type);
366 if ((varstring != NULL && *varstring != '\0')
367 @@ -167,28 +179,36 @@ f_type_print_varspec_suffix (struct type
368 if (arrayprint_recurse_level == 1)
369 fprintf_filtered (stream, "(");
371 - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
372 - f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
373 - arrayprint_recurse_level);
375 - lower_bound = f77_get_lowerbound (type);
376 - if (lower_bound != 1) /* Not the default. */
377 - fprintf_filtered (stream, "%d:", lower_bound);
379 - /* Make sure that, if we have an assumed size array, we
380 - print out a warning and print the upperbound as '*'. */
382 - if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
383 - fprintf_filtered (stream, "*");
384 + if (TYPE_NOT_ASSOCIATED (type))
385 + val_print_not_associated (stream);
386 + else if (TYPE_NOT_ALLOCATED (type))
387 + val_print_not_allocated (stream);
390 - upper_bound = f77_get_upperbound (type);
391 - fprintf_filtered (stream, "%d", upper_bound);
394 - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
395 - f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
396 - arrayprint_recurse_level);
399 + if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
400 + f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
401 + arrayprint_recurse_level);
403 + lower_bound = f77_get_lowerbound (type);
404 + if (lower_bound != 1) /* Not the default. */
405 + fprintf_filtered (stream, "%d:", lower_bound);
407 + /* Make sure that, if we have an assumed size array, we
408 + print out a warning and print the upperbound as '*'. */
410 + if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
411 + fprintf_filtered (stream, "*");
414 + upper_bound = f77_get_upperbound (type);
415 + fprintf_filtered (stream, "%d", upper_bound);
418 + if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
419 + f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
420 + arrayprint_recurse_level);
422 if (arrayprint_recurse_level == 1)
423 fprintf_filtered (stream, ")");
425 Index: gdb-7.9.50.20150520/gdb/f-valprint.c
426 ===================================================================
427 --- gdb-7.9.50.20150520.orig/gdb/f-valprint.c 2015-05-29 08:26:49.567634019 +0200
428 +++ gdb-7.9.50.20150520/gdb/f-valprint.c 2015-05-29 08:27:06.262740266 +0200
431 extern void _initialize_f_valprint (void);
432 static void info_common_command (char *, int);
433 -static void f77_create_arrayprint_offset_tbl (struct type *,
435 static void f77_get_dynamic_length_of_aggregate (struct type *);
437 int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
438 @@ -45,15 +43,6 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIM
439 /* Array which holds offsets to be applied to get a row's elements
440 for a given array. Array also holds the size of each subarray. */
442 -/* The following macro gives us the size of the nth dimension, Where
445 -#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
447 -/* The following gives us the offset for row n where n is 1-based. */
449 -#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
452 f77_get_lowerbound (struct type *type)
454 @@ -111,47 +100,6 @@ f77_get_dynamic_length_of_aggregate (str
455 * TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
458 -/* Function that sets up the array offset,size table for the array
462 -f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
464 - struct type *tmp_type;
471 - while (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
473 - upper = f77_get_upperbound (tmp_type);
474 - lower = f77_get_lowerbound (tmp_type);
476 - F77_DIM_SIZE (ndimen) = upper - lower + 1;
478 - tmp_type = TYPE_TARGET_TYPE (tmp_type);
482 - /* Now we multiply eltlen by all the offsets, so that later we
483 - can print out array elements correctly. Up till now we
484 - know an offset to apply to get the item but we also
485 - have to know how much to add to get to the next item. */
488 - eltlen = TYPE_LENGTH (tmp_type);
489 - F77_DIM_OFFSET (ndimen) = eltlen;
490 - while (--ndimen > 0)
492 - eltlen *= F77_DIM_SIZE (ndimen + 1);
493 - F77_DIM_OFFSET (ndimen) = eltlen;
499 /* Actual function which prints out F77 arrays, Valaddr == address in
500 the superior. Address == the address in the inferior. */
502 @@ -164,41 +112,62 @@ f77_print_array_1 (int nss, int ndimensi
503 const struct value_print_options *options,
506 + struct type *range_type = TYPE_INDEX_TYPE (check_typedef (type));
507 + CORE_ADDR addr = address + embedded_offset;
508 + LONGEST lowerbound, upperbound;
511 + get_discrete_bounds (range_type, &lowerbound, &upperbound);
513 if (nss != ndimensions)
516 - (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max);
519 + LONGEST byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
522 + dim_size = byte_stride;
524 + dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
526 + for (i = lowerbound;
527 + (i < upperbound + 1 && (*elts) < options->print_max);
530 + struct value *subarray = value_from_contents_and_address
531 + (TYPE_TARGET_TYPE (type), value_contents_for_printing_const (val)
532 + + offs, addr + offs);
534 fprintf_filtered (stream, "( ");
535 - f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
537 - embedded_offset + i * F77_DIM_OFFSET (nss),
539 - stream, recurse, val, options, elts);
540 + f77_print_array_1 (nss + 1, ndimensions, value_type (subarray),
541 + value_contents_for_printing (subarray),
542 + value_embedded_offset (subarray),
543 + value_address (subarray),
544 + stream, recurse, subarray, options, elts);
546 fprintf_filtered (stream, ") ");
548 - if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
549 + if (*elts >= options->print_max && i < upperbound)
550 fprintf_filtered (stream, "...");
554 - for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
555 + for (i = lowerbound; i < upperbound + 1 && (*elts) < options->print_max;
558 - val_print (TYPE_TARGET_TYPE (type),
560 - embedded_offset + i * F77_DIM_OFFSET (ndimensions),
561 - address, stream, recurse,
562 - val, options, current_language);
563 + struct value *elt = value_subscript ((struct value *)val, i);
565 + val_print (value_type (elt),
566 + value_contents_for_printing (elt),
567 + value_embedded_offset (elt),
568 + value_address (elt), stream, recurse,
569 + elt, options, current_language);
571 - if (i != (F77_DIM_SIZE (nss) - 1))
572 + if (i != upperbound)
573 fprintf_filtered (stream, ", ");
575 if ((*elts == options->print_max - 1)
576 - && (i != (F77_DIM_SIZE (nss) - 1)))
577 + && (i != upperbound))
578 fprintf_filtered (stream, "...");
581 @@ -225,12 +194,6 @@ f77_print_array (struct type *type, cons
582 Type node corrupt! F77 arrays cannot have %d subscripts (%d Max)"),
583 ndimensions, MAX_FORTRAN_DIMS);
585 - /* Since F77 arrays are stored column-major, we set up an
586 - offset table to get at the various row's elements. The
587 - offset table contains entries for both offset and subarray size. */
589 - f77_create_arrayprint_offset_tbl (type, stream);
591 f77_print_array_1 (1, ndimensions, type, valaddr, embedded_offset,
592 address, stream, recurse, val, options, &elts);
594 @@ -375,12 +338,15 @@ f_val_print (struct type *type, const gd
595 fprintf_filtered (stream, "( ");
596 for (index = 0; index < TYPE_NFIELDS (type); index++)
598 - int offset = TYPE_FIELD_BITPOS (type, index) / 8;
599 + struct value *field = value_field
600 + ((struct value *)original_value, index);
602 + val_print (value_type (field),
603 + value_contents_for_printing (field),
604 + value_embedded_offset (field),
605 + value_address (field), stream, recurse + 1,
606 + field, options, current_language);
608 - val_print (TYPE_FIELD_TYPE (type, index), valaddr,
609 - embedded_offset + offset,
610 - address, stream, recurse + 1,
611 - original_value, options, current_language);
612 if (index != TYPE_NFIELDS (type) - 1)
613 fputs_filtered (", ", stream);
615 Index: gdb-7.9.50.20150520/gdb/gdbtypes.c
616 ===================================================================
617 --- gdb-7.9.50.20150520.orig/gdb/gdbtypes.c 2015-05-29 08:27:02.683717492 +0200
618 +++ gdb-7.9.50.20150520/gdb/gdbtypes.c 2015-05-29 10:54:36.236498749 +0200
619 @@ -824,7 +824,8 @@ allocate_stub_method (struct type *type)
621 create_range_type (struct type *result_type, struct type *index_type,
622 const struct dynamic_prop *low_bound,
623 - const struct dynamic_prop *high_bound)
624 + const struct dynamic_prop *high_bound,
625 + const struct dynamic_prop *stride)
627 if (result_type == NULL)
628 result_type = alloc_type_copy (index_type);
629 @@ -839,6 +840,7 @@ create_range_type (struct type *result_t
630 TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
631 TYPE_RANGE_DATA (result_type)->low = *low_bound;
632 TYPE_RANGE_DATA (result_type)->high = *high_bound;
633 + TYPE_RANGE_DATA (result_type)->stride = *stride;
635 if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0)
636 TYPE_UNSIGNED (result_type) = 1;
637 @@ -867,7 +869,7 @@ struct type *
638 create_static_range_type (struct type *result_type, struct type *index_type,
639 LONGEST low_bound, LONGEST high_bound)
641 - struct dynamic_prop low, high;
642 + struct dynamic_prop low, high, stride;
644 low.kind = PROP_CONST;
645 low.data.const_val = low_bound;
646 @@ -875,7 +877,11 @@ create_static_range_type (struct type *r
647 high.kind = PROP_CONST;
648 high.data.const_val = high_bound;
650 - result_type = create_range_type (result_type, index_type, &low, &high);
651 + stride.kind = PROP_CONST;
652 + stride.data.const_val = 0;
654 + result_type = create_range_type (result_type, index_type,
655 + &low, &high, &stride);
659 @@ -1068,18 +1074,24 @@ create_array_type_with_stride (struct ty
661 TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
662 TYPE_TARGET_TYPE (result_type) = element_type;
663 - if (has_static_range (TYPE_RANGE_DATA (range_type)))
664 + if (has_static_range (TYPE_RANGE_DATA (range_type))
665 + && dwarf2_address_data_valid (result_type))
667 - LONGEST low_bound, high_bound;
668 + LONGEST low_bound, high_bound, byte_stride;
670 if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
671 low_bound = high_bound = 0;
672 CHECK_TYPEDEF (element_type);
674 + byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
676 /* Be careful when setting the array length. Ada arrays can be
677 empty arrays with the high_bound being smaller than the low_bound.
678 In such cases, the array length should be zero. */
679 if (high_bound < low_bound)
680 TYPE_LENGTH (result_type) = 0;
681 + else if (byte_stride > 0)
682 + TYPE_LENGTH (result_type) = byte_stride * (high_bound - low_bound + 1);
683 else if (bit_stride > 0)
684 TYPE_LENGTH (result_type) =
685 (bit_stride * (high_bound - low_bound + 1) + 7) / 8;
686 @@ -1789,12 +1801,31 @@ stub_noname_complaint (void)
688 is_dynamic_type_internal (struct type *type, int top_level)
695 type = check_typedef (type);
697 /* We only want to recognize references at the outermost level. */
698 if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
699 type = check_typedef (TYPE_TARGET_TYPE (type));
701 + if (TYPE_ASSOCIATED_PROP (type))
704 + if (TYPE_ALLOCATED_PROP (type))
707 + /* Scan field types in the Fortran case for nested dynamic types.
708 + This will be done only for Fortran as in the C++ case an endless recursion
709 + can occur in the area of classes. */
710 + if (current_language->la_language == language_fortran)
711 + for (index = 0; index < TYPE_NFIELDS (type); index++)
712 + if (is_dynamic_type (TYPE_FIELD_TYPE (type, index)))
715 /* Types that have a dynamic TYPE_DATA_LOCATION are considered
716 dynamic, even if the type itself is statically defined.
717 From a user's point of view, this may appear counter-intuitive;
718 @@ -1823,11 +1854,19 @@ is_dynamic_type_internal (struct type *t
720 gdb_assert (TYPE_NFIELDS (type) == 1);
722 - /* The array is dynamic if either the bounds are dynamic,
723 - or the elements it contains have a dynamic contents. */
724 + /* The array is dynamic if either
725 + - the bounds are dynamic,
726 + - the elements it contains have a dynamic contents
727 + - a data_locaton attribute was found. */
728 if (is_dynamic_type_internal (TYPE_INDEX_TYPE (type), 0))
730 - return is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0);
731 + else if (TYPE_DATA_LOCATION (type) != NULL
732 + && (TYPE_DATA_LOCATION_KIND (type) == PROP_LOCEXPR
733 + || TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST))
736 + return is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0);
740 case TYPE_CODE_STRUCT:
741 @@ -1840,6 +1879,18 @@ is_dynamic_type_internal (struct type *t
742 && is_dynamic_type_internal (TYPE_FIELD_TYPE (type, i), 0))
745 + case TYPE_CODE_PTR:
747 + if (TYPE_TARGET_TYPE (type)
748 + && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRING
749 + || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY))
750 + return is_dynamic_type (check_typedef (TYPE_TARGET_TYPE (type)));
760 @@ -1869,7 +1920,8 @@ resolve_dynamic_range (struct type *dyn_
761 struct type *static_range_type, *static_target_type;
762 const struct dynamic_prop *prop;
763 const struct dwarf2_locexpr_baton *baton;
764 - struct dynamic_prop low_bound, high_bound;
765 + struct dynamic_prop low_bound, high_bound, stride;
766 + struct type *range_copy = copy_type (dyn_range_type);
768 gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE);
770 @@ -1901,12 +1953,19 @@ resolve_dynamic_range (struct type *dyn_
771 high_bound.data.const_val = 0;
774 + prop = &TYPE_RANGE_DATA (dyn_range_type)->stride;
775 + if (dwarf2_evaluate_property (prop, addr_stack, &value))
777 + stride.kind = PROP_CONST;
778 + stride.data.const_val = value;
782 - = resolve_dynamic_type_internal (TYPE_TARGET_TYPE (dyn_range_type),
783 + = resolve_dynamic_type_internal (TYPE_TARGET_TYPE (range_copy),
785 - static_range_type = create_range_type (copy_type (dyn_range_type),
786 + static_range_type = create_range_type (range_copy,
788 - &low_bound, &high_bound);
789 + &low_bound, &high_bound, &stride);
790 TYPE_RANGE_DATA (static_range_type)->flag_bound_evaluated = 1;
791 return static_range_type;
793 @@ -1923,23 +1982,47 @@ resolve_dynamic_array (struct type *type
794 struct type *elt_type;
795 struct type *range_type;
796 struct type *ary_dim;
797 + struct dynamic_prop *prop;
798 + struct type *copy = copy_type (type);
800 - gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
801 + gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY
802 + || TYPE_CODE (type) == TYPE_CODE_STRING);
805 range_type = check_typedef (TYPE_INDEX_TYPE (elt_type));
806 range_type = resolve_dynamic_range (range_type, addr_stack);
808 + prop = TYPE_ALLOCATED_PROP (type);
809 + if (dwarf2_evaluate_property (prop, addr_stack, &value))
811 + TYPE_ALLOCATED_PROP (copy)->kind = PROP_CONST;
812 + TYPE_ALLOCATED_PROP (copy)->data.const_val = value;
815 + prop = TYPE_ASSOCIATED_PROP (type);
816 + if (dwarf2_evaluate_property (prop, addr_stack, &value))
818 + TYPE_ASSOCIATED_PROP (copy)->kind = PROP_CONST;
819 + TYPE_ASSOCIATED_PROP (copy)->data.const_val = value;
822 ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
824 - if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
825 - elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (type), addr_stack);
826 + if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY
827 + || TYPE_CODE (ary_dim) == TYPE_CODE_STRING))
828 + elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (copy), addr_stack);
830 elt_type = TYPE_TARGET_TYPE (type);
832 - return create_array_type_with_stride (copy_type (type),
833 - elt_type, range_type,
834 - TYPE_FIELD_BITSIZE (type, 0));
835 + if (TYPE_CODE (type) == TYPE_CODE_STRING
836 + && TYPE_FIELD_BITSIZE (type, 0) == 0)
837 + return create_string_type (copy,
841 + return create_array_type_with_stride (copy,
843 + range_type, TYPE_FIELD_BITSIZE (type, 0));
846 /* Resolve dynamic bounds of members of the union TYPE to static
847 @@ -4453,6 +4536,20 @@ copy_type_recursive (struct objfile *obj
848 TYPE_DYN_PROP_LIST (type));
851 + /* Copy allocated information. */
852 + if (TYPE_ALLOCATED_PROP (type) != NULL)
854 + TYPE_ALLOCATED_PROP (new_type) = xmalloc (sizeof (struct dynamic_prop));
855 + *TYPE_ALLOCATED_PROP (new_type) = *TYPE_ALLOCATED_PROP (type);
858 + /* Copy associated information. */
859 + if (TYPE_ASSOCIATED_PROP (type) != NULL)
861 + TYPE_ASSOCIATED_PROP (new_type) = xmalloc (sizeof (struct dynamic_prop));
862 + *TYPE_ASSOCIATED_PROP (new_type) = *TYPE_ASSOCIATED_PROP (type);
865 /* Copy pointers to other types. */
866 if (TYPE_TARGET_TYPE (type))
867 TYPE_TARGET_TYPE (new_type) =
868 @@ -4494,6 +4591,35 @@ copy_type_recursive (struct objfile *obj
869 gdb_assert_not_reached ("bad type_specific_kind");
872 + if (TYPE_ALLOCATED_PROP (type))
874 + TYPE_ALLOCATED_PROP (new_type)
875 + = OBSTACK_ZALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
876 + struct dynamic_prop);
877 + memcpy (TYPE_ALLOCATED_PROP (new_type), TYPE_ALLOCATED_PROP (type),
878 + sizeof (struct dynamic_prop));
881 + if (TYPE_ASSOCIATED_PROP (type))
883 + TYPE_ASSOCIATED_PROP (new_type)
884 + = OBSTACK_ZALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
885 + struct dynamic_prop);
886 + memcpy (TYPE_ASSOCIATED_PROP (new_type), TYPE_ASSOCIATED_PROP (type),
887 + sizeof (struct dynamic_prop));
890 + if (TYPE_NFIELDS (type))
892 + int nfields = TYPE_NFIELDS (type);
894 + TYPE_FIELDS (new_type)
895 + = OBSTACK_CALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
896 + nfields, struct field);
897 + memcpy (TYPE_FIELDS (new_type), TYPE_FIELDS (type),
898 + nfields * sizeof (struct field));
904 @@ -4519,6 +4645,14 @@ copy_type (const struct type *type)
905 TYPE_DYN_PROP_LIST (new_type)
906 = copy_dynamic_prop_list (&TYPE_OBJFILE (type) -> objfile_obstack,
907 TYPE_DYN_PROP_LIST (type));
908 + if (TYPE_ALLOCATED_PROP (type) != NULL)
909 + TYPE_ALLOCATED_PROP (new_type) = obstack_copy
910 + (&TYPE_OBJFILE (type)->objfile_obstack, TYPE_ALLOCATED_PROP (type),
911 + sizeof (*TYPE_ALLOCATED_PROP (type)));
912 + if (TYPE_ASSOCIATED_PROP (type) != NULL)
913 + TYPE_ASSOCIATED_PROP (new_type) = obstack_copy
914 + (&TYPE_OBJFILE (type)->objfile_obstack, TYPE_ASSOCIATED_PROP (type),
915 + sizeof (*TYPE_ASSOCIATED_PROP (type)));
919 Index: gdb-7.9.50.20150520/gdb/gdbtypes.h
920 ===================================================================
921 --- gdb-7.9.50.20150520.orig/gdb/gdbtypes.h 2015-05-29 08:27:02.685717504 +0200
922 +++ gdb-7.9.50.20150520/gdb/gdbtypes.h 2015-05-29 08:46:08.862924052 +0200
923 @@ -569,6 +569,10 @@ struct range_bounds
925 struct dynamic_prop high;
927 + /* * Stride of range. */
929 + struct dynamic_prop stride;
931 /* True if HIGH range bound contains the number of elements in the
932 subrange. This affects how the final hight bound is computed. */
934 @@ -741,6 +745,18 @@ struct main_type
936 /* * Contains all dynamic type properties. */
937 struct dynamic_prop_list *dyn_prop_list;
939 + /* Structure for DW_AT_allocated.
940 + The presence of this attribute indicates that the object of the type
941 + can be allocated/deallocated. The value can be a dwarf expression,
942 + reference, or a constant. */
943 + struct dynamic_prop *allocated;
945 + /* Structure for DW_AT_associated.
946 + The presence of this attribute indicated that the object of the type
947 + can be associated. The value can be a dwarf expression,
948 + reference, or a constant. */
949 + struct dynamic_prop *associated;
952 /* * A ``struct type'' describes a particular instance of a type, with
953 @@ -1255,6 +1271,15 @@ extern void allocate_gnat_aux_type (stru
954 TYPE_RANGE_DATA(range_type)->high.kind
955 #define TYPE_LOW_BOUND_KIND(range_type) \
956 TYPE_RANGE_DATA(range_type)->low.kind
957 +#define TYPE_BYTE_STRIDE(range_type) \
958 + TYPE_RANGE_DATA(range_type)->stride.data.const_val
959 +#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
960 + TYPE_RANGE_DATA(range_type)->stride.data.locexpr
961 +#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \
962 + TYPE_RANGE_DATA(range_type)->stride.data.loclist
963 +#define TYPE_BYTE_STRIDE_KIND(range_type) \
964 + TYPE_RANGE_DATA(range_type)->stride.kind
967 /* Property accessors for the type data location. */
968 #define TYPE_DATA_LOCATION(thistype) \
969 @@ -1265,6 +1290,20 @@ extern void allocate_gnat_aux_type (stru
970 TYPE_DATA_LOCATION (thistype)->data.const_val
971 #define TYPE_DATA_LOCATION_KIND(thistype) \
972 TYPE_DATA_LOCATION (thistype)->kind
973 +#define TYPE_ALLOCATED_PROP(thistype) TYPE_MAIN_TYPE(thistype)->allocated
974 +#define TYPE_ASSOCIATED_PROP(thistype) TYPE_MAIN_TYPE(thistype)->associated
976 +/* Allocated status of type object. If set to non-zero it means the object
977 + is allocated. A zero value means it is not allocated. */
978 +#define TYPE_NOT_ALLOCATED(t) (TYPE_ALLOCATED_PROP (t) \
979 + && TYPE_ALLOCATED_PROP (t)->kind == PROP_CONST \
980 + && !TYPE_ALLOCATED_PROP (t)->data.const_val)
982 +/* Associated status of type object. If set to non-zero it means the object
983 + is associated. A zero value means it is not associated. */
984 +#define TYPE_NOT_ASSOCIATED(t) (TYPE_ASSOCIATED_PROP (t) \
985 + && TYPE_ASSOCIATED_PROP (t)->kind == PROP_CONST \
986 + && !TYPE_ASSOCIATED_PROP (t)->data.const_val)
988 /* Attribute accessors for dynamic properties. */
989 #define TYPE_DYN_PROP_LIST(thistype) \
990 @@ -1283,6 +1322,9 @@ extern void allocate_gnat_aux_type (stru
991 TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
992 #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
993 TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
994 +#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \
995 + (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0)
998 #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
999 (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
1000 @@ -1764,6 +1806,7 @@ extern struct type *create_array_type_wi
1002 extern struct type *create_range_type (struct type *, struct type *,
1003 const struct dynamic_prop *,
1004 + const struct dynamic_prop *,
1005 const struct dynamic_prop *);
1007 extern struct type *create_array_type (struct type *, struct type *,
1008 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
1009 ===================================================================
1010 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1011 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp 2015-05-29 08:27:06.266740292 +0200
1013 +# Copyright 2014 Free Software Foundation, Inc.
1015 +# This program is free software; you can redistribute it and/or modify
1016 +# it under the terms of the GNU General Public License as published by
1017 +# the Free Software Foundation; either version 3 of the License, or
1018 +# (at your option) any later version.
1020 +# This program is distributed in the hope that it will be useful,
1021 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1022 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1023 +# GNU General Public License for more details.
1025 +# You should have received a copy of the GNU General Public License
1026 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1028 +standard_testfile "vla.f90"
1030 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1031 + {debug f90 quiet}] } {
1035 +if ![runto MAIN__] then {
1036 + perror "couldn't run to breakpoint MAIN__"
1040 +# Check the association status of various types of VLA's
1041 +# and pointer to VLA's.
1042 +gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
1043 +gdb_continue_to_breakpoint "vla1-allocated"
1044 +gdb_test "print l" " = \\.TRUE\\." \
1045 + "print vla1 allocation status (allocated)"
1047 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
1048 +gdb_continue_to_breakpoint "vla2-allocated"
1049 +gdb_test "print l" " = \\.TRUE\\." \
1050 + "print vla2 allocation status (allocated)"
1052 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
1053 +gdb_continue_to_breakpoint "pvla-associated"
1054 +gdb_test "print l" " = \\.TRUE\\." \
1055 + "print pvla associated status (associated)"
1057 +gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
1058 +gdb_continue_to_breakpoint "pvla-re-associated"
1059 +gdb_test "print l" " = \\.TRUE\\." \
1060 + "print pvla associated status (re-associated)"
1062 +gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
1063 +gdb_continue_to_breakpoint "pvla-deassociated"
1064 +gdb_test "print l" " = \\.FALSE\\." \
1065 + "print pvla allocation status (deassociated)"
1067 +gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
1068 +gdb_continue_to_breakpoint "vla1-deallocated"
1069 +gdb_test "print l" " = \\.FALSE\\." \
1070 + "print vla1 allocation status (deallocated)"
1071 +gdb_test "print vla1" " = <not allocated>" \
1072 + "print deallocated vla1"
1074 +gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
1075 +gdb_continue_to_breakpoint "vla2-deallocated"
1076 +gdb_test "print l" " = \\.FALSE\\." "print vla2 deallocated"
1077 +gdb_test "print vla2" " = <not allocated>" "print deallocated vla2"
1078 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-datatypes.exp
1079 ===================================================================
1080 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1081 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-datatypes.exp 2015-05-29 08:27:06.266740292 +0200
1083 +# Copyright 2014 Free Software Foundation, Inc.
1085 +# This program is free software; you can redistribute it and/or modify
1086 +# it under the terms of the GNU General Public License as published by
1087 +# the Free Software Foundation; either version 3 of the License, or
1088 +# (at your option) any later version.
1090 +# This program is distributed in the hope that it will be useful,
1091 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1092 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1093 +# GNU General Public License for more details.
1095 +# You should have received a copy of the GNU General Public License
1096 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1098 +standard_testfile ".f90"
1100 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1101 + {debug f90 quiet}] } {
1105 +# check that all fortran standard datatypes will be
1106 +# handled correctly when using as VLA's
1108 +if ![runto MAIN__] then {
1109 + perror "couldn't run to breakpoint MAIN__"
1113 +gdb_breakpoint [gdb_get_line_number "vlas-allocated"]
1114 +gdb_continue_to_breakpoint "vlas-allocated"
1115 +gdb_test "next" " = allocated\\\(realvla\\\)" \
1116 + "next to allocation status of intvla"
1117 +gdb_test "print l" " = \\.TRUE\\." "intvla allocated"
1118 +gdb_test "next" " = allocated\\\(complexvla\\\)" \
1119 + "next to allocation status of realvla"
1120 +gdb_test "print l" " = \\.TRUE\\." "realvla allocated"
1121 +gdb_test "next" " = allocated\\\(logicalvla\\\)" \
1122 + "next to allocation status of complexvla"
1123 +gdb_test "print l" " = \\.TRUE\\." "complexvla allocated"
1124 +gdb_test "next" " = allocated\\\(charactervla\\\)" \
1125 + "next to allocation status of logicalvla"
1126 +gdb_test "print l" " = \\.TRUE\\." "logicalvla allocated"
1127 +gdb_test "next" "intvla\\\(:,:,:\\\) = 1" \
1128 + "next to allocation status of charactervla"
1129 +gdb_test "print l" " = \\.TRUE\\." "charactervla allocated"
1131 +gdb_breakpoint [gdb_get_line_number "vlas-initialized"]
1132 +gdb_continue_to_breakpoint "vlas-initialized"
1133 +gdb_test "ptype intvla" "type = integer\\\(kind=4\\\) \\\(11,22,33\\\)" \
1135 +gdb_test "ptype realvla" "type = real\\\(kind=4\\\) \\\(11,22,33\\\)" \
1137 +gdb_test "ptype complexvla" "type = complex\\\(kind=4\\\) \\\(11,22,33\\\)" \
1138 + "ptype complexvla"
1139 +gdb_test "ptype logicalvla" "type = logical\\\(kind=4\\\) \\\(11,22,33\\\)" \
1140 + "ptype logicalvla"
1141 +gdb_test "ptype charactervla" "type = character\\\*1 \\\(11,22,33\\\)" \
1142 + "ptype charactervla"
1144 +gdb_test "print intvla(5,5,5)" " = 1" "print intvla(5,5,5) (1st)"
1145 +gdb_test "print realvla(5,5,5)" " = 3.14\\d+" \
1146 + "print realvla(5,5,5) (1st)"
1147 +gdb_test "print complexvla(5,5,5)" " = \\\(2,-3\\\)" \
1148 + "print complexvla(5,5,5) (1st)"
1149 +gdb_test "print logicalvla(5,5,5)" " = \\.TRUE\\." \
1150 + "print logicalvla(5,5,5) (1st)"
1151 +gdb_test "print charactervla(5,5,5)" " = 'K'" \
1152 + "print charactervla(5,5,5) (1st)"
1154 +gdb_breakpoint [gdb_get_line_number "vlas-modified"]
1155 +gdb_continue_to_breakpoint "vlas-modified"
1156 +gdb_test "print intvla(5,5,5)" " = 42" "print intvla(5,5,5) (2nd)"
1157 +gdb_test "print realvla(5,5,5)" " = 4.13\\d+" \
1158 + "print realvla(5,5,5) (2nd)"
1159 +gdb_test "print complexvla(5,5,5)" " = \\\(-3,2\\\)" \
1160 + "print complexvla(5,5,5) (2nd)"
1161 +gdb_test "print logicalvla(5,5,5)" " = \\.FALSE\\." \
1162 + "print logicalvla(5,5,5) (2nd)"
1163 +gdb_test "print charactervla(5,5,5)" " = 'X'" \
1164 + "print charactervla(5,5,5) (2nd)"
1165 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-datatypes.f90
1166 ===================================================================
1167 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1168 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-datatypes.f90 2015-05-29 08:27:06.266740292 +0200
1170 +! Copyright 2014 Free Software Foundation, Inc.
1172 +! This program is free software; you can redistribute it and/or modify
1173 +! it under the terms of the GNU General Public License as published by
1174 +! the Free Software Foundation; either version 2 of the License, or
1175 +! (at your option) any later version.
1177 +! This program is distributed in the hope that it will be useful,
1178 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1179 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1180 +! GNU General Public License for more details.
1182 +! You should have received a copy of the GNU General Public License
1183 +! along with this program; if not, write to the Free Software
1184 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1186 +program vla_primitives
1187 + integer, allocatable :: intvla(:, :, :)
1188 + real, allocatable :: realvla(:, :, :)
1189 + complex, allocatable :: complexvla(:, :, :)
1190 + logical, allocatable :: logicalvla(:, :, :)
1191 + character, allocatable :: charactervla(:, :, :)
1194 + allocate (intvla (11,22,33))
1195 + allocate (realvla (11,22,33))
1196 + allocate (complexvla (11,22,33))
1197 + allocate (logicalvla (11,22,33))
1198 + allocate (charactervla (11,22,33))
1200 + l = allocated(intvla) ! vlas-allocated
1201 + l = allocated(realvla)
1202 + l = allocated(complexvla)
1203 + l = allocated(logicalvla)
1204 + l = allocated(charactervla)
1207 + realvla(:,:,:) = 3.14
1208 + complexvla(:,:,:) = cmplx(2.0,-3.0)
1209 + logicalvla(:,:,:) = .TRUE.
1210 + charactervla(:,:,:) = char(75)
1212 + intvla(5,5,5) = 42 ! vlas-initialized
1213 + realvla(5,5,5) = 4.13
1214 + complexvla(5,5,5) = cmplx(-3.0,2.0)
1215 + logicalvla(5,5,5) = .FALSE.
1216 + charactervla(5,5,5) = 'X'
1218 + ! dummy statement for bp
1219 + l = .FALSE. ! vlas-modified
1220 +end program vla_primitives
1221 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-func.exp
1222 ===================================================================
1223 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1224 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-func.exp 2015-05-29 08:27:06.266740292 +0200
1226 +# Copyright 2014 Free Software Foundation, Inc.
1228 +# This program is free software; you can redistribute it and/or modify
1229 +# it under the terms of the GNU General Public License as published by
1230 +# the Free Software Foundation; either version 3 of the License, or
1231 +# (at your option) any later version.
1233 +# This program is distributed in the hope that it will be useful,
1234 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1235 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1236 +# GNU General Public License for more details.
1238 +# You should have received a copy of the GNU General Public License
1239 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1241 +standard_testfile ".f90"
1243 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1244 + {debug f90 quiet}] } {
1248 +if ![runto MAIN__] then {
1249 + perror "couldn't run to breakpoint MAIN__"
1253 +# Check VLA passed to first Fortran function.
1254 +gdb_breakpoint [gdb_get_line_number "func1-vla-passed"]
1255 +gdb_continue_to_breakpoint "func1-vla-passed"
1256 +gdb_test "print vla" " = \\( *\\( *22, *22, *22,\[()22, .\]*\\)" \
1257 + "print vla (func1)"
1258 +gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10,10\\\)" \
1259 + "ptype vla (func1)"
1261 +gdb_breakpoint [gdb_get_line_number "func1-vla-modified"]
1262 +gdb_continue_to_breakpoint "func1-vla-modified"
1263 +gdb_test "print vla(5,5)" " = 55" "print vla(5,5) (func1)"
1264 +gdb_test "print vla(7,7)" " = 77" "print vla(5,5) (func1)"
1266 +# Check if the values are correct after returning from func1
1267 +gdb_breakpoint [gdb_get_line_number "func1-returned"]
1268 +gdb_continue_to_breakpoint "func1-returned"
1269 +gdb_test "print ret" " = .TRUE." "print ret after func1 returned"
1271 +# Check VLA passed to second Fortran function
1272 +gdb_breakpoint [gdb_get_line_number "func2-vla-passed"]
1273 +gdb_continue_to_breakpoint "func2-vla-passed"
1274 +gdb_test "print vla" \
1275 + " = \\\(44, 44, 44, 44, 44, 44, 44, 44, 44, 44\\\)" \
1276 + "print vla (func2)"
1277 +gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
1278 + "ptype vla (func2)"
1280 +# Check if the returned VLA has the correct values and ptype.
1281 +gdb_breakpoint [gdb_get_line_number "func2-returned"]
1282 +gdb_continue_to_breakpoint "func2-returned"
1283 +gdb_test "print vla3" " = \\\(1, 2, 44, 4, 44, 44, 44, 8, 44, 44\\\)" \
1284 + "print vla3 (after func2)"
1285 +gdb_test "ptype vla3" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
1286 + "ptype vla3 (after func2)"
1287 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-func.f90
1288 ===================================================================
1289 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1290 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-func.f90 2015-05-29 08:27:06.267740298 +0200
1292 +! Copyright 2014 Free Software Foundation, Inc.
1294 +! This program is free software; you can redistribute it and/or modify
1295 +! it under the terms of the GNU General Public License as published by
1296 +! the Free Software Foundation; either version 2 of the License, or
1297 +! (at your option) any later version.
1299 +! This program is distributed in the hope that it will be useful,
1300 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1301 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1302 +! GNU General Public License for more details.
1304 +! You should have received a copy of the GNU General Public License
1305 +! along with this program; if not, write to the Free Software
1306 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1308 +logical function func1 (vla)
1310 + integer, allocatable :: vla (:, :)
1311 + func1 = allocated(vla)
1312 + vla(5,5) = 55 ! func1-vla-passed
1314 + return ! func1-vla-modified
1317 +function func2(vla)
1319 + integer :: vla (:)
1320 + integer :: func2(size(vla))
1323 + vla(1) = 1 ! func2-vla-passed
1334 + logical function func1 (vla)
1335 + integer :: vla (:, :)
1339 + function func2 (vla)
1340 + integer :: vla (:)
1341 + integer func2(size(vla))
1346 + integer, allocatable :: vla1 (:, :)
1347 + integer, allocatable :: vla2 (:)
1348 + integer, allocatable :: vla3 (:)
1352 + allocate (vla1 (10,10))
1355 + allocate (vla2 (10))
1359 + vla3 = func2(vla2) ! func1-returned
1361 + ret = .TRUE. ! func2-returned
1362 +end program vla_func
1363 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-history.exp
1364 ===================================================================
1365 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1366 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-history.exp 2015-05-29 08:27:06.267740298 +0200
1368 +# Copyright 2014 Free Software Foundation, Inc.
1370 +# This program is free software; you can redistribute it and/or modify
1371 +# it under the terms of the GNU General Public License as published by
1372 +# the Free Software Foundation; either version 3 of the License, or
1373 +# (at your option) any later version.
1375 +# This program is distributed in the hope that it will be useful,
1376 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1377 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1378 +# GNU General Public License for more details.
1380 +# You should have received a copy of the GNU General Public License
1381 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1383 +standard_testfile "vla.f90"
1385 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1386 + {debug f90 quiet}] } {
1390 +if ![runto MAIN__] then {
1391 + perror "couldn't run to breakpoint MAIN__"
1395 +# Set some breakpoints and print complete vla.
1396 +gdb_breakpoint [gdb_get_line_number "vla1-init"]
1397 +gdb_continue_to_breakpoint "vla1-init"
1398 +gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
1400 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
1401 +gdb_continue_to_breakpoint "vla2-allocated"
1402 +gdb_test "print vla1" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
1403 + "print vla1 allocated"
1404 +gdb_test "print vla2" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
1405 + "print vla2 allocated"
1407 +gdb_breakpoint [gdb_get_line_number "vla1-filled"]
1408 +gdb_continue_to_breakpoint "vla1-filled"
1409 +gdb_test "print vla1" \
1410 + " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" \
1411 + "print vla1 filled"
1413 +# Try to access history values for full vla prints.
1414 +gdb_test "print \$1" " = <not allocated>" "print \$1"
1415 +gdb_test "print \$2" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
1417 +gdb_test "print \$3" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
1419 +gdb_test "print \$4" \
1420 + " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" "print \$4"
1422 +gdb_breakpoint [gdb_get_line_number "vla2-filled"]
1423 +gdb_continue_to_breakpoint "vla2-filled"
1424 +gdb_test "print vla2(1,43,20)" " = 1311" "print vla2(1,43,20)"
1425 +gdb_test "print vla1(1,3,8)" " = 1001" "print vla2(1,3,8)"
1427 +# Try to access history values for vla values.
1428 +gdb_test "print \$9" " = 1311" "print \$9"
1429 +gdb_test "print \$10" " = 1001" "print \$10"
1430 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
1431 ===================================================================
1432 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1433 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp 2015-05-29 08:27:06.267740298 +0200
1435 +# Copyright 2014 Free Software Foundation, Inc.
1437 +# This program is free software; you can redistribute it and/or modify
1438 +# it under the terms of the GNU General Public License as published by
1439 +# the Free Software Foundation; either version 3 of the License, or
1440 +# (at your option) any later version.
1442 +# This program is distributed in the hope that it will be useful,
1443 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1444 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1445 +# GNU General Public License for more details.
1447 +# You should have received a copy of the GNU General Public License
1448 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1450 +standard_testfile "vla-sub.f90"
1452 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1453 + {debug f90 quiet}] } {
1457 +if ![runto MAIN__] then {
1458 + perror "couldn't run to breakpoint MAIN__"
1462 +# Pass fixed array to function and handle them as vla in function.
1463 +gdb_breakpoint [gdb_get_line_number "not-filled"]
1464 +gdb_continue_to_breakpoint "not-filled (1st)"
1465 +gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(42,42\\\)" \
1466 + "ptype array1 (passed fixed)"
1467 +gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(42,42,42\\\)" \
1468 + "ptype array2 (passed fixed)"
1469 +gdb_test "ptype array1(40, 10)" "type = integer\\\(kind=4\\\)" \
1470 + "ptype array1(40, 10) (passed fixed)"
1471 +gdb_test "ptype array2(13, 11, 5)" "type = real\\\(kind=4\\\)" \
1472 + "ptype array2(13, 11, 5) (passed fixed)"
1474 +# Pass sub arrays to function and handle them as vla in function.
1475 +gdb_continue_to_breakpoint "not-filled (2nd)"
1476 +gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(6,6\\\)" \
1477 + "ptype array1 (passed sub-array)"
1478 +gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(6,6,6\\\)" \
1479 + "ptype array2 (passed sub-array)"
1480 +gdb_test "ptype array1(3, 3)" "type = integer\\\(kind=4\\\)" \
1481 + "ptype array1(3, 3) (passed sub-array)"
1482 +gdb_test "ptype array2(4, 4, 4)" "type = real\\\(kind=4\\\)" \
1483 + "ptype array2(4, 4, 4) (passed sub-array)"
1485 +# Check ptype outside of bounds. This should not crash GDB.
1486 +gdb_test "ptype array1(100, 100)" "no such vector element" \
1487 + "ptype array1(100, 100) subarray do not crash (passed sub-array)"
1488 +gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
1489 + "ptype array2(100, 100, 100) subarray do not crash (passed sub-array)"
1491 +# Pass vla to function.
1492 +gdb_continue_to_breakpoint "not-filled (3rd)"
1493 +gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(20,20\\\)" \
1494 + "ptype array1 (passed vla)"
1495 +gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
1496 + "ptype array2 (passed vla)"
1497 +gdb_test "ptype array1(3, 3)" "type = integer\\\(kind=4\\\)" \
1498 + "ptype array1(3, 3) (passed vla)"
1499 +gdb_test "ptype array2(4, 4, 4)" "type = real\\\(kind=4\\\)" \
1500 + "ptype array2(4, 4, 4) (passed vla)"
1502 +# Check ptype outside of bounds. This should not crash GDB.
1503 +gdb_test "ptype array1(100, 100)" "no such vector element" \
1504 + "ptype array1(100, 100) VLA do not crash (passed vla)"
1505 +gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
1506 + "ptype array2(100, 100, 100) VLA do not crash (passed vla)"
1508 +# Pass fixed array to function and handle it as VLA of arbitrary length in
1510 +gdb_breakpoint [gdb_get_line_number "end-of-bar"]
1511 +gdb_continue_to_breakpoint "end-of-bar"
1512 +gdb_test "ptype array1" \
1513 + "type = (PTR TO -> \\( )?integer(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" \
1514 + "ptype array1 (arbitrary length)"
1515 +gdb_test "ptype array2" \
1516 + "type = (PTR TO -> \\( )?integer(\\(kind=4\\)|\\*4) \\(4:9,10:\\*\\)\\)?" \
1517 + "ptype array2 (arbitrary length)"
1518 +gdb_test "ptype array1(100)" "type = integer\\\(kind=4\\\)" \
1519 + "ptype array1(100) (arbitrary length)"
1520 +gdb_test "ptype array2(4,100)" "type = integer\\\(kind=4\\\)" \
1521 + "ptype array2(4,100) (arbitrary length)"
1522 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-ptype.exp
1523 ===================================================================
1524 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1525 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-ptype.exp 2015-05-29 08:27:06.267740298 +0200
1527 +# Copyright 2014 Free Software Foundation, Inc.
1529 +# This program is free software; you can redistribute it and/or modify
1530 +# it under the terms of the GNU General Public License as published by
1531 +# the Free Software Foundation; either version 3 of the License, or
1532 +# (at your option) any later version.
1534 +# This program is distributed in the hope that it will be useful,
1535 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1536 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1537 +# GNU General Public License for more details.
1539 +# You should have received a copy of the GNU General Public License
1540 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1542 +standard_testfile "vla.f90"
1544 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1545 + {debug f90 quiet}] } {
1549 +if ![runto MAIN__] then {
1550 + perror "couldn't run to breakpoint MAIN__"
1554 +# Check the ptype of various VLA states and pointer to VLA's.
1555 +gdb_breakpoint [gdb_get_line_number "vla1-init"]
1556 +gdb_continue_to_breakpoint "vla1-init"
1557 +gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not initialized"
1558 +gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not initialized"
1559 +gdb_test "ptype pvla" "type = <not associated>" "ptype pvla not initialized"
1560 +gdb_test "ptype vla1(3, 6, 9)" "no such vector element because not allocated" \
1561 + "ptype vla1(3, 6, 9) not initialized"
1562 +gdb_test "ptype vla2(5, 45, 20)" \
1563 + "no such vector element because not allocated" \
1564 + "ptype vla1(5, 45, 20) not initialized"
1566 +gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
1567 +gdb_continue_to_breakpoint "vla1-allocated"
1568 +gdb_test "ptype vla1" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
1569 + "ptype vla1 allocated"
1571 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
1572 +gdb_continue_to_breakpoint "vla2-allocated"
1573 +gdb_test "ptype vla2" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
1574 + "ptype vla2 allocated"
1576 +gdb_breakpoint [gdb_get_line_number "vla1-filled"]
1577 +gdb_continue_to_breakpoint "vla1-filled"
1578 +gdb_test "ptype vla1" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
1579 + "ptype vla1 filled"
1580 +gdb_test "ptype vla1(3, 6, 9)" "type = real\\\(kind=4\\\)" \
1581 + "ptype vla1(3, 6, 9)"
1583 +gdb_breakpoint [gdb_get_line_number "vla2-filled"]
1584 +gdb_continue_to_breakpoint "vla2-filled"
1585 +gdb_test "ptype vla2" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
1586 + "ptype vla2 filled"
1587 +gdb_test "ptype vla2(5, 45, 20)" "type = real\\\(kind=4\\\)" \
1588 + "ptype vla1(5, 45, 20) filled"
1590 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
1591 +gdb_continue_to_breakpoint "pvla-associated"
1592 +gdb_test "ptype pvla" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
1593 + "ptype pvla associated"
1594 +gdb_test "ptype pvla(3, 6, 9)" "type = real\\\(kind=4\\\)" \
1595 + "ptype pvla(3, 6, 9)"
1597 +gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
1598 +gdb_continue_to_breakpoint "pvla-re-associated"
1599 +gdb_test "ptype pvla" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
1600 + "ptype pvla re-associated"
1601 +gdb_test "ptype vla2(5, 45, 20)" "type = real\\\(kind=4\\\)" \
1602 + "ptype vla1(5, 45, 20) re-associated"
1604 +gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
1605 +gdb_continue_to_breakpoint "pvla-deassociated"
1606 +gdb_test "ptype pvla" "type = <not associated>" "ptype pvla deassociated"
1607 +gdb_test "ptype pvla(5, 45, 20)" \
1608 + "no such vector element because not associated" \
1609 + "ptype pvla(5, 45, 20) not associated"
1611 +gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
1612 +gdb_continue_to_breakpoint "vla1-deallocated"
1613 +gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not allocated"
1614 +gdb_test "ptype vla1(3, 6, 9)" "no such vector element because not allocated" \
1615 + "ptype vla1(3, 6, 9) not allocated"
1617 +gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
1618 +gdb_continue_to_breakpoint "vla2-deallocated"
1619 +gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not allocated"
1620 +gdb_test "ptype vla2(5, 45, 20)" \
1621 + "no such vector element because not allocated" \
1622 + "ptype vla2(5, 45, 20) not allocated"
1623 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-sizeof.exp
1624 ===================================================================
1625 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1626 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-sizeof.exp 2015-05-29 08:27:06.267740298 +0200
1628 +# Copyright 2014 Free Software Foundation, Inc.
1630 +# This program is free software; you can redistribute it and/or modify
1631 +# it under the terms of the GNU General Public License as published by
1632 +# the Free Software Foundation; either version 3 of the License, or
1633 +# (at your option) any later version.
1635 +# This program is distributed in the hope that it will be useful,
1636 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1637 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1638 +# GNU General Public License for more details.
1640 +# You should have received a copy of the GNU General Public License
1641 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1643 +standard_testfile "vla.f90"
1645 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1646 + {debug f90 quiet}] } {
1650 +if ![runto MAIN__] then {
1651 + perror "couldn't run to breakpoint MAIN__"
1655 +# Try to access values in non allocated VLA
1656 +gdb_breakpoint [gdb_get_line_number "vla1-init"]
1657 +gdb_continue_to_breakpoint "vla1-init"
1658 +gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1"
1660 +# Try to access value in allocated VLA
1661 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
1662 +gdb_continue_to_breakpoint "vla2-allocated"
1663 +gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1"
1665 +# Try to access values in undefined pointer to VLA (dangling)
1666 +gdb_breakpoint [gdb_get_line_number "vla1-filled"]
1667 +gdb_continue_to_breakpoint "vla1-filled"
1668 +gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
1670 +# Try to access values in pointer to VLA and compare them
1671 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
1672 +gdb_continue_to_breakpoint "pvla-associated"
1673 +gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
1674 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-stride.exp
1675 ===================================================================
1676 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1677 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-stride.exp 2015-05-29 08:27:06.267740298 +0200
1679 +# Copyright 2014 Free Software Foundation, Inc.
1681 +# This program is free software; you can redistribute it and/or modify
1682 +# it under the terms of the GNU General Public License as published by
1683 +# the Free Software Foundation; either version 3 of the License, or
1684 +# (at your option) any later version.
1686 +# This program is distributed in the hope that it will be useful,
1687 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1688 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1689 +# GNU General Public License for more details.
1691 +# You should have received a copy of the GNU General Public License
1692 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1694 +standard_testfile ".f90"
1696 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1697 + {debug f90 quiet}] } {
1701 +if ![runto MAIN__] then {
1702 + perror "couldn't run to breakpoint MAIN__"
1706 +gdb_breakpoint [gdb_get_line_number "re-reverse-elements"]
1707 +gdb_continue_to_breakpoint "re-reverse-elements"
1708 +gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \
1709 + "print re-reverse-elements"
1710 +gdb_test "print pvla(1)" " = 1" "print first re-reverse-element"
1711 +gdb_test "print pvla(10)" " = 10" "print last re-reverse-element"
1713 +gdb_breakpoint [gdb_get_line_number "odd-elements"]
1714 +gdb_continue_to_breakpoint "odd-elements"
1715 +gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements"
1716 +gdb_test "print pvla(1)" " = 1" "print first odd-element"
1717 +gdb_test "print pvla(5)" " = 9" "print last odd-element"
1719 +gdb_breakpoint [gdb_get_line_number "single-element"]
1720 +gdb_continue_to_breakpoint "single-element"
1721 +gdb_test "print pvla" " = \\\(5\\\)" "print single-element"
1722 +gdb_test "print pvla(1)" " = 5" "print one single-element"
1723 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-stride.f90
1724 ===================================================================
1725 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1726 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-stride.f90 2015-05-29 08:27:06.268740305 +0200
1728 +! Copyright 2014 Free Software Foundation, Inc.
1730 +! This program is free software; you can redistribute it and/or modify
1731 +! it under the terms of the GNU General Public License as published by
1732 +! the Free Software Foundation; either version 2 of the License, or
1733 +! (at your option) any later version.
1735 +! This program is distributed in the hope that it will be useful,
1736 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1737 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1738 +! GNU General Public License for more details.
1740 +! You should have received a copy of the GNU General Public License
1741 +! along with this program; if not, write to the Free Software
1742 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1745 + integer, target, allocatable :: vla (:)
1746 + integer, pointer :: pvla (:)
1749 + vla = (/ (I, I = 1,10) /)
1751 + pvla => vla(10:1:-1)
1752 + pvla => pvla(10:1:-1)
1753 + pvla => vla(1:10:2) ! re-reverse-elements
1754 + pvla => vla(5:4:-2) ! odd-elements
1756 + pvla => null() ! single-element
1757 +end program vla_stride
1758 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-strings.exp
1759 ===================================================================
1760 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1761 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-strings.exp 2015-05-29 08:27:06.268740305 +0200
1763 +# Copyright 2014 Free Software Foundation, Inc.
1765 +# This program is free software; you can redistribute it and/or modify
1766 +# it under the terms of the GNU General Public License as published by
1767 +# the Free Software Foundation; either version 3 of the License, or
1768 +# (at your option) any later version.
1770 +# This program is distributed in the hope that it will be useful,
1771 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1772 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1773 +# GNU General Public License for more details.
1775 +# You should have received a copy of the GNU General Public License
1776 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
1778 +standard_testfile ".f90"
1780 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
1781 + {debug f90 quiet}] } {
1785 +# check that all fortran standard datatypes will be
1786 +# handled correctly when using as VLA's
1788 +if ![runto MAIN__] then {
1789 + perror "couldn't run to breakpoint MAIN__"
1793 +gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
1794 +gdb_continue_to_breakpoint "var_char-allocated-1"
1795 +gdb_test "print var_char" \
1796 + " = \\(PTR TO -> \\( character\\*10 \\)\\) ${hex}" \
1797 + "print var_char after allocated first time"
1798 +gdb_test "print *var_char" \
1799 + " = '\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000'" \
1800 + "print *var_char after allocated first time"
1801 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*10 \\)" \
1802 + "whatis var_char first time"
1803 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*10 \\)" \
1804 + "ptype var_char first time"
1805 +gdb_test "next" "\\d+.*var_char = 'foo'.*" \
1806 + "next to allocation status of var_char"
1807 +gdb_test "print l" " = .TRUE." "print allocation status first time"
1809 +gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
1810 +gdb_continue_to_breakpoint "var_char-filled-1"
1811 +gdb_test "print var_char" \
1812 + " = \\(PTR TO -> \\( character\\*3 \\)\\) ${hex}" \
1813 + "print var_char after filled first time"
1814 +gdb_test "print *var_char" " = 'foo'" \
1815 + "print *var_char after filled first time"
1816 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*3 \\)" \
1817 + "whatis var_char after filled first time"
1818 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*3 \\)" \
1819 + "ptype var_char after filled first time"
1820 +gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
1821 +gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
1823 +gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
1824 +gdb_continue_to_breakpoint "var_char-filled-2"
1825 +gdb_test "print var_char" \
1826 + " = \\(PTR TO -> \\( character\\*6 \\)\\) ${hex}" \
1827 + "print var_char after allocated second time"
1828 +gdb_test "print *var_char" " = 'foobar'" \
1829 + "print *var_char after allocated second time"
1830 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*6 \\)" \
1831 + "whatis var_char second time"
1832 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*6 \\)" \
1833 + "ptype var_char second time"
1835 +gdb_breakpoint [gdb_get_line_number "var_char-empty"]
1836 +gdb_continue_to_breakpoint "var_char-empty"
1837 +gdb_test "print var_char" \
1838 + " = \\(PTR TO -> \\( character\\*0 \\)\\) ${hex}" \
1839 + "print var_char after set empty"
1840 +gdb_test "print *var_char" " = \"\"" "print *var_char after set empty"
1841 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*0 \\)" \
1842 + "whatis var_char after set empty"
1843 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*0 \\)" \
1844 + "ptype var_char after set empty"
1846 +gdb_breakpoint [gdb_get_line_number "var_char-allocated-3"]
1847 +gdb_continue_to_breakpoint "var_char-allocated-3"
1848 +gdb_test "print var_char" \
1849 + " = \\(PTR TO -> \\( character\\*21 \\)\\) ${hex}" \
1850 + "print var_char after allocated third time"
1851 +gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*21 \\)" \
1852 + "whatis var_char after allocated third time"
1853 +gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*21 \\)" \
1854 + "ptype var_char after allocated third time"
1856 +gdb_breakpoint [gdb_get_line_number "var_char_p-associated"]
1857 +gdb_continue_to_breakpoint "var_char_p-associated"
1858 +gdb_test "print var_char_p" \
1859 + " = \\(PTR TO -> \\( character\\*7 \\)\\) ${hex}" \
1860 + "print var_char_p after associated"
1861 +gdb_test "print *var_char_p" " = 'johndoe'" \
1862 + "print *var_char_ after associated"
1863 +gdb_test "whatis var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
1864 + "whatis var_char_p after associated"
1865 +gdb_test "ptype var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
1866 + "ptype var_char_p after associated"
1867 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-strings.f90
1868 ===================================================================
1869 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1870 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-strings.f90 2015-05-31 15:25:01.305615755 +0200
1872 +! Copyright 2014 Free Software Foundation, Inc.
1874 +! This program is free software; you can redistribute it and/or modify
1875 +! it under the terms of the GNU General Public License as published by
1876 +! the Free Software Foundation; either version 2 of the License, or
1877 +! (at your option) any later version.
1879 +! This program is distributed in the hope that it will be useful,
1880 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1881 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1882 +! GNU General Public License for more details.
1884 +! You should have received a copy of the GNU General Public License
1885 +! along with this program; if not, write to the Free Software
1886 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1888 +program vla_strings
1889 + character(len=:), target, allocatable :: var_char
1890 + character(len=:), pointer :: var_char_p
1893 + allocate(character(len=10) :: var_char)
1894 + l = allocated(var_char) ! var_char-allocated-1
1896 + deallocate(var_char) ! var_char-filled-1
1897 + l = allocated(var_char) ! var_char-deallocated
1898 + allocate(character(len=42) :: var_char)
1899 + l = allocated(var_char)
1900 + var_char = 'foobar'
1901 + var_char = '' ! var_char-filled-2
1902 + var_char = 'bar' ! var_char-empty
1903 + deallocate(var_char)
1904 + allocate(character(len=21) :: var_char)
1905 + l = allocated(var_char) ! var_char-allocated-3
1906 + var_char = 'johndoe'
1907 + var_char_p => var_char
1908 + l = associated(var_char_p) ! var_char_p-associated
1909 + var_char_p => null()
1910 + l = associated(var_char_p) ! var_char_p-not-associated
1911 +end program vla_strings
1912 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-sub.f90
1913 ===================================================================
1914 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1915 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-sub.f90 2015-05-29 08:27:06.268740305 +0200
1917 +! Copyright 2014 Free Software Foundation, Inc.
1919 +! This program is free software; you can redistribute it and/or modify
1920 +! it under the terms of the GNU General Public License as published by
1921 +! the Free Software Foundation; either version 2 of the License, or
1922 +! (at your option) any later version.
1924 +! This program is distributed in the hope that it will be useful,
1925 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
1926 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1927 +! GNU General Public License for more details.
1929 +! You should have received a copy of the GNU General Public License
1930 +! along with this program; if not, write to the Free Software
1931 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1933 +! Original file written by Jakub Jelinek <jakub@redhat.com> and
1934 +! Jan Kratochvil <jan.kratochvil@redhat.com>.
1935 +! Modified for the GDB testcases by Keven Boell <keven.boell@intel.com>.
1937 +subroutine foo (array1, array2)
1938 + integer :: array1 (:, :)
1939 + real :: array2 (:, :, :)
1941 + array1(:,:) = 5 ! not-filled
1944 + array2(:,:,:) = 6 ! array1-filled
1946 + array2(1,1,1) = 30
1947 + array2(3,3,3) = 90 ! array2-almost-filled
1950 +subroutine bar (array1, array2)
1951 + integer :: array1 (*)
1952 + integer :: array2 (4:9, 10:*)
1954 + array1(5:10) = 1311
1957 + array2(4,10) = array1(7)
1958 + array2(4,100) = array1(7)
1959 + return ! end-of-bar
1964 + subroutine foo (array1, array2)
1965 + integer :: array1 (:, :)
1966 + real :: array2 (:, :, :)
1970 + subroutine bar (array1, array2)
1971 + integer :: array1 (*)
1972 + integer :: array2 (4:9, 10:*)
1976 + real, allocatable :: vla1 (:, :, :)
1977 + integer, allocatable :: vla2 (:, :)
1979 + ! used for subroutine
1980 + integer :: sub_arr1(42, 42)
1981 + real :: sub_arr2(42, 42, 42)
1982 + integer :: sub_arr3(42)
1984 + sub_arr1(:,:) = 1 ! vla2-deallocated
1985 + sub_arr2(:,:,:) = 2
1988 + call foo(sub_arr1, sub_arr2)
1989 + call foo(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))
1991 + allocate (vla1 (10,10,10))
1992 + allocate (vla2 (20,20))
1993 + vla1(:,:,:) = 1311
1995 + call foo(vla2, vla1)
1997 + call bar(sub_arr3, sub_arr1)
1998 +end program vla_sub
1999 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
2000 ===================================================================
2001 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2002 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp 2015-05-29 08:27:06.268740305 +0200
2004 +# Copyright 2014 Free Software Foundation, Inc.
2006 +# This program is free software; you can redistribute it and/or modify
2007 +# it under the terms of the GNU General Public License as published by
2008 +# the Free Software Foundation; either version 3 of the License, or
2009 +# (at your option) any later version.
2011 +# This program is distributed in the hope that it will be useful,
2012 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2013 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2014 +# GNU General Public License for more details.
2016 +# You should have received a copy of the GNU General Public License
2017 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2019 +standard_testfile "vla-sub.f90"
2021 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
2022 + {debug f90 quiet}] } {
2026 +if ![runto MAIN__] then {
2027 + perror "couldn't run to breakpoint MAIN__"
2031 +# Check VLA with arbitary length and check that elements outside of
2032 +# bounds of the passed VLA can be accessed correctly.
2033 +gdb_breakpoint [gdb_get_line_number "end-of-bar"]
2034 +gdb_continue_to_breakpoint "end-of-bar"
2035 +gdb_test "p array1(42)" " = 3" "print arbitary array1(42)"
2036 +gdb_test "p array1(100)" " = 100" "print arbitary array1(100)"
2037 +gdb_test "p array2(4,10)" " = 1" "print arbitary array2(4,10)"
2038 +gdb_test "p array2(4,100)" " = 1" "print arbitary array2(4,100)"
2039 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
2040 ===================================================================
2041 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2042 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp 2015-05-29 08:27:06.268740305 +0200
2044 +# Copyright 2014 Free Software Foundation, Inc.
2046 +# This program is free software; you can redistribute it and/or modify
2047 +# it under the terms of the GNU General Public License as published by
2048 +# the Free Software Foundation; either version 3 of the License, or
2049 +# (at your option) any later version.
2051 +# This program is distributed in the hope that it will be useful,
2052 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2053 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2054 +# GNU General Public License for more details.
2056 +# You should have received a copy of the GNU General Public License
2057 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2059 +standard_testfile "vla-sub.f90"
2061 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
2062 + {debug f90 quiet}] } {
2066 +if ![runto MAIN__] then {
2067 + perror "couldn't run to breakpoint MAIN__"
2071 +# "up" works with GCC but other Fortran compilers may copy the values into the
2072 +# outer function only on the exit of the inner function.
2073 +# We need both variants as depending on the arch we optionally may still be
2074 +# executing the caller line or not after `finish'.
2076 +gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
2077 +gdb_continue_to_breakpoint "array2-almost-filled"
2078 +gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
2079 + "print array2 in foo after it was filled"
2080 +gdb_test "print array2(2,1,1)=20" " = 20" \
2081 + "set array(2,2,2) to 20 in subroutine"
2082 +gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
2083 + "print array2 in foo after it was mofified in debugger"
2085 +gdb_test "finish" \
2086 + ".*foo\\\(sub_arr1\\\(5:10, 5:10\\\), sub_arr2\\\(10:15,10:15,10:15\\\)\\\)" \
2088 +gdb_test "p sub_arr1(5, 7)" " = 5" "sub_arr1(5, 7) after finish"
2089 +gdb_test "p sub_arr1(1, 1)" " = 30" "sub_arr1(1, 1) after finish"
2090 +gdb_test "p sub_arr2(1, 1, 1)" " = 30" "sub_arr2(1, 1, 1) after finish"
2091 +gdb_test "p sub_arr2(2, 1, 1)" " = 20" "sub_arr2(2, 1, 1) after finish"
2093 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-value-sub.exp
2094 ===================================================================
2095 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2096 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-value-sub.exp 2015-05-29 08:27:06.269740311 +0200
2098 +# Copyright 2014 Free Software Foundation, Inc.
2100 +# This program is free software; you can redistribute it and/or modify
2101 +# it under the terms of the GNU General Public License as published by
2102 +# the Free Software Foundation; either version 3 of the License, or
2103 +# (at your option) any later version.
2105 +# This program is distributed in the hope that it will be useful,
2106 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2107 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2108 +# GNU General Public License for more details.
2110 +# You should have received a copy of the GNU General Public License
2111 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2113 +standard_testfile "vla-sub.f90"
2115 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
2116 + {debug f90 quiet}] } {
2120 +if ![runto MAIN__] then {
2121 + perror "couldn't run to breakpoint MAIN__"
2125 +# Check the values of VLA's in subroutine can be evaluated correctly
2127 +# Try to access values from a fixed array handled as VLA in subroutine.
2128 +gdb_breakpoint [gdb_get_line_number "not-filled"]
2129 +gdb_continue_to_breakpoint "not-filled (1st)"
2130 +gdb_test "print array1" " = \\(\[()1, .\]*\\)" \
2131 + "print passed array1 in foo (passed fixed array)"
2133 +gdb_breakpoint [gdb_get_line_number "array1-filled"]
2134 +gdb_continue_to_breakpoint "array1-filled (1st)"
2135 +gdb_test "print array1(5, 7)" " = 5" \
2136 + "print array1(5, 7) after filled in foo (passed fixed array)"
2137 +gdb_test "print array1(1, 1)" " = 30" \
2138 + "print array1(1, 1) after filled in foo (passed fixed array)"
2140 +gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
2141 +gdb_continue_to_breakpoint "array2-almost-filled (1st)"
2142 +gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
2143 + "print array2 in foo after it was filled (passed fixed array)"
2144 +gdb_test "print array2(2,1,1)=20" " = 20" \
2145 + "set array(2,2,2) to 20 in subroutine (passed fixed array)"
2146 +gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
2147 + "print array2 in foo after it was mofified in debugger (passed fixed array)"
2150 +# Try to access values from a fixed sub-array handled as VLA in subroutine.
2151 +gdb_continue_to_breakpoint "not-filled (2nd)"
2152 +gdb_test "print array1" " = \\(\[()5, .\]*\\)" \
2153 + "print passed array1 in foo (passed sub-array)"
2155 +gdb_continue_to_breakpoint "array1-filled (2nd)"
2156 +gdb_test "print array1(5, 5)" " = 5" \
2157 + "print array1(5, 5) after filled in foo (passed sub-array)"
2158 +gdb_test "print array1(1, 1)" " = 30" \
2159 + "print array1(1, 1) after filled in foo (passed sub-array)"
2161 +gdb_continue_to_breakpoint "array2-almost-filled (2nd)"
2162 +gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
2163 + "print array2 in foo after it was filled (passed sub-array)"
2164 +gdb_test "print array2(2,1,1)=20" " = 20" \
2165 + "set array(2,2,2) to 20 in subroutine (passed sub-array)"
2166 +gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
2167 + "print array2 in foo after it was mofified in debugger (passed sub-array)"
2170 +# Try to access values from a VLA passed to subroutine.
2171 +gdb_continue_to_breakpoint "not-filled (3rd)"
2172 +gdb_test "print array1" " = \\(\[()42, .\]*\\)" \
2173 + "print passed array1 in foo (passed vla)"
2175 +gdb_continue_to_breakpoint "array1-filled (3rd)"
2176 +gdb_test "print array1(5, 5)" " = 5" \
2177 + "print array1(5, 5) after filled in foo (passed vla)"
2178 +gdb_test "print array1(1, 1)" " = 30" \
2179 + "print array1(1, 1) after filled in foo (passed vla)"
2181 +gdb_continue_to_breakpoint "array2-almost-filled (3rd)"
2182 +gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
2183 + "print array2 in foo after it was filled (passed vla)"
2184 +gdb_test "print array2(2,1,1)=20" " = 20" \
2185 + "set array(2,2,2) to 20 in subroutine (passed vla)"
2186 +gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
2187 + "print array2 in foo after it was mofified in debugger (passed vla)"
2188 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-value.exp
2189 ===================================================================
2190 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2191 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla-value.exp 2015-05-29 08:27:06.269740311 +0200
2193 +# Copyright 2014 Free Software Foundation, Inc.
2195 +# This program is free software; you can redistribute it and/or modify
2196 +# it under the terms of the GNU General Public License as published by
2197 +# the Free Software Foundation; either version 3 of the License, or
2198 +# (at your option) any later version.
2200 +# This program is distributed in the hope that it will be useful,
2201 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2202 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2203 +# GNU General Public License for more details.
2205 +# You should have received a copy of the GNU General Public License
2206 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2208 +standard_testfile "vla.f90"
2210 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
2211 + {debug f90 quiet}] } {
2215 +if ![runto MAIN__] then {
2216 + perror "couldn't run to breakpoint MAIN__"
2220 +# Try to access values in non allocated VLA
2221 +gdb_breakpoint [gdb_get_line_number "vla1-init"]
2222 +gdb_continue_to_breakpoint "vla1-init"
2223 +gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
2224 +gdb_test "print &vla1" \
2225 + " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not allocated>\\\)\\\)\\\) $hex" \
2226 + "print non-allocated &vla1"
2227 +gdb_test "print vla1(1,1,1)" "no such vector element because not allocated" \
2228 + "print member in non-allocated vla1 (1)"
2229 +gdb_test "print vla1(101,202,303)" \
2230 + "no such vector element because not allocated" \
2231 + "print member in non-allocated vla1 (2)"
2232 +gdb_test "print vla1(5,2,18)=1" "no such vector element because not allocated" \
2233 + "set member in non-allocated vla1"
2235 +# Try to access value in allocated VLA
2236 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
2237 +gdb_continue_to_breakpoint "vla2-allocated"
2238 +gdb_test "next" "\\d+(\\t|\\s)+vla1\\\(3, 6, 9\\\) = 42" \
2239 + "step over value assignment of vla1"
2240 +gdb_test "print &vla1" \
2241 + " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
2242 + "print allocated &vla1"
2243 +gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
2244 +gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
2245 +gdb_test "print vla1(9, 9, 9) = 999" " = 999" \
2246 + "print allocated vla1(9,9,9)=1"
2248 +# Try to access values in allocated VLA after specific assignment
2249 +gdb_breakpoint [gdb_get_line_number "vla1-filled"]
2250 +gdb_continue_to_breakpoint "vla1-filled"
2251 +gdb_test "print vla1(3, 6, 9)" " = 42" \
2252 + "print allocated vla1(3,6,9) after specific assignment (filled)"
2253 +gdb_test "print vla1(1, 3, 8)" " = 1001" \
2254 + "print allocated vla1(1,3,8) after specific assignment (filled)"
2255 +gdb_test "print vla1(9, 9, 9)" " = 999" \
2256 + "print allocated vla1(9,9,9) after assignment in debugger (filled)"
2258 +# Try to access values in undefined pointer to VLA (dangling)
2259 +gdb_test "print pvla" " = <not associated>" "print undefined pvla"
2260 +gdb_test "print &pvla" \
2261 + " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not associated>\\\)\\\)\\\) $hex" \
2262 + "print non-associated &pvla"
2263 +gdb_test "print pvla(1, 3, 8)" "no such vector element because not associated" \
2264 + "print undefined pvla(1,3,8)"
2266 +# Try to access values in pointer to VLA and compare them
2267 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
2268 +gdb_continue_to_breakpoint "pvla-associated"
2269 +gdb_test "print &pvla" \
2270 + " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
2271 + "print associated &pvla"
2272 +gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
2273 +gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
2274 +gdb_test "print pvla(9, 9, 9)" " = 999" "print associated pvla(9,9,9)"
2276 +# Fill values to VLA using pointer and check
2277 +gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
2278 +gdb_continue_to_breakpoint "pvla-re-associated"
2279 +gdb_test "print pvla(5, 45, 20)" \
2280 + " = 1" "print pvla(5, 45, 20) after filled using pointer"
2281 +gdb_test "print vla2(5, 45, 20)" \
2282 + " = 1" "print vla2(5, 45, 20) after filled using pointer"
2283 +gdb_test "print pvla(7, 45, 14)" " = 2" \
2284 + "print pvla(7, 45, 14) after filled using pointer"
2285 +gdb_test "print vla2(7, 45, 14)" " = 2" \
2286 + "print vla2(7, 45, 14) after filled using pointer"
2288 +# Try to access values of deassociated VLA pointer
2289 +gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
2290 +gdb_continue_to_breakpoint "pvla-deassociated"
2291 +gdb_test "print pvla(5, 45, 20)" \
2292 + "no such vector element because not associated" \
2293 + "print pvla(5, 45, 20) after deassociated"
2294 +gdb_test "print pvla(7, 45, 14)" \
2295 + "no such vector element because not associated" \
2296 + "print pvla(7, 45, 14) after dissasociated"
2297 +gdb_test "print pvla" " = <not associated>" \
2298 + "print vla1 after deassociated"
2300 +# Try to access values of deallocated VLA
2301 +gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
2302 +gdb_continue_to_breakpoint "vla1-deallocated"
2303 +gdb_test "print vla1(3, 6, 9)" "no such vector element because not allocated" \
2304 + "print allocated vla1(3,6,9) after specific assignment (deallocated)"
2305 +gdb_test "print vla1(1, 3, 8)" "no such vector element because not allocated" \
2306 + "print allocated vla1(1,3,8) after specific assignment (deallocated)"
2307 +gdb_test "print vla1(9, 9, 9)" "no such vector element because not allocated" \
2308 + "print allocated vla1(9,9,9) after assignment in debugger (deallocated)"
2311 +# Try to assign VLA to user variable
2312 +clean_restart ${testfile}
2314 +if ![runto MAIN__] then {
2315 + perror "couldn't run to breakpoint MAIN__"
2318 +gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
2319 +gdb_continue_to_breakpoint "vla2-allocated"
2320 +gdb_test "next" "\\d+.*vla1\\(3, 6, 9\\) = 42" "next (1)"
2322 +gdb_test_no_output "set \$myvar = vla1" "set \$myvar = vla1"
2323 +gdb_test "print \$myvar" \
2324 + " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" \
2325 + "print \$myvar set to vla1"
2327 +gdb_test "next" "\\d+.*vla1\\(1, 3, 8\\) = 1001" "next (2)"
2328 +gdb_test "print \$myvar(3,6,9)" " = 1311" "print \$myvar(3,6,9)"
2330 +gdb_breakpoint [gdb_get_line_number "pvla-associated"]
2331 +gdb_continue_to_breakpoint "pvla-associated"
2332 +gdb_test_no_output "set \$mypvar = pvla" "set \$mypvar = pvla"
2333 +gdb_test "print \$mypvar(1,3,8)" " = 1001" "print \$mypvar(1,3,8)"
2335 +# deallocate pointer and make sure user defined variable still has the
2337 +gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
2338 +gdb_continue_to_breakpoint "pvla-deassociated"
2339 +gdb_test "print \$mypvar(1,3,8)" " = 1001" \
2340 + "print \$mypvar(1,3,8) after deallocated"
2341 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla.f90
2342 ===================================================================
2343 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2344 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/vla.f90 2015-05-29 08:27:06.269740311 +0200
2346 +! Copyright 2014 Free Software Foundation, Inc.
2348 +! This program is free software; you can redistribute it and/or modify
2349 +! it under the terms of the GNU General Public License as published by
2350 +! the Free Software Foundation; either version 3 of the License, or
2351 +! (at your option) any later version.
2353 +! This program is distributed in the hope that it will be useful,
2354 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
2355 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2356 +! GNU General Public License for more details.
2358 +! You should have received a copy of the GNU General Public License
2359 +! along with this program. If not, see <http://www.gnu.org/licenses/>.
2362 + real, target, allocatable :: vla1 (:, :, :)
2363 + real, target, allocatable :: vla2 (:, :, :)
2364 + real, target, allocatable :: vla3 (:, :)
2365 + real, pointer :: pvla (:, :, :)
2368 + allocate (vla1 (10,10,10)) ! vla1-init
2369 + l = allocated(vla1)
2371 + allocate (vla2 (1:7,42:50,13:35)) ! vla1-allocated
2372 + l = allocated(vla2)
2374 + vla1(:, :, :) = 1311 ! vla2-allocated
2375 + vla1(3, 6, 9) = 42
2376 + vla1(1, 3, 8) = 1001
2377 + vla1(6, 2, 7) = 13
2379 + vla2(:, :, :) = 1311 ! vla1-filled
2380 + vla2(5, 45, 20) = 42
2382 + pvla => vla1 ! vla2-filled
2383 + l = associated(pvla)
2385 + pvla => vla2 ! pvla-associated
2386 + l = associated(pvla)
2387 + pvla(5, 45, 20) = 1
2388 + pvla(7, 45, 14) = 2
2390 + pvla => null() ! pvla-re-associated
2391 + l = associated(pvla)
2393 + deallocate (vla1) ! pvla-deassociated
2394 + l = allocated(vla1)
2396 + deallocate (vla2) ! vla1-deallocated
2397 + l = allocated(vla2)
2399 + allocate (vla3 (2,2)) ! vla2-deallocated
2402 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
2403 ===================================================================
2404 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2405 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.mi/mi-vla-fortran.exp 2015-05-29 11:13:53.951656591 +0200
2407 +# Copyright 2014 Free Software Foundation, Inc.
2409 +# This program is free software; you can redistribute it and/or modify
2410 +# it under the terms of the GNU General Public License as published by
2411 +# the Free Software Foundation; either version 3 of the License, or
2412 +# (at your option) any later version.
2414 +# This program is distributed in the hope that it will be useful,
2415 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2416 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2417 +# GNU General Public License for more details.
2419 +# You should have received a copy of the GNU General Public License
2420 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
2422 +# Verify that, using the MI, we can evaluate a simple C Variable Length
2425 +load_lib mi-support.exp
2426 +set MIFLAGS "-i=mi"
2429 +if [mi_gdb_start] {
2433 +standard_testfile vla.f90
2435 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
2436 + {debug f90}] != "" } {
2437 + untested mi-vla-fortran.exp
2441 +mi_delete_breakpoints
2442 +mi_gdb_reinitialize_dir $srcdir/$subdir
2443 +mi_gdb_load ${binfile}
2445 +set bp_lineno [gdb_get_line_number "vla1-not-allocated"]
2446 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 1 "del" "vla" \
2447 + ".*vla.f90" $bp_lineno $hex \
2448 + "insert breakpoint at line $bp_lineno (vla not allocated)"
2450 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2451 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2452 +mi_gdb_test "500-data-evaluate-expression vla1" \
2453 + "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
2455 +mi_create_varobj_checked vla1_not_allocated vla1 "<not allocated>" \
2456 + "create local variable vla1_not_allocated"
2457 +mi_gdb_test "501-var-info-type vla1_not_allocated" \
2458 + "501\\^done,type=\"<not allocated>\"" \
2459 + "info type variable vla1_not_allocated"
2460 +mi_gdb_test "502-var-show-format vla1_not_allocated" \
2461 + "502\\^done,format=\"natural\"" \
2462 + "show format variable vla1_not_allocated"
2463 +mi_gdb_test "503-var-evaluate-expression vla1_not_allocated" \
2464 + "503\\^done,value=\"\\\[0\\\]\"" \
2465 + "eval variable vla1_not_allocated"
2466 +mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
2467 + "real\\\(kind=4\\\)" "get children of vla1_not_allocated"
2471 +set bp_lineno [gdb_get_line_number "vla1-allocated"]
2472 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 2 "del" "vla" ".*vla.f90" \
2473 + $bp_lineno $hex "insert breakpoint at line $bp_lineno (vla allocated)"
2475 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2476 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2477 +# Content of 'vla1' is uninitialized here.
2479 +mi_create_varobj_checked vla1_allocated vla1 "real\\\(kind=4\\\) \\\(5\\\)" \
2480 + "create local variable vla1_allocated"
2481 +mi_gdb_test "511-var-info-type vla1_allocated" \
2482 + "511\\^done,type=\"real\\\(kind=4\\\) \\\(5\\\)\"" \
2483 + "info type variable vla1_allocated"
2484 +mi_gdb_test "512-var-show-format vla1_allocated" \
2485 + "512\\^done,format=\"natural\"" \
2486 + "show format variable vla1_allocated"
2487 +mi_gdb_test "513-var-evaluate-expression vla1_allocated" \
2488 + "513\\^done,value=\"\\\[5\\\]\"" \
2489 + "eval variable vla1_allocated"
2490 +mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
2491 + "real\\\(kind=4\\\)" "get children of vla1_allocated"
2494 +set bp_lineno [gdb_get_line_number "vla1-filled"]
2495 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 3 "del" "vla" ".*vla.f90" \
2496 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2498 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2499 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2500 +mi_gdb_test "520-data-evaluate-expression vla1" \
2501 + "520\\^done,value=\"\\(1, 1, 1, 1, 1\\)\"" "evaluate filled vla"
2504 +set bp_lineno [gdb_get_line_number "vla1-modified"]
2505 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 4 "del" "vla" ".*vla.f90" \
2506 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
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 "530-data-evaluate-expression vla1" \
2511 + "530\\^done,value=\"\\(1, 42, 1, 24, 1\\)\"" "evaluate filled vla"
2512 +mi_gdb_test "540-data-evaluate-expression vla1(1)" \
2513 + "540\\^done,value=\"1\"" "evaluate filled vla"
2514 +mi_gdb_test "550-data-evaluate-expression vla1(2)" \
2515 + "550\\^done,value=\"42\"" "evaluate filled vla"
2516 +mi_gdb_test "560-data-evaluate-expression vla1(4)" \
2517 + "560\\^done,value=\"24\"" "evaluate filled vla"
2520 +set bp_lineno [gdb_get_line_number "vla1-deallocated"]
2521 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 5 "del" "vla" ".*vla.f90" \
2522 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2524 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2525 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2526 +mi_gdb_test "570-data-evaluate-expression vla1" \
2527 + "570\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
2530 +set bp_lineno [gdb_get_line_number "pvla2-not-associated"]
2531 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 6 "del" "vla" ".*vla.f90" \
2532 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2534 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2535 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2536 +mi_gdb_test "580-data-evaluate-expression pvla2" \
2537 + "580\\^done,value=\"<not associated>\"" "evaluate not associated vla"
2539 +mi_create_varobj_checked pvla2_not_associated pvla2 "<not associated>" \
2540 + "create local variable pvla2_not_associated"
2541 +mi_gdb_test "581-var-info-type pvla2_not_associated" \
2542 + "581\\^done,type=\"<not associated>\"" \
2543 + "info type variable pvla2_not_associated"
2544 +mi_gdb_test "582-var-show-format pvla2_not_associated" \
2545 + "582\\^done,format=\"natural\"" \
2546 + "show format variable pvla2_not_associated"
2547 +mi_gdb_test "583-var-evaluate-expression pvla2_not_associated" \
2548 + "583\\^done,value=\"\\\[0\\\]\"" \
2549 + "eval variable pvla2_not_associated"
2550 +mi_list_array_varobj_children_with_index "pvla2_not_associated" "0" "1" \
2551 + "real\\\(kind=4\\\)" "get children of pvla2_not_associated"
2554 +set bp_lineno [gdb_get_line_number "pvla2-associated"]
2555 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 7 "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 "590-data-evaluate-expression pvla2" \
2561 + "590\\^done,value=\"\\(\\( 2, 2, 2, 2, 2\\) \\( 2, 2, 2, 2, 2\\) \\)\"" \
2562 + "evaluate associated vla"
2564 +mi_create_varobj_checked pvla2_associated pvla2 \
2565 + "real\\\(kind=4\\\) \\\(5,2\\\)" "create local variable pvla2_associated"
2566 +mi_gdb_test "591-var-info-type pvla2_associated" \
2567 + "591\\^done,type=\"real\\\(kind=4\\\) \\\(5,2\\\)\"" \
2568 + "info type variable pvla2_associated"
2569 +mi_gdb_test "592-var-show-format pvla2_associated" \
2570 + "592\\^done,format=\"natural\"" \
2571 + "show format variable pvla2_associated"
2572 +mi_gdb_test "593-var-evaluate-expression pvla2_associated" \
2573 + "593\\^done,value=\"\\\[2\\\]\"" \
2574 + "eval variable pvla2_associated"
2577 +set bp_lineno [gdb_get_line_number "pvla2-set-to-null"]
2578 +mi_create_breakpoint "-t vla.f90:$bp_lineno" 8 "del" "vla" ".*vla.f90" \
2579 + $bp_lineno $hex "insert breakpoint at line $bp_lineno"
2581 +mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
2582 + { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
2583 +mi_gdb_test "600-data-evaluate-expression pvla2" \
2584 + "600\\^done,value=\"<not associated>\"" "evaluate vla pointer set to null"
2588 Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.mi/vla.f90
2589 ===================================================================
2590 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2591 +++ gdb-7.9.50.20150520/gdb/testsuite/gdb.mi/vla.f90 2015-05-29 08:27:06.270740317 +0200
2593 +! Copyright 2014 Free Software Foundation, Inc.
2595 +! This program is free software; you can redistribute it and/or modify
2596 +! it under the terms of the GNU General Public License as published by
2597 +! the Free Software Foundation; either version 3 of the License, or
2598 +! (at your option) any later version.
2600 +! This program is distributed in the hope that it will be useful,
2601 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
2602 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2603 +! GNU General Public License for more details.
2605 +! You should have received a copy of the GNU General Public License
2606 +! along with this program. If not, see <http://www.gnu.org/licenses/>.
2609 + real, allocatable :: vla1 (:)
2610 + real, target, allocatable :: vla2(:, :)
2611 + real, pointer :: pvla2 (:, :)
2614 + allocate (vla1 (5)) ! vla1-not-allocated
2615 + l = allocated(vla1) ! vla1-allocated
2618 + vla1(2) = 42 ! vla1-filled
2621 + deallocate (vla1) ! vla1-modified
2622 + l = allocated(vla1) ! vla1-deallocated
2624 + allocate (vla2 (5, 2))
2627 + pvla2 => vla2 ! pvla2-not-associated
2628 + l = associated(pvla2) ! pvla2-associated
2633 + l = associated(pvla2) ! pvla2-set-to-null
2635 Index: gdb-7.9.50.20150520/gdb/typeprint.c
2636 ===================================================================
2637 --- gdb-7.9.50.20150520.orig/gdb/typeprint.c 2015-05-29 08:27:02.688717523 +0200
2638 +++ gdb-7.9.50.20150520/gdb/typeprint.c 2015-05-29 08:27:06.270740317 +0200
2639 @@ -458,6 +458,13 @@ whatis_exp (char *exp, int show)
2641 type = value_type (val);
2643 + if (TYPE_CODE (type) == TYPE_CODE_PTR)
2644 + if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
2646 + val = value_addr (value_ind (val));
2647 + type = value_type (val);
2650 get_user_print_options (&opts);
2651 if (opts.objectprint)
2653 Index: gdb-7.9.50.20150520/gdb/valarith.c
2654 ===================================================================
2655 --- gdb-7.9.50.20150520.orig/gdb/valarith.c 2015-05-29 08:27:02.689717530 +0200
2656 +++ gdb-7.9.50.20150520/gdb/valarith.c 2015-05-29 08:27:06.271740324 +0200
2657 @@ -193,12 +193,31 @@ value_subscripted_rvalue (struct value *
2658 struct type *array_type = check_typedef (value_type (array));
2659 struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
2660 unsigned int elt_size = TYPE_LENGTH (elt_type);
2661 - unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
2662 + unsigned int elt_offs = longest_to_int (index - lowerbound);
2663 + LONGEST elt_stride = TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type));
2666 + if (elt_stride > 0)
2667 + elt_offs *= elt_stride;
2668 + else if (elt_stride < 0)
2670 + int offs = (elt_offs + 1) * elt_stride;
2672 + elt_offs = TYPE_LENGTH (array_type) + offs;
2675 + elt_offs *= elt_size;
2677 if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
2678 && elt_offs >= TYPE_LENGTH (array_type)))
2679 - error (_("no such vector element"));
2681 + if (TYPE_NOT_ASSOCIATED (array_type))
2682 + error (_("no such vector element because not associated"));
2683 + else if (TYPE_NOT_ALLOCATED (array_type))
2684 + error (_("no such vector element because not allocated"));
2686 + error (_("no such vector element"));
2689 if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
2690 v = allocate_value_lazy (elt_type);
2691 Index: gdb-7.9.50.20150520/gdb/valprint.c
2692 ===================================================================
2693 --- gdb-7.9.50.20150520.orig/gdb/valprint.c 2015-05-29 08:27:02.690717536 +0200
2694 +++ gdb-7.9.50.20150520/gdb/valprint.c 2015-05-29 08:27:06.271740324 +0200
2695 @@ -303,6 +303,18 @@ valprint_check_validity (struct ui_file
2697 CHECK_TYPEDEF (type);
2699 + if (TYPE_NOT_ASSOCIATED (type))
2701 + val_print_not_associated (stream);
2705 + if (TYPE_NOT_ALLOCATED (type))
2707 + val_print_not_allocated (stream);
2711 if (TYPE_CODE (type) != TYPE_CODE_UNION
2712 && TYPE_CODE (type) != TYPE_CODE_STRUCT
2713 && TYPE_CODE (type) != TYPE_CODE_ARRAY)
2714 @@ -359,6 +371,18 @@ val_print_invalid_address (struct ui_fil
2715 fprintf_filtered (stream, _("<invalid address>"));
2719 +val_print_not_allocated (struct ui_file *stream)
2721 + fprintf_filtered (stream, _("<not allocated>"));
2725 +val_print_not_associated (struct ui_file *stream)
2727 + fprintf_filtered (stream, _("<not associated>"));
2730 /* A generic val_print that is suitable for use by language
2731 implementations of the la_val_print method. This function can
2732 handle most type codes, though not all, notably exception
2733 @@ -802,12 +826,16 @@ static int
2734 value_check_printable (struct value *val, struct ui_file *stream,
2735 const struct value_print_options *options)
2737 + const struct type *type;
2741 fprintf_filtered (stream, _("<address of value unknown>"));
2745 + type = value_type (val);
2747 if (value_entirely_optimized_out (val))
2749 if (options->summary && !val_print_scalar_type_p (value_type (val)))
2750 @@ -833,6 +861,18 @@ value_check_printable (struct value *val
2754 + if (TYPE_NOT_ASSOCIATED (type))
2756 + val_print_not_associated (stream);
2760 + if (TYPE_NOT_ALLOCATED (type))
2762 + val_print_not_allocated (stream);
2769 Index: gdb-7.9.50.20150520/gdb/valprint.h
2770 ===================================================================
2771 --- gdb-7.9.50.20150520.orig/gdb/valprint.h 2015-05-29 08:27:02.691717543 +0200
2772 +++ gdb-7.9.50.20150520/gdb/valprint.h 2015-05-29 08:27:06.272740330 +0200
2773 @@ -232,4 +232,8 @@ extern void print_command_parse_format (
2774 struct format_data *fmtp);
2775 extern void print_value (struct value *val, const struct format_data *fmtp);
2777 +extern void val_print_not_allocated (struct ui_file *stream);
2779 +extern void val_print_not_associated (struct ui_file *stream);
2782 Index: gdb-7.9.50.20150520/gdb/value.c
2783 ===================================================================
2784 --- gdb-7.9.50.20150520.orig/gdb/value.c 2015-05-29 08:27:02.693717555 +0200
2785 +++ gdb-7.9.50.20150520/gdb/value.c 2015-05-29 08:27:06.273740337 +0200
2787 #include "tracepoint.h"
2789 #include "user-regs.h"
2790 +#include "dwarf2loc.h"
2792 /* Prototypes for exported functions. */
2794 @@ -1776,6 +1777,25 @@ set_value_component_location (struct val
2795 if (funcs->copy_closure)
2796 component->location.computed.closure = funcs->copy_closure (whole);
2799 + /* For dynamic types compute the address of the component value location in
2800 + sub range types based on the location of the sub range type, if not being
2801 + an internal GDB variable or parts of it. */
2802 + if (VALUE_LVAL (component) != lval_internalvar
2803 + && VALUE_LVAL (component) != lval_internalvar_component)
2806 + struct type *type = value_type (whole);
2808 + addr = value_raw_address (component);
2810 + if (TYPE_DATA_LOCATION (type)
2811 + && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
2813 + addr = TYPE_DATA_LOCATION_ADDR (type);
2814 + set_value_address (component, addr);
2820 @@ -3080,13 +3100,22 @@ value_primitive_field (struct value *arg
2821 v = allocate_value_lazy (type);
2824 - v = allocate_value (type);
2825 - value_contents_copy_raw (v, value_embedded_offset (v),
2826 - arg1, value_embedded_offset (arg1) + offset,
2827 - TYPE_LENGTH (type));
2828 + if (TYPE_DATA_LOCATION (type)
2829 + && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
2830 + v = value_at_lazy (type, value_address (arg1) + offset);
2833 + v = allocate_value (type);
2834 + value_contents_copy_raw (v, value_embedded_offset (v),
2835 + arg1, value_embedded_offset (arg1) + offset,
2836 + TYPE_LENGTH (type));
2839 - v->offset = (value_offset (arg1) + offset
2840 - + value_embedded_offset (arg1));
2842 + if (!TYPE_DATA_LOCATION (type)
2843 + || !TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
2844 + v->offset = (value_offset (arg1) + offset
2845 + + value_embedded_offset (arg1));
2847 set_value_component_location (v, arg1);
2848 VALUE_REGNUM (v) = VALUE_REGNUM (arg1);
2849 @@ -3674,7 +3703,8 @@ readjust_indirect_value_type (struct val
2850 struct value *original_value)
2852 /* Re-adjust type. */
2853 - deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type));
2854 + if (!is_dynamic_type (TYPE_TARGET_TYPE (original_type)))
2855 + deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type));
2857 /* Add embedding info. */
2858 set_value_enclosing_type (value, enc_type);
2859 @@ -3691,6 +3721,12 @@ coerce_ref (struct value *arg)
2860 struct value *retval;
2861 struct type *enc_type;
2863 + if (current_language->la_language != language_fortran
2864 + && TYPE_DATA_LOCATION (value_type_arg_tmp) != NULL
2865 + && TYPE_DATA_LOCATION_KIND (value_type_arg_tmp) == PROP_CONST)
2866 + arg = value_at_lazy (value_type_arg_tmp,
2867 + TYPE_DATA_LOCATION_ADDR (value_type_arg_tmp));
2869 retval = coerce_ref_if_computed (arg);
2872 @@ -3825,8 +3861,14 @@ value_fetch_lazy (struct value *val)
2874 else if (VALUE_LVAL (val) == lval_memory)
2876 - CORE_ADDR addr = value_address (val);
2877 struct type *type = check_typedef (value_enclosing_type (val));
2880 + if (TYPE_DATA_LOCATION (type) != NULL
2881 + && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
2882 + addr = TYPE_DATA_LOCATION_ADDR (type);
2884 + addr = value_address (val);
2886 if (TYPE_LENGTH (type))
2887 read_value_memory (val, 0, value_stack (val),
2888 Index: gdb-7.9.50.20150520/gdb/dwarf2loc.c
2889 ===================================================================
2890 --- gdb-7.9.50.20150520.orig/gdb/dwarf2loc.c 2015-05-29 08:27:02.694717562 +0200
2891 +++ gdb-7.9.50.20150520/gdb/dwarf2loc.c 2015-05-29 08:27:06.274740343 +0200
2892 @@ -2294,6 +2294,11 @@ dwarf2_evaluate_loc_desc_full (struct ty
2893 int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0);
2895 do_cleanups (value_chain);
2897 + /* Select right frame to correctly evaluate VLA's during a backtrace. */
2898 + if (is_dynamic_type (type))
2899 + select_frame (frame);
2901 retval = value_at_lazy (type, address + byte_offset);
2902 if (in_stack_memory)
2903 set_value_stack (retval, 1);
2904 @@ -2577,6 +2582,19 @@ dwarf2_compile_property_to_c (struct ui_
2905 data, data + size, per_cu);
2908 +/* See dwarf2loc.h. */
2911 +dwarf2_address_data_valid (const struct type *type)
2913 + if (TYPE_NOT_ASSOCIATED (type))
2916 + if (TYPE_NOT_ALLOCATED (type))
2922 /* Helper functions and baton for dwarf2_loc_desc_needs_frame. */