|
|
2f9ed3 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
2f9ed3 |
From: Fedora GDB patches <invalid@email.com>
|
|
|
2f9ed3 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
2f9ed3 |
Subject: gdb-vla-intel-fortran-strides.patch
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
;; VLA (Fortran dynamic arrays) from Intel + archer-jankratochvil-vla tests.
|
|
|
2f9ed3 |
;;=push
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
git diff --stat -p gdb/master...gdb/users/bheckel/fortran-strides
|
|
|
2f9ed3 |
dbfd7140bf4c0500d1f5d192be781f83f78f7922
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
gdb/dwarf2loc.c | 46 ++-
|
|
|
2f9ed3 |
gdb/dwarf2loc.h | 6 +
|
|
|
2f9ed3 |
gdb/dwarf2read.c | 13 +-
|
|
|
2f9ed3 |
gdb/eval.c | 391 +++++++++++++++++++++-----
|
|
|
2f9ed3 |
gdb/expprint.c | 20 +-
|
|
|
2f9ed3 |
gdb/expression.h | 18 +-
|
|
|
2f9ed3 |
gdb/f-exp.y | 42 ++-
|
|
|
2f9ed3 |
gdb/f-valprint.c | 8 +-
|
|
|
2f9ed3 |
gdb/gdbtypes.c | 34 ++-
|
|
|
2f9ed3 |
gdb/gdbtypes.h | 18 +-
|
|
|
2f9ed3 |
gdb/parse.c | 24 +-
|
|
|
2f9ed3 |
gdb/rust-exp.y | 12 +-
|
|
|
2f9ed3 |
gdb/rust-lang.c | 17 +-
|
|
|
2f9ed3 |
gdb/testsuite/gdb.fortran/static-arrays.exp | 421 ++++++++++++++++++++++++++++
|
|
|
2f9ed3 |
gdb/testsuite/gdb.fortran/static-arrays.f90 | 55 ++++
|
|
|
2f9ed3 |
gdb/testsuite/gdb.fortran/vla-ptype.exp | 4 +
|
|
|
2f9ed3 |
gdb/testsuite/gdb.fortran/vla-sizeof.exp | 4 +
|
|
|
2f9ed3 |
gdb/testsuite/gdb.fortran/vla-stride.exp | 44 +++
|
|
|
2f9ed3 |
gdb/testsuite/gdb.fortran/vla-stride.f90 | 29 ++
|
|
|
2f9ed3 |
gdb/testsuite/gdb.fortran/vla.f90 | 10 +
|
|
|
2f9ed3 |
gdb/valarith.c | 10 +-
|
|
|
2f9ed3 |
gdb/valops.c | 197 +++++++++++--
|
|
|
2f9ed3 |
gdb/value.h | 2 +
|
|
|
2f9ed3 |
23 files changed, 1242 insertions(+), 183 deletions(-)
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
|
|
|
2f9ed3 |
--- a/gdb/dwarf2loc.c
|
|
|
2f9ed3 |
+++ b/gdb/dwarf2loc.c
|
|
|
2f9ed3 |
@@ -2429,11 +2429,14 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
|
|
|
2f9ed3 |
/* See dwarf2loc.h. */
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
int
|
|
|
2f9ed3 |
-dwarf2_evaluate_property (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
+dwarf2_evaluate_property_signed (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
struct frame_info *frame,
|
|
|
2f9ed3 |
struct property_addr_info *addr_stack,
|
|
|
2f9ed3 |
- CORE_ADDR *value)
|
|
|
2f9ed3 |
+ CORE_ADDR *value,
|
|
|
2f9ed3 |
+ int is_signed)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
+ int rc = 0;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
if (prop == NULL)
|
|
|
2f9ed3 |
return 0;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
@@ -2457,7 +2460,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
*value = value_as_address (val);
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
- return 1;
|
|
|
2f9ed3 |
+ rc = 1;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
@@ -2479,7 +2482,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
if (!value_optimized_out (val))
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
*value = value_as_address (val);
|
|
|
2f9ed3 |
- return 1;
|
|
|
2f9ed3 |
+ rc = 1;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
@@ -2487,8 +2490,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
case PROP_CONST:
|
|
|
2f9ed3 |
*value = prop->data.const_val;
|
|
|
2f9ed3 |
- return 1;
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
+ rc = 1;
|
|
|
2f9ed3 |
+ break;
|
|
|
2f9ed3 |
case PROP_ADDR_OFFSET:
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
struct dwarf2_property_baton *baton
|
|
|
2f9ed3 |
@@ -2509,11 +2512,38 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
val = value_at (baton->offset_info.type,
|
|
|
2f9ed3 |
pinfo->addr + baton->offset_info.offset);
|
|
|
2f9ed3 |
*value = value_as_address (val);
|
|
|
2f9ed3 |
- return 1;
|
|
|
2f9ed3 |
+ rc = 1;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
+ break;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- return 0;
|
|
|
2f9ed3 |
+ if (rc == 1 && is_signed == 1)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ /* If we have a valid return candidate and it's value is signed,
|
|
|
2f9ed3 |
+ we have to sign-extend the value because CORE_ADDR on 64bit machine has
|
|
|
2f9ed3 |
+ 8 bytes but address size of an 32bit application is 4 bytes. */
|
|
|
2f9ed3 |
+ struct gdbarch * gdbarch = target_gdbarch ();
|
|
|
2f9ed3 |
+ const int addr_bit = gdbarch_addr_bit (gdbarch);
|
|
|
2f9ed3 |
+ const CORE_ADDR neg_mask = ((~0) << (addr_bit - 1));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Check if signed bit is set and sign-extend values. */
|
|
|
2f9ed3 |
+ if (*value & (neg_mask))
|
|
|
2f9ed3 |
+ *value |= (neg_mask );
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ return rc;
|
|
|
2f9ed3 |
+}
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+int
|
|
|
2f9ed3 |
+dwarf2_evaluate_property (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
+ struct frame_info *frame,
|
|
|
2f9ed3 |
+ struct property_addr_info *addr_stack,
|
|
|
2f9ed3 |
+ CORE_ADDR *value)
|
|
|
2f9ed3 |
+{
|
|
|
2f9ed3 |
+ return dwarf2_evaluate_property_signed (prop,
|
|
|
2f9ed3 |
+ frame,
|
|
|
2f9ed3 |
+ addr_stack,
|
|
|
2f9ed3 |
+ value,
|
|
|
2f9ed3 |
+ 0);
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
/* See dwarf2loc.h. */
|
|
|
2f9ed3 |
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
|
|
|
2f9ed3 |
--- a/gdb/dwarf2loc.h
|
|
|
2f9ed3 |
+++ b/gdb/dwarf2loc.h
|
|
|
2f9ed3 |
@@ -143,6 +143,12 @@ int dwarf2_evaluate_property (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
struct property_addr_info *addr_stack,
|
|
|
2f9ed3 |
CORE_ADDR *value);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
+int dwarf2_evaluate_property_signed (const struct dynamic_prop *prop,
|
|
|
2f9ed3 |
+ struct frame_info *frame,
|
|
|
2f9ed3 |
+ struct property_addr_info *addr_stack,
|
|
|
2f9ed3 |
+ CORE_ADDR *value,
|
|
|
2f9ed3 |
+ int is_signed);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
/* A helper for the compiler interface that compiles a single dynamic
|
|
|
2f9ed3 |
property to C code.
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
|
|
|
2f9ed3 |
--- a/gdb/dwarf2read.c
|
|
|
2f9ed3 |
+++ b/gdb/dwarf2read.c
|
|
|
2f9ed3 |
@@ -17773,7 +17773,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
2f9ed3 |
struct type *base_type, *orig_base_type;
|
|
|
2f9ed3 |
struct type *range_type;
|
|
|
2f9ed3 |
struct attribute *attr;
|
|
|
2f9ed3 |
- struct dynamic_prop low, high;
|
|
|
2f9ed3 |
+ struct dynamic_prop low, high, stride;
|
|
|
2f9ed3 |
int low_default_is_valid;
|
|
|
2f9ed3 |
int high_bound_is_count = 0;
|
|
|
2f9ed3 |
const char *name;
|
|
|
2f9ed3 |
@@ -17793,7 +17793,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
low.kind = PROP_CONST;
|
|
|
2f9ed3 |
high.kind = PROP_CONST;
|
|
|
2f9ed3 |
+ stride.kind = PROP_CONST;
|
|
|
2f9ed3 |
high.data.const_val = 0;
|
|
|
2f9ed3 |
+ stride.data.const_val = 0;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
/* Set LOW_DEFAULT_IS_VALID if current language and DWARF version allow
|
|
|
2f9ed3 |
omitting DW_AT_lower_bound. */
|
|
|
2f9ed3 |
@@ -17826,6 +17828,14 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
+ attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
|
|
|
2f9ed3 |
+ if (attr)
|
|
|
2f9ed3 |
+ if (!attr_to_dynamic_prop (attr, die, cu, &stride))
|
|
|
2f9ed3 |
+ complaint (_("Missing DW_AT_byte_stride "
|
|
|
2f9ed3 |
+ "- DIE at 0x%s [in module %s]"),
|
|
|
2f9ed3 |
+ sect_offset_str (die->sect_off),
|
|
|
2f9ed3 |
+ objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
|
|
|
2f9ed3 |
if (attr)
|
|
|
2f9ed3 |
attr_to_dynamic_prop (attr, die, cu, &low);
|
|
|
2f9ed3 |
@@ -17918,7 +17928,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
2f9ed3 |
&& !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask))
|
|
|
2f9ed3 |
high.data.const_val |= negative_mask;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- range_type = create_range_type (NULL, orig_base_type, &low, &high);
|
|
|
2f9ed3 |
+ range_type = create_range_type (NULL, orig_base_type, &low, &high, &stride);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (high_bound_is_count)
|
|
|
2f9ed3 |
TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1;
|
|
|
2f9ed3 |
diff --git a/gdb/eval.c b/gdb/eval.c
|
|
|
2f9ed3 |
--- a/gdb/eval.c
|
|
|
2f9ed3 |
+++ b/gdb/eval.c
|
|
|
2f9ed3 |
@@ -377,29 +377,324 @@ init_array_element (struct value *array, struct value *element,
|
|
|
2f9ed3 |
return index;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
+/* Evaluates any operation on Fortran arrays or strings with at least
|
|
|
2f9ed3 |
+ one user provided parameter. Expects the input ARRAY to be either
|
|
|
2f9ed3 |
+ an array, or a string. Evaluates EXP by incrementing POS, and
|
|
|
2f9ed3 |
+ writes the content from the elt stack into a local struct. NARGS
|
|
|
2f9ed3 |
+ specifies number of literal or range arguments the user provided.
|
|
|
2f9ed3 |
+ NARGS must be the same number as ARRAY has dimensions. */
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
static struct value *
|
|
|
2f9ed3 |
-value_f90_subarray (struct value *array,
|
|
|
2f9ed3 |
- struct expression *exp, int *pos, enum noside noside)
|
|
|
2f9ed3 |
+value_f90_subarray (struct value *array, struct expression *exp,
|
|
|
2f9ed3 |
+ int *pos, int nargs, enum noside noside)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- int pc = (*pos) + 1;
|
|
|
2f9ed3 |
- LONGEST low_bound, high_bound;
|
|
|
2f9ed3 |
- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
|
|
|
2f9ed3 |
- enum range_type range_type
|
|
|
2f9ed3 |
- = (enum range_type) longest_to_int (exp->elts[pc].longconst);
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- *pos += 3;
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
|
|
|
2f9ed3 |
- low_bound = TYPE_LOW_BOUND (range);
|
|
|
2f9ed3 |
- else
|
|
|
2f9ed3 |
- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
|
|
|
2f9ed3 |
+ int i, dim_count = 0;
|
|
|
2f9ed3 |
+ struct value *new_array = array;
|
|
|
2f9ed3 |
+ struct type *array_type = check_typedef (value_type (new_array));
|
|
|
2f9ed3 |
+ struct type *elt_type;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ typedef struct
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ enum range_type f90_range_type;
|
|
|
2f9ed3 |
+ LONGEST low, high, stride;
|
|
|
2f9ed3 |
+ } subscript_range;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ typedef enum subscript_kind
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ SUBSCRIPT_RANGE, /* e.g. "(lowbound:highbound)" */
|
|
|
2f9ed3 |
+ SUBSCRIPT_INDEX /* e.g. "(literal)" */
|
|
|
2f9ed3 |
+ } kind;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Local struct to hold user data for Fortran subarray dimensions. */
|
|
|
2f9ed3 |
+ struct subscript_store
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ /* For every dimension, we are either working on a range or an index
|
|
|
2f9ed3 |
+ expression, so we store this info separately for later. */
|
|
|
2f9ed3 |
+ enum subscript_kind kind;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* We also store either the lower and upper bound info, or the index
|
|
|
2f9ed3 |
+ number. Before evaluation of the input values, we do not know if we are
|
|
|
2f9ed3 |
+ actually working on a range of ranges, or an index in a range. So as a
|
|
|
2f9ed3 |
+ first step we store all input in a union. The array calculation itself
|
|
|
2f9ed3 |
+ deals with this later on. */
|
|
|
2f9ed3 |
+ union element_range
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ subscript_range range;
|
|
|
2f9ed3 |
+ LONGEST number;
|
|
|
2f9ed3 |
+ } U;
|
|
|
2f9ed3 |
+ } *subscript_array;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Check if the number of arguments provided by the user matches
|
|
|
2f9ed3 |
+ the number of dimension of the array. A string has only one
|
|
|
2f9ed3 |
+ dimension. */
|
|
|
2f9ed3 |
+ if (nargs != calc_f77_array_dims (value_type (new_array)))
|
|
|
2f9ed3 |
+ error (_("Wrong number of subscripts"));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ subscript_array = (struct subscript_store*) alloca (sizeof (*subscript_array) * nargs);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Parse the user input into the SUBSCRIPT_ARRAY to store it. We need
|
|
|
2f9ed3 |
+ to evaluate it first, as the input is from left-to-right. The
|
|
|
2f9ed3 |
+ array is stored from right-to-left. So we have to use the user
|
|
|
2f9ed3 |
+ input in reverse order. Later on, we need the input information to
|
|
|
2f9ed3 |
+ re-calculate the output array. For multi-dimensional arrays, we
|
|
|
2f9ed3 |
+ can be dealing with any possible combination of ranges and indices
|
|
|
2f9ed3 |
+ for every dimension. */
|
|
|
2f9ed3 |
+ for (i = 0; i < nargs; i++)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ struct subscript_store *index = &subscript_array[i];
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* The user input is a range, with or without lower and upper bound.
|
|
|
2f9ed3 |
+ E.g.: "p arry(2:5)", "p arry( :5)", "p arry( : )", etc. */
|
|
|
2f9ed3 |
+ if (exp->elts[*pos].opcode == OP_RANGE)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ int pc = (*pos) + 1;
|
|
|
2f9ed3 |
+ subscript_range *range;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ index->kind = SUBSCRIPT_RANGE;
|
|
|
2f9ed3 |
+ range = &index->U.range;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ *pos += 3;
|
|
|
2f9ed3 |
+ range->f90_range_type = (enum range_type) exp->elts[pc].longconst;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* If a lower bound was provided by the user, the bit has been
|
|
|
2f9ed3 |
+ set and we can assign the value from the elt stack. Same for
|
|
|
2f9ed3 |
+ upper bound. */
|
|
|
2f9ed3 |
+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND)
|
|
|
2f9ed3 |
+ == SUBARRAY_LOW_BOUND)
|
|
|
2f9ed3 |
+ range->low = value_as_long (evaluate_subexp (NULL_TYPE, exp,
|
|
|
2f9ed3 |
+ pos, noside));
|
|
|
2f9ed3 |
+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND)
|
|
|
2f9ed3 |
+ == SUBARRAY_HIGH_BOUND)
|
|
|
2f9ed3 |
+ range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp,
|
|
|
2f9ed3 |
+ pos, noside));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Assign the user's stride value if provided. */
|
|
|
2f9ed3 |
+ if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
|
|
|
2f9ed3 |
+ range->stride = value_as_long (evaluate_subexp (NULL_TYPE, exp,
|
|
|
2f9ed3 |
+ pos, noside));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Assign the default stride value '1'. */
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ range->stride = 1;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
|
|
|
2f9ed3 |
- high_bound = TYPE_HIGH_BOUND (range);
|
|
|
2f9ed3 |
- else
|
|
|
2f9ed3 |
- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
|
|
|
2f9ed3 |
+ /* Check the provided stride value is illegal, aka '0'. */
|
|
|
2f9ed3 |
+ if (range->stride == 0)
|
|
|
2f9ed3 |
+ error (_("Stride must not be 0"));
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ /* User input is an index. E.g.: "p arry(5)". */
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ struct value *val;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ index->kind = SUBSCRIPT_INDEX;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Evaluate each subscript; it must be a legal integer in F77. This
|
|
|
2f9ed3 |
+ ensures the validity of the provided index. */
|
|
|
2f9ed3 |
+ val = evaluate_subexp_with_coercion (exp, pos, noside);
|
|
|
2f9ed3 |
+ index->U.number = value_as_long (val);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Traverse the array from right to left and set the high and low bounds
|
|
|
2f9ed3 |
+ for later use. */
|
|
|
2f9ed3 |
+ for (i = nargs - 1; i >= 0; i--)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ struct subscript_store *index = &subscript_array[i];
|
|
|
2f9ed3 |
+ struct type *index_type = TYPE_INDEX_TYPE (array_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ switch (index->kind)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ case SUBSCRIPT_RANGE:
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* When we hit the first range specified by the user, we must
|
|
|
2f9ed3 |
+ treat any subsequent user entry as a range. We simply
|
|
|
2f9ed3 |
+ increment DIM_COUNT which tells us how many times we are
|
|
|
2f9ed3 |
+ calling VALUE_SLICE_1. */
|
|
|
2f9ed3 |
+ subscript_range *range = &index->U.range;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* If no lower bound was provided by the user, we take the
|
|
|
2f9ed3 |
+ default boundary. Same for the high bound. */
|
|
|
2f9ed3 |
+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND) == 0)
|
|
|
2f9ed3 |
+ range->low = TYPE_LOW_BOUND (index_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) == 0)
|
|
|
2f9ed3 |
+ range->high = TYPE_HIGH_BOUND (index_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Both user provided low and high bound have to be inside the
|
|
|
2f9ed3 |
+ array bounds. Throw an error if not. */
|
|
|
2f9ed3 |
+ if (range->low < TYPE_LOW_BOUND (index_type)
|
|
|
2f9ed3 |
+ || range->low > TYPE_HIGH_BOUND (index_type)
|
|
|
2f9ed3 |
+ || range->high < TYPE_LOW_BOUND (index_type)
|
|
|
2f9ed3 |
+ || range->high > TYPE_HIGH_BOUND (index_type))
|
|
|
2f9ed3 |
+ error (_("provided bound(s) outside array bound(s)"));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* For a negative stride the lower boundary must be larger than the
|
|
|
2f9ed3 |
+ upper boundary.
|
|
|
2f9ed3 |
+ For a positive stride the lower boundary must be smaller than the
|
|
|
2f9ed3 |
+ upper boundary. */
|
|
|
2f9ed3 |
+ if ((range->stride < 0 && range->low < range->high)
|
|
|
2f9ed3 |
+ || (range->stride > 0 && range->low > range->high))
|
|
|
2f9ed3 |
+ error (_("Wrong value provided for stride and boundaries"));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ break;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ case SUBSCRIPT_INDEX:
|
|
|
2f9ed3 |
+ break;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ array_type = TYPE_TARGET_TYPE (array_type);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Reset ARRAY_TYPE before slicing.*/
|
|
|
2f9ed3 |
+ array_type = check_typedef (value_type (new_array));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Traverse the array from right to left and evaluate each corresponding
|
|
|
2f9ed3 |
+ user input. VALUE_SUBSCRIPT is called for every index, until a range
|
|
|
2f9ed3 |
+ expression is evaluated. After a range expression has been evaluated,
|
|
|
2f9ed3 |
+ every subsequent expression is also treated as a range. */
|
|
|
2f9ed3 |
+ for (i = nargs - 1; i >= 0; i--)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ struct subscript_store *index = &subscript_array[i];
|
|
|
2f9ed3 |
+ struct type *index_type = TYPE_INDEX_TYPE (array_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ switch (index->kind)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ case SUBSCRIPT_RANGE:
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* When we hit the first range specified by the user, we must
|
|
|
2f9ed3 |
+ treat any subsequent user entry as a range. We simply
|
|
|
2f9ed3 |
+ increment DIM_COUNT which tells us how many times we are
|
|
|
2f9ed3 |
+ calling VALUE_SLICE_1. */
|
|
|
2f9ed3 |
+ subscript_range *range = &index->U.range;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* DIM_COUNT counts every user argument that is treated as a range.
|
|
|
2f9ed3 |
+ This is necessary for expressions like 'print array(7, 8:9).
|
|
|
2f9ed3 |
+ Here the first argument is a literal, but must be treated as a
|
|
|
2f9ed3 |
+ range argument to allow the correct output representation. */
|
|
|
2f9ed3 |
+ dim_count++;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ new_array
|
|
|
2f9ed3 |
+ = value_slice_1 (new_array, range->low,
|
|
|
2f9ed3 |
+ range->high - range->low + 1,
|
|
|
2f9ed3 |
+ range->stride, dim_count);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ break;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ case SUBSCRIPT_INDEX:
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ /* DIM_COUNT only stays '0' when no range argument was processed
|
|
|
2f9ed3 |
+ before, starting from the last dimension. This way we can
|
|
|
2f9ed3 |
+ reduce the number of dimensions from the result array.
|
|
|
2f9ed3 |
+ However, if a range has been processed before an index, we
|
|
|
2f9ed3 |
+ treat the index like a range with equal low- and high bounds
|
|
|
2f9ed3 |
+ to get the value offset right. */
|
|
|
2f9ed3 |
+ if (dim_count == 0)
|
|
|
2f9ed3 |
+ new_array
|
|
|
2f9ed3 |
+ = value_subscripted_rvalue (new_array, index->U.number,
|
|
|
2f9ed3 |
+ f77_get_lowerbound (value_type
|
|
|
2f9ed3 |
+ (new_array)));
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ dim_count++;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* We might end up here, because we have to treat the provided
|
|
|
2f9ed3 |
+ index like a range. But now VALUE_SUBSCRIPTED_RVALUE
|
|
|
2f9ed3 |
+ cannot do the range checks for us. So we have to make sure
|
|
|
2f9ed3 |
+ ourselves that the user provided index is inside the
|
|
|
2f9ed3 |
+ array bounds. Throw an error if not. */
|
|
|
2f9ed3 |
+ if (index->U.number < TYPE_LOW_BOUND (index_type)
|
|
|
2f9ed3 |
+ && index->U.number > TYPE_HIGH_BOUND (index_type))
|
|
|
2f9ed3 |
+ error (_("provided bound(s) outside array bound(s)"));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ if (index->U.number > TYPE_LOW_BOUND (index_type)
|
|
|
2f9ed3 |
+ && index->U.number > TYPE_HIGH_BOUND (index_type))
|
|
|
2f9ed3 |
+ error (_("provided bound(s) outside array bound(s)"));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ new_array = value_slice_1 (new_array,
|
|
|
2f9ed3 |
+ index->U.number,
|
|
|
2f9ed3 |
+ 1, /* COUNT is '1' element */
|
|
|
2f9ed3 |
+ 1, /* STRIDE set to '1' */
|
|
|
2f9ed3 |
+ dim_count);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ break;
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ array_type = TYPE_TARGET_TYPE (array_type);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* With DIM_COUNT > 1 we currently have a one dimensional array, but expect
|
|
|
2f9ed3 |
+ an array of arrays, depending on how many ranges have been provided by
|
|
|
2f9ed3 |
+ the user. So we need to rebuild the array dimensions for printing it
|
|
|
2f9ed3 |
+ correctly.
|
|
|
2f9ed3 |
+ Starting from right to left in the user input, after we hit the first
|
|
|
2f9ed3 |
+ range argument every subsequent argument is also treated as a range.
|
|
|
2f9ed3 |
+ E.g.:
|
|
|
2f9ed3 |
+ "p ary(3, 7, 2:15)" in Fortran has only 1 dimension, but we calculated 3
|
|
|
2f9ed3 |
+ ranges.
|
|
|
2f9ed3 |
+ "p ary(3, 7:12, 4)" in Fortran has only 1 dimension, but we calculated 2
|
|
|
2f9ed3 |
+ ranges.
|
|
|
2f9ed3 |
+ "p ary(2:4, 5, 7)" in Fortran has only 1 dimension, and we calculated 1
|
|
|
2f9ed3 |
+ range. */
|
|
|
2f9ed3 |
+ if (dim_count > 1)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ struct value *v = NULL;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ elt_type = TYPE_TARGET_TYPE (value_type (new_array));
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- return value_slice (array, low_bound, high_bound - low_bound + 1);
|
|
|
2f9ed3 |
+ /* Every SUBSCRIPT_RANGE in the user input signifies an actual range in
|
|
|
2f9ed3 |
+ the output array. So we traverse the SUBSCRIPT_ARRAY again, looking
|
|
|
2f9ed3 |
+ for a range entry. When we find one, we use the range info to create
|
|
|
2f9ed3 |
+ an additional range_type to set the correct bounds and dimensions for
|
|
|
2f9ed3 |
+ the output array. In addition, we may have a stride value that is not
|
|
|
2f9ed3 |
+ '1', forcing us to adjust the number of elements in a range, according
|
|
|
2f9ed3 |
+ to the stride value. */
|
|
|
2f9ed3 |
+ for (i = 0; i < nargs; i++)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ struct subscript_store *index = &subscript_array[i];
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ if (index->kind == SUBSCRIPT_RANGE)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ struct type *range_type, *interim_array_type;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ int new_length;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* The length of a sub-dimension with all elements between the
|
|
|
2f9ed3 |
+ bounds plus the start element itself. It may be modified by
|
|
|
2f9ed3 |
+ a user provided stride value. */
|
|
|
2f9ed3 |
+ new_length = index->U.range.high - index->U.range.low;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ new_length /= index->U.range.stride;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ range_type
|
|
|
2f9ed3 |
+ = create_static_range_type (NULL,
|
|
|
2f9ed3 |
+ elt_type,
|
|
|
2f9ed3 |
+ index->U.range.low,
|
|
|
2f9ed3 |
+ index->U.range.low + new_length);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ interim_array_type = create_array_type (NULL,
|
|
|
2f9ed3 |
+ elt_type,
|
|
|
2f9ed3 |
+ range_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ TYPE_CODE (interim_array_type)
|
|
|
2f9ed3 |
+ = TYPE_CODE (value_type (new_array));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ v = allocate_value (interim_array_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ elt_type = value_type (v);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ value_contents_copy (v, 0, new_array, 0, TYPE_LENGTH (elt_type));
|
|
|
2f9ed3 |
+ return v;
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ return new_array;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
@@ -1242,19 +1537,6 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
|
|
|
2f9ed3 |
return eval_call (exp, noside, nargs, argvec, var_func_name, expect_type);
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
-/* Helper for skipping all the arguments in an undetermined argument list.
|
|
|
2f9ed3 |
- This function was designed for use in the OP_F77_UNDETERMINED_ARGLIST
|
|
|
2f9ed3 |
- case of evaluate_subexp_standard as multiple, but not all, code paths
|
|
|
2f9ed3 |
- require a generic skip. */
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
-static void
|
|
|
2f9ed3 |
-skip_undetermined_arglist (int nargs, struct expression *exp, int *pos,
|
|
|
2f9ed3 |
- enum noside noside)
|
|
|
2f9ed3 |
-{
|
|
|
2f9ed3 |
- for (int i = 0; i < nargs; ++i)
|
|
|
2f9ed3 |
- evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
2f9ed3 |
-}
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
struct value *
|
|
|
2f9ed3 |
evaluate_subexp_standard (struct type *expect_type,
|
|
|
2f9ed3 |
struct expression *exp, int *pos,
|
|
|
2f9ed3 |
@@ -1949,33 +2231,8 @@ evaluate_subexp_standard (struct type *expect_type,
|
|
|
2f9ed3 |
switch (code)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
case TYPE_CODE_ARRAY:
|
|
|
2f9ed3 |
- if (exp->elts[*pos].opcode == OP_RANGE)
|
|
|
2f9ed3 |
- return value_f90_subarray (arg1, exp, pos, noside);
|
|
|
2f9ed3 |
- else
|
|
|
2f9ed3 |
- {
|
|
|
2f9ed3 |
- if (noside == EVAL_SKIP)
|
|
|
2f9ed3 |
- {
|
|
|
2f9ed3 |
- skip_undetermined_arglist (nargs, exp, pos, noside);
|
|
|
2f9ed3 |
- /* Return the dummy value with the correct type. */
|
|
|
2f9ed3 |
- return arg1;
|
|
|
2f9ed3 |
- }
|
|
|
2f9ed3 |
- goto multi_f77_subscript;
|
|
|
2f9ed3 |
- }
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
case TYPE_CODE_STRING:
|
|
|
2f9ed3 |
- if (exp->elts[*pos].opcode == OP_RANGE)
|
|
|
2f9ed3 |
- return value_f90_subarray (arg1, exp, pos, noside);
|
|
|
2f9ed3 |
- else
|
|
|
2f9ed3 |
- {
|
|
|
2f9ed3 |
- if (noside == EVAL_SKIP)
|
|
|
2f9ed3 |
- {
|
|
|
2f9ed3 |
- skip_undetermined_arglist (nargs, exp, pos, noside);
|
|
|
2f9ed3 |
- /* Return the dummy value with the correct type. */
|
|
|
2f9ed3 |
- return arg1;
|
|
|
2f9ed3 |
- }
|
|
|
2f9ed3 |
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
|
|
|
2f9ed3 |
- return value_subscript (arg1, value_as_long (arg2));
|
|
|
2f9ed3 |
- }
|
|
|
2f9ed3 |
+ return value_f90_subarray (arg1, exp, pos, nargs, noside);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
case TYPE_CODE_PTR:
|
|
|
2f9ed3 |
case TYPE_CODE_FUNC:
|
|
|
2f9ed3 |
@@ -2372,49 +2629,6 @@ evaluate_subexp_standard (struct type *expect_type,
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
return (arg1);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- multi_f77_subscript:
|
|
|
2f9ed3 |
- {
|
|
|
2f9ed3 |
- LONGEST subscript_array[MAX_FORTRAN_DIMS];
|
|
|
2f9ed3 |
- int ndimensions = 1, i;
|
|
|
2f9ed3 |
- struct value *array = arg1;
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- if (nargs > MAX_FORTRAN_DIMS)
|
|
|
2f9ed3 |
- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- ndimensions = calc_f77_array_dims (type);
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- if (nargs != ndimensions)
|
|
|
2f9ed3 |
- error (_("Wrong number of subscripts"));
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- gdb_assert (nargs > 0);
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- /* Now that we know we have a legal array subscript expression
|
|
|
2f9ed3 |
- let us actually find out where this element exists in the array. */
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- /* Take array indices left to right. */
|
|
|
2f9ed3 |
- for (i = 0; i < nargs; i++)
|
|
|
2f9ed3 |
- {
|
|
|
2f9ed3 |
- /* Evaluate each subscript; it must be a legal integer in F77. */
|
|
|
2f9ed3 |
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- /* Fill in the subscript array. */
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- subscript_array[i] = value_as_long (arg2);
|
|
|
2f9ed3 |
- }
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- /* Internal type of array is arranged right to left. */
|
|
|
2f9ed3 |
- for (i = nargs; i > 0; i--)
|
|
|
2f9ed3 |
- {
|
|
|
2f9ed3 |
- struct type *array_type = check_typedef (value_type (array));
|
|
|
2f9ed3 |
- LONGEST index = subscript_array[i - 1];
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- array = value_subscripted_rvalue (array, index,
|
|
|
2f9ed3 |
- f77_get_lowerbound (array_type));
|
|
|
2f9ed3 |
- }
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
- return array;
|
|
|
2f9ed3 |
- }
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
case BINOP_LOGICAL_AND:
|
|
|
2f9ed3 |
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
2f9ed3 |
if (noside == EVAL_SKIP)
|
|
|
2f9ed3 |
@@ -3334,6 +3548,9 @@ calc_f77_array_dims (struct type *array_type)
|
|
|
2f9ed3 |
int ndimen = 1;
|
|
|
2f9ed3 |
struct type *tmp_type;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
+ if (TYPE_CODE (array_type) == TYPE_CODE_STRING)
|
|
|
2f9ed3 |
+ return 1;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY))
|
|
|
2f9ed3 |
error (_("Can't get dimensions for a non-array type"));
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
diff --git a/gdb/expprint.c b/gdb/expprint.c
|
|
|
2f9ed3 |
--- a/gdb/expprint.c
|
|
|
2f9ed3 |
+++ b/gdb/expprint.c
|
|
|
2f9ed3 |
@@ -578,17 +578,14 @@ print_subexp_standard (struct expression *exp, int *pos,
|
|
|
2f9ed3 |
longest_to_int (exp->elts[pc + 1].longconst);
|
|
|
2f9ed3 |
*pos += 2;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- if (range_type == NONE_BOUND_DEFAULT_EXCLUSIVE
|
|
|
2f9ed3 |
- || range_type == LOW_BOUND_DEFAULT_EXCLUSIVE)
|
|
|
2f9ed3 |
+ if ((range_type & SUBARRAY_HIGH_BOUND_EXCLUSIVE)
|
|
|
2f9ed3 |
+ == SUBARRAY_HIGH_BOUND_EXCLUSIVE)
|
|
|
2f9ed3 |
fputs_filtered ("EXCLUSIVE_", stream);
|
|
|
2f9ed3 |
fputs_filtered ("RANGE(", stream);
|
|
|
2f9ed3 |
- if (range_type == HIGH_BOUND_DEFAULT
|
|
|
2f9ed3 |
- || range_type == NONE_BOUND_DEFAULT
|
|
|
2f9ed3 |
- || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE)
|
|
|
2f9ed3 |
+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
|
|
|
2f9ed3 |
print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
|
|
|
2f9ed3 |
fputs_filtered ("..", stream);
|
|
|
2f9ed3 |
- if (range_type == LOW_BOUND_DEFAULT
|
|
|
2f9ed3 |
- || range_type == NONE_BOUND_DEFAULT)
|
|
|
2f9ed3 |
+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
|
|
|
2f9ed3 |
print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
|
|
|
2f9ed3 |
fputs_filtered (")", stream);
|
|
|
2f9ed3 |
return;
|
|
|
2f9ed3 |
@@ -1105,22 +1102,24 @@ dump_subexp_body_standard (struct expression *exp,
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
switch (range_type)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- case BOTH_BOUND_DEFAULT:
|
|
|
2f9ed3 |
+ case SUBARRAY_NONE_BOUND:
|
|
|
2f9ed3 |
fputs_filtered ("Range '..'", stream);
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
- case LOW_BOUND_DEFAULT:
|
|
|
2f9ed3 |
+ case SUBARRAY_HIGH_BOUND:
|
|
|
2f9ed3 |
fputs_filtered ("Range '..EXP'", stream);
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
- case LOW_BOUND_DEFAULT_EXCLUSIVE:
|
|
|
2f9ed3 |
- fputs_filtered ("ExclusiveRange '..EXP'", stream);
|
|
|
2f9ed3 |
- break;
|
|
|
2f9ed3 |
- case HIGH_BOUND_DEFAULT:
|
|
|
2f9ed3 |
+ case SUBARRAY_LOW_BOUND:
|
|
|
2f9ed3 |
fputs_filtered ("Range 'EXP..'", stream);
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
- case NONE_BOUND_DEFAULT:
|
|
|
2f9ed3 |
+ case (SUBARRAY_LOW_BOUND
|
|
|
2f9ed3 |
+ | SUBARRAY_HIGH_BOUND
|
|
|
2f9ed3 |
+ | SUBARRAY_HIGH_BOUND_EXCLUSIVE):
|
|
|
2f9ed3 |
+ fputs_filtered ("ExclusiveRange '..EXP'", stream);
|
|
|
2f9ed3 |
+ break;
|
|
|
2f9ed3 |
+ case (SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND):
|
|
|
2f9ed3 |
fputs_filtered ("Range 'EXP..EXP'", stream);
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
- case NONE_BOUND_DEFAULT_EXCLUSIVE:
|
|
|
2f9ed3 |
+ case (SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE):
|
|
|
2f9ed3 |
fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream);
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
default:
|
|
|
2f9ed3 |
@@ -1128,11 +1127,9 @@ dump_subexp_body_standard (struct expression *exp,
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- if (range_type == HIGH_BOUND_DEFAULT
|
|
|
2f9ed3 |
- || range_type == NONE_BOUND_DEFAULT)
|
|
|
2f9ed3 |
+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
|
|
|
2f9ed3 |
elt = dump_subexp (exp, stream, elt);
|
|
|
2f9ed3 |
- if (range_type == LOW_BOUND_DEFAULT
|
|
|
2f9ed3 |
- || range_type == NONE_BOUND_DEFAULT)
|
|
|
2f9ed3 |
+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
|
|
|
2f9ed3 |
elt = dump_subexp (exp, stream, elt);
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
diff --git a/gdb/expression.h b/gdb/expression.h
|
|
|
2f9ed3 |
--- a/gdb/expression.h
|
|
|
2f9ed3 |
+++ b/gdb/expression.h
|
|
|
2f9ed3 |
@@ -150,28 +150,27 @@ extern void dump_raw_expression (struct expression *,
|
|
|
2f9ed3 |
struct ui_file *, const char *);
|
|
|
2f9ed3 |
extern void dump_prefix_expression (struct expression *, struct ui_file *);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
-/* In an OP_RANGE expression, either bound could be empty, indicating
|
|
|
2f9ed3 |
- that its value is by default that of the corresponding bound of the
|
|
|
2f9ed3 |
- array or string. Also, the upper end of the range can be exclusive
|
|
|
2f9ed3 |
- or inclusive. So we have six sorts of subrange. This enumeration
|
|
|
2f9ed3 |
- type is to identify this. */
|
|
|
2f9ed3 |
+/* In an OP_RANGE expression, either bound can be provided by the
|
|
|
2f9ed3 |
+ user, or not. In addition to this, the user can also specify a
|
|
|
2f9ed3 |
+ stride value to indicated only certain elements of the array.
|
|
|
2f9ed3 |
+ Also, the upper end of the range can be exclusive or inclusive.
|
|
|
2f9ed3 |
+ This enumeration type is to identify this. */
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
enum range_type
|
|
|
2f9ed3 |
-{
|
|
|
2f9ed3 |
- /* Neither the low nor the high bound was given -- so this refers to
|
|
|
2f9ed3 |
- the entire available range. */
|
|
|
2f9ed3 |
- BOTH_BOUND_DEFAULT,
|
|
|
2f9ed3 |
- /* The low bound was not given and the high bound is inclusive. */
|
|
|
2f9ed3 |
- LOW_BOUND_DEFAULT,
|
|
|
2f9ed3 |
- /* The high bound was not given and the low bound in inclusive. */
|
|
|
2f9ed3 |
- HIGH_BOUND_DEFAULT,
|
|
|
2f9ed3 |
- /* Both bounds were given and both are inclusive. */
|
|
|
2f9ed3 |
- NONE_BOUND_DEFAULT,
|
|
|
2f9ed3 |
- /* The low bound was not given and the high bound is exclusive. */
|
|
|
2f9ed3 |
- NONE_BOUND_DEFAULT_EXCLUSIVE,
|
|
|
2f9ed3 |
- /* Both bounds were given. The low bound is inclusive and the high
|
|
|
2f9ed3 |
- bound is exclusive. */
|
|
|
2f9ed3 |
- LOW_BOUND_DEFAULT_EXCLUSIVE,
|
|
|
2f9ed3 |
-};
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ SUBARRAY_NONE_BOUND = 0x0, /* "( : )" */
|
|
|
2f9ed3 |
+ SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" */
|
|
|
2f9ed3 |
+ SUBARRAY_HIGH_BOUND = 0x2, /* "(:high)" */
|
|
|
2f9ed3 |
+ SUBARRAY_STRIDE = 0x4, /* "(::stride)" */
|
|
|
2f9ed3 |
+ /* The low bound was not given and the high bound is exclusive.
|
|
|
2f9ed3 |
+ In this case we always use (SUBARRAY_HIGH_BOUND |
|
|
|
2f9ed3 |
+ SUBARRAY_HIGH_BOUND_EXCLUSIVE). */
|
|
|
2f9ed3 |
+ SUBARRAY_HIGH_BOUND_EXCLUSIVE = 0x8,
|
|
|
2f9ed3 |
+ /* Both bounds were given. The low bound is inclusive and the high
|
|
|
2f9ed3 |
+ bound is exclusive. In this case, we use (SUBARRAY_LOW_BOUND |
|
|
|
2f9ed3 |
+ SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE). */
|
|
|
2f9ed3 |
+ // SUBARRAY_LOW_BOUND_EXCLUSIVE = (SUBARRAY_LOW_BOUND
|
|
|
2f9ed3 |
+ // | SUBARRAY_HIGH_BOUND_EXCLUSIVE),
|
|
|
2f9ed3 |
+ };
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
#endif /* !defined (EXPRESSION_H) */
|
|
|
2f9ed3 |
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
|
|
|
2f9ed3 |
--- a/gdb/f-exp.y
|
|
|
2f9ed3 |
+++ b/gdb/f-exp.y
|
|
|
2f9ed3 |
@@ -257,31 +257,63 @@ arglist : subrange
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
arglist : arglist ',' exp %prec ABOVE_COMMA
|
|
|
2f9ed3 |
{ arglist_len++; }
|
|
|
2f9ed3 |
+ | arglist ',' subrange %prec ABOVE_COMMA
|
|
|
2f9ed3 |
+ { arglist_len++; }
|
|
|
2f9ed3 |
;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
/* There are four sorts of subrange types in F90. */
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
subrange: exp ':' exp %prec ABOVE_COMMA
|
|
|
2f9ed3 |
- { write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
- write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT);
|
|
|
2f9ed3 |
+ { write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
+ write_exp_elt_longcst (pstate,
|
|
|
2f9ed3 |
+ SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND);
|
|
|
2f9ed3 |
write_exp_elt_opcode (pstate, OP_RANGE); }
|
|
|
2f9ed3 |
;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
subrange: exp ':' %prec ABOVE_COMMA
|
|
|
2f9ed3 |
{ write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
- write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT);
|
|
|
2f9ed3 |
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND);
|
|
|
2f9ed3 |
write_exp_elt_opcode (pstate, OP_RANGE); }
|
|
|
2f9ed3 |
;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
subrange: ':' exp %prec ABOVE_COMMA
|
|
|
2f9ed3 |
{ write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
- write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT);
|
|
|
2f9ed3 |
+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND);
|
|
|
2f9ed3 |
write_exp_elt_opcode (pstate, OP_RANGE); }
|
|
|
2f9ed3 |
;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
subrange: ':' %prec ABOVE_COMMA
|
|
|
2f9ed3 |
{ write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
- write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT);
|
|
|
2f9ed3 |
+ write_exp_elt_longcst (pstate, SUBARRAY_NONE_BOUND);
|
|
|
2f9ed3 |
+ write_exp_elt_opcode (pstate, OP_RANGE); }
|
|
|
2f9ed3 |
+ ;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+/* Each subrange type can have a stride argument. */
|
|
|
2f9ed3 |
+subrange: exp ':' exp ':' exp %prec ABOVE_COMMA
|
|
|
2f9ed3 |
+ { write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
|
|
|
2f9ed3 |
+ | SUBARRAY_HIGH_BOUND
|
|
|
2f9ed3 |
+ | SUBARRAY_STRIDE);
|
|
|
2f9ed3 |
+ write_exp_elt_opcode (pstate, OP_RANGE); }
|
|
|
2f9ed3 |
+ ;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+subrange: exp ':' ':' exp %prec ABOVE_COMMA
|
|
|
2f9ed3 |
+ { write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
|
|
|
2f9ed3 |
+ | SUBARRAY_STRIDE);
|
|
|
2f9ed3 |
+ write_exp_elt_opcode (pstate, OP_RANGE); }
|
|
|
2f9ed3 |
+ ;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+subrange: ':' exp ':' exp %prec ABOVE_COMMA
|
|
|
2f9ed3 |
+ { write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND
|
|
|
2f9ed3 |
+ | SUBARRAY_STRIDE);
|
|
|
2f9ed3 |
+ write_exp_elt_opcode (pstate, OP_RANGE); }
|
|
|
2f9ed3 |
+ ;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+subrange: ':' ':' exp %prec ABOVE_COMMA
|
|
|
2f9ed3 |
+ { write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
2f9ed3 |
+ write_exp_elt_longcst (pstate, SUBARRAY_STRIDE);
|
|
|
2f9ed3 |
write_exp_elt_opcode (pstate, OP_RANGE); }
|
|
|
2f9ed3 |
;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
|
|
|
2f9ed3 |
--- a/gdb/f-valprint.c
|
|
|
2f9ed3 |
+++ b/gdb/f-valprint.c
|
|
|
2f9ed3 |
@@ -119,8 +119,14 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (nss != ndimensions)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- size_t dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
|
|
|
2f9ed3 |
+ size_t dim_size;
|
|
|
2f9ed3 |
size_t offs = 0;
|
|
|
2f9ed3 |
+ LONGEST byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ if (byte_stride)
|
|
|
2f9ed3 |
+ dim_size = byte_stride;
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
for (i = lowerbound;
|
|
|
2f9ed3 |
(i < upperbound + 1 && (*elts) < options->print_max);
|
|
|
2f9ed3 |
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
|
|
|
2f9ed3 |
--- a/gdb/gdbtypes.c
|
|
|
2f9ed3 |
+++ b/gdb/gdbtypes.c
|
|
|
2f9ed3 |
@@ -911,7 +911,8 @@ operator== (const range_bounds &l, const range_bounds &r)
|
|
|
2f9ed3 |
struct type *
|
|
|
2f9ed3 |
create_range_type (struct type *result_type, struct type *index_type,
|
|
|
2f9ed3 |
const struct dynamic_prop *low_bound,
|
|
|
2f9ed3 |
- const struct dynamic_prop *high_bound)
|
|
|
2f9ed3 |
+ const struct dynamic_prop *high_bound,
|
|
|
2f9ed3 |
+ const struct dynamic_prop *stride)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
if (result_type == NULL)
|
|
|
2f9ed3 |
result_type = alloc_type_copy (index_type);
|
|
|
2f9ed3 |
@@ -926,6 +927,7 @@ create_range_type (struct type *result_type, struct type *index_type,
|
|
|
2f9ed3 |
TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
|
|
|
2f9ed3 |
TYPE_RANGE_DATA (result_type)->low = *low_bound;
|
|
|
2f9ed3 |
TYPE_RANGE_DATA (result_type)->high = *high_bound;
|
|
|
2f9ed3 |
+ TYPE_RANGE_DATA (result_type)->stride = *stride;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0)
|
|
|
2f9ed3 |
TYPE_UNSIGNED (result_type) = 1;
|
|
|
2f9ed3 |
@@ -954,7 +956,7 @@ struct type *
|
|
|
2f9ed3 |
create_static_range_type (struct type *result_type, struct type *index_type,
|
|
|
2f9ed3 |
LONGEST low_bound, LONGEST high_bound)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- struct dynamic_prop low, high;
|
|
|
2f9ed3 |
+ struct dynamic_prop low, high, stride;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
low.kind = PROP_CONST;
|
|
|
2f9ed3 |
low.data.const_val = low_bound;
|
|
|
2f9ed3 |
@@ -962,7 +964,11 @@ create_static_range_type (struct type *result_type, struct type *index_type,
|
|
|
2f9ed3 |
high.kind = PROP_CONST;
|
|
|
2f9ed3 |
high.data.const_val = high_bound;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- result_type = create_range_type (result_type, index_type, &low, &high);
|
|
|
2f9ed3 |
+ stride.kind = PROP_CONST;
|
|
|
2f9ed3 |
+ stride.data.const_val = 0;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ result_type = create_range_type (result_type, index_type,
|
|
|
2f9ed3 |
+ &low, &high, &stride);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
return result_type;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
@@ -1180,16 +1186,20 @@ create_array_type_with_stride (struct type *result_type,
|
|
|
2f9ed3 |
&& (!type_not_associated (result_type)
|
|
|
2f9ed3 |
&& !type_not_allocated (result_type)))
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- LONGEST low_bound, high_bound;
|
|
|
2f9ed3 |
+ LONGEST low_bound, high_bound, byte_stride;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
|
|
|
2f9ed3 |
low_bound = high_bound = 0;
|
|
|
2f9ed3 |
element_type = check_typedef (element_type);
|
|
|
2f9ed3 |
+ byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
/* Be careful when setting the array length. Ada arrays can be
|
|
|
2f9ed3 |
empty arrays with the high_bound being smaller than the low_bound.
|
|
|
2f9ed3 |
In such cases, the array length should be zero. */
|
|
|
2f9ed3 |
if (high_bound < low_bound)
|
|
|
2f9ed3 |
TYPE_LENGTH (result_type) = 0;
|
|
|
2f9ed3 |
+ else if (byte_stride > 0)
|
|
|
2f9ed3 |
+ TYPE_LENGTH (result_type) = byte_stride * (high_bound - low_bound + 1);
|
|
|
2f9ed3 |
else if (bit_stride > 0)
|
|
|
2f9ed3 |
TYPE_LENGTH (result_type) =
|
|
|
2f9ed3 |
(bit_stride * (high_bound - low_bound + 1) + 7) / 8;
|
|
|
2f9ed3 |
@@ -1990,12 +2000,12 @@ resolve_dynamic_range (struct type *dyn_range_type,
|
|
|
2f9ed3 |
CORE_ADDR value;
|
|
|
2f9ed3 |
struct type *static_range_type, *static_target_type;
|
|
|
2f9ed3 |
const struct dynamic_prop *prop;
|
|
|
2f9ed3 |
- struct dynamic_prop low_bound, high_bound;
|
|
|
2f9ed3 |
+ struct dynamic_prop low_bound, high_bound, stride;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
prop = &TYPE_RANGE_DATA (dyn_range_type)->low;
|
|
|
2f9ed3 |
- if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
|
|
|
2f9ed3 |
+ if (dwarf2_evaluate_property_signed (prop, NULL, addr_stack, &value, 1))
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
low_bound.kind = PROP_CONST;
|
|
|
2f9ed3 |
low_bound.data.const_val = value;
|
|
|
2f9ed3 |
@@ -2007,7 +2017,7 @@ resolve_dynamic_range (struct type *dyn_range_type,
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
prop = &TYPE_RANGE_DATA (dyn_range_type)->high;
|
|
|
2f9ed3 |
- if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
|
|
|
2f9ed3 |
+ if (dwarf2_evaluate_property_signed (prop, NULL, addr_stack, &value, 1))
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
high_bound.kind = PROP_CONST;
|
|
|
2f9ed3 |
high_bound.data.const_val = value;
|
|
|
2f9ed3 |
@@ -2022,12 +2032,20 @@ resolve_dynamic_range (struct type *dyn_range_type,
|
|
|
2f9ed3 |
high_bound.data.const_val = 0;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
+ prop = &TYPE_RANGE_DATA (dyn_range_type)->stride;
|
|
|
2f9ed3 |
+ if (dwarf2_evaluate_property_signed (prop, NULL, addr_stack, &value, 1))
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ stride.kind = PROP_CONST;
|
|
|
2f9ed3 |
+ stride.data.const_val = value;
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
static_target_type
|
|
|
2f9ed3 |
= resolve_dynamic_type_internal (TYPE_TARGET_TYPE (dyn_range_type),
|
|
|
2f9ed3 |
addr_stack, 0);
|
|
|
2f9ed3 |
static_range_type = create_range_type (copy_type (dyn_range_type),
|
|
|
2f9ed3 |
static_target_type,
|
|
|
2f9ed3 |
- &low_bound, &high_bound);
|
|
|
2f9ed3 |
+ &low_bound, &high_bound, &stride);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
TYPE_RANGE_DATA (static_range_type)->flag_bound_evaluated = 1;
|
|
|
2f9ed3 |
return static_range_type;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
|
|
|
2f9ed3 |
--- a/gdb/gdbtypes.h
|
|
|
2f9ed3 |
+++ b/gdb/gdbtypes.h
|
|
|
2f9ed3 |
@@ -614,6 +614,10 @@ struct range_bounds
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
struct dynamic_prop high;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
+ /* * Stride of range. */
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ struct dynamic_prop stride;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
/* True if HIGH range bound contains the number of elements in the
|
|
|
2f9ed3 |
subrange. This affects how the final hight bound is computed. */
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
@@ -778,7 +782,6 @@ struct main_type
|
|
|
2f9ed3 |
/* * Union member used for range types. */
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
struct range_bounds *bounds;
|
|
|
2f9ed3 |
-
|
|
|
2f9ed3 |
} flds_bnds;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
/* * Slot to point to additional language-specific fields of this
|
|
|
2f9ed3 |
@@ -1327,6 +1330,15 @@ extern bool set_type_align (struct type *, ULONGEST);
|
|
|
2f9ed3 |
TYPE_RANGE_DATA(range_type)->high.kind
|
|
|
2f9ed3 |
#define TYPE_LOW_BOUND_KIND(range_type) \
|
|
|
2f9ed3 |
TYPE_RANGE_DATA(range_type)->low.kind
|
|
|
2f9ed3 |
+#define TYPE_BYTE_STRIDE(range_type) \
|
|
|
2f9ed3 |
+ TYPE_RANGE_DATA(range_type)->stride.data.const_val
|
|
|
2f9ed3 |
+#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
|
|
|
2f9ed3 |
+ TYPE_RANGE_DATA(range_type)->stride.data.locexpr
|
|
|
2f9ed3 |
+#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \
|
|
|
2f9ed3 |
+ TYPE_RANGE_DATA(range_type)->stride.data.loclist
|
|
|
2f9ed3 |
+#define TYPE_BYTE_STRIDE_KIND(range_type) \
|
|
|
2f9ed3 |
+ TYPE_RANGE_DATA(range_type)->stride.kind
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
/* Property accessors for the type data location. */
|
|
|
2f9ed3 |
#define TYPE_DATA_LOCATION(thistype) \
|
|
|
2f9ed3 |
@@ -1361,6 +1373,9 @@ extern bool set_type_align (struct type *, ULONGEST);
|
|
|
2f9ed3 |
TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
|
|
|
2f9ed3 |
#define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
|
|
|
2f9ed3 |
TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
|
|
|
2f9ed3 |
+#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \
|
|
|
2f9ed3 |
+ (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0)
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
|
|
|
2f9ed3 |
(TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
|
|
|
2f9ed3 |
@@ -1896,6 +1911,7 @@ extern struct type *create_array_type_with_stride
|
|
|
2f9ed3 |
struct dynamic_prop *, unsigned int);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
extern struct type *create_range_type (struct type *, struct type *,
|
|
|
2f9ed3 |
+ const struct dynamic_prop *,
|
|
|
2f9ed3 |
const struct dynamic_prop *,
|
|
|
2f9ed3 |
const struct dynamic_prop *);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
diff --git a/gdb/parse.c b/gdb/parse.c
|
|
|
2f9ed3 |
--- a/gdb/parse.c
|
|
|
2f9ed3 |
+++ b/gdb/parse.c
|
|
|
2f9ed3 |
@@ -989,24 +989,20 @@ operator_length_standard (const struct expression *expr, int endpos,
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
case OP_RANGE:
|
|
|
2f9ed3 |
oplen = 3;
|
|
|
2f9ed3 |
+ args = 0;
|
|
|
2f9ed3 |
range_type = (enum range_type)
|
|
|
2f9ed3 |
longest_to_int (expr->elts[endpos - 2].longconst);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- switch (range_type)
|
|
|
2f9ed3 |
- {
|
|
|
2f9ed3 |
- case LOW_BOUND_DEFAULT:
|
|
|
2f9ed3 |
- case LOW_BOUND_DEFAULT_EXCLUSIVE:
|
|
|
2f9ed3 |
- case HIGH_BOUND_DEFAULT:
|
|
|
2f9ed3 |
- args = 1;
|
|
|
2f9ed3 |
- break;
|
|
|
2f9ed3 |
- case BOTH_BOUND_DEFAULT:
|
|
|
2f9ed3 |
- args = 0;
|
|
|
2f9ed3 |
- break;
|
|
|
2f9ed3 |
- case NONE_BOUND_DEFAULT:
|
|
|
2f9ed3 |
- case NONE_BOUND_DEFAULT_EXCLUSIVE:
|
|
|
2f9ed3 |
- args = 2;
|
|
|
2f9ed3 |
- break;
|
|
|
2f9ed3 |
- }
|
|
|
2f9ed3 |
+ /* Increment the argument counter for each argument
|
|
|
2f9ed3 |
+ provided by the user. */
|
|
|
2f9ed3 |
+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
|
|
|
2f9ed3 |
+ args++;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
|
|
|
2f9ed3 |
+ args++;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ if ((range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
|
|
|
2f9ed3 |
+ args++;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
break;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
|
|
|
2f9ed3 |
--- a/gdb/rust-exp.y
|
|
|
2f9ed3 |
+++ b/gdb/rust-exp.y
|
|
|
2f9ed3 |
@@ -2475,24 +2475,28 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
case OP_RANGE:
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- enum range_type kind = BOTH_BOUND_DEFAULT;
|
|
|
2f9ed3 |
+ enum range_type kind = SUBARRAY_NONE_BOUND;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (operation->left.op != NULL)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
convert_ast_to_expression (operation->left.op, top);
|
|
|
2f9ed3 |
- kind = HIGH_BOUND_DEFAULT;
|
|
|
2f9ed3 |
+ kind = SUBARRAY_LOW_BOUND;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
if (operation->right.op != NULL)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
convert_ast_to_expression (operation->right.op, top);
|
|
|
2f9ed3 |
- if (kind == BOTH_BOUND_DEFAULT)
|
|
|
2f9ed3 |
- kind = (operation->inclusive
|
|
|
2f9ed3 |
- ? LOW_BOUND_DEFAULT : LOW_BOUND_DEFAULT_EXCLUSIVE);
|
|
|
2f9ed3 |
+ if (kind == SUBARRAY_NONE_BOUND)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ kind = (range_type) SUBARRAY_HIGH_BOUND;
|
|
|
2f9ed3 |
+ if (!operation->inclusive)
|
|
|
2f9ed3 |
+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
else
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- gdb_assert (kind == HIGH_BOUND_DEFAULT);
|
|
|
2f9ed3 |
- kind = (operation->inclusive
|
|
|
2f9ed3 |
- ? NONE_BOUND_DEFAULT : NONE_BOUND_DEFAULT_EXCLUSIVE);
|
|
|
2f9ed3 |
+ gdb_assert (kind == SUBARRAY_LOW_BOUND);
|
|
|
2f9ed3 |
+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND);
|
|
|
2f9ed3 |
+ if (!operation->inclusive)
|
|
|
2f9ed3 |
+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE);
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
else
|
|
|
2f9ed3 |
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
|
|
|
2f9ed3 |
--- a/gdb/rust-lang.c
|
|
|
2f9ed3 |
+++ b/gdb/rust-lang.c
|
|
|
2f9ed3 |
@@ -1193,13 +1193,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
|
|
|
2f9ed3 |
kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
|
|
|
2f9ed3 |
*pos += 3;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- if (kind == HIGH_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT
|
|
|
2f9ed3 |
- || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
|
|
|
2f9ed3 |
+ if ((kind & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
|
|
|
2f9ed3 |
low = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
2f9ed3 |
- if (kind == LOW_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT_EXCLUSIVE
|
|
|
2f9ed3 |
- || kind == NONE_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
|
|
|
2f9ed3 |
+ if ((kind & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
|
|
|
2f9ed3 |
high = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
2f9ed3 |
- bool inclusive = (kind == NONE_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT);
|
|
|
2f9ed3 |
+ bool inclusive = (!((kind & SUBARRAY_HIGH_BOUND_EXCLUSIVE) == SUBARRAY_HIGH_BOUND_EXCLUSIVE));
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (noside == EVAL_SKIP)
|
|
|
2f9ed3 |
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
|
|
|
2f9ed3 |
@@ -1288,7 +1286,7 @@ rust_compute_range (struct type *type, struct value *range,
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
*low = 0;
|
|
|
2f9ed3 |
*high = 0;
|
|
|
2f9ed3 |
- *kind = BOTH_BOUND_DEFAULT;
|
|
|
2f9ed3 |
+ *kind = SUBARRAY_NONE_BOUND;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (TYPE_NFIELDS (type) == 0)
|
|
|
2f9ed3 |
return;
|
|
|
2f9ed3 |
@@ -1296,15 +1294,14 @@ rust_compute_range (struct type *type, struct value *range,
|
|
|
2f9ed3 |
i = 0;
|
|
|
2f9ed3 |
if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- *kind = HIGH_BOUND_DEFAULT;
|
|
|
2f9ed3 |
+ *kind = SUBARRAY_LOW_BOUND;
|
|
|
2f9ed3 |
*low = value_as_long (value_field (range, 0));
|
|
|
2f9ed3 |
++i;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
if (TYPE_NFIELDS (type) > i
|
|
|
2f9ed3 |
&& strcmp (TYPE_FIELD_NAME (type, i), "end") == 0)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- *kind = (*kind == BOTH_BOUND_DEFAULT
|
|
|
2f9ed3 |
- ? LOW_BOUND_DEFAULT : NONE_BOUND_DEFAULT);
|
|
|
2f9ed3 |
+ *kind = (range_type) (*kind | SUBARRAY_HIGH_BOUND);
|
|
|
2f9ed3 |
*high = value_as_long (value_field (range, i));
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (rust_inclusive_range_type_p (type))
|
|
|
2f9ed3 |
@@ -1322,7 +1319,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
|
|
|
2f9ed3 |
struct type *rhstype;
|
|
|
2f9ed3 |
LONGEST low, high_bound;
|
|
|
2f9ed3 |
/* Initialized to appease the compiler. */
|
|
|
2f9ed3 |
- enum range_type kind = BOTH_BOUND_DEFAULT;
|
|
|
2f9ed3 |
+ enum range_type kind = SUBARRAY_NONE_BOUND;
|
|
|
2f9ed3 |
LONGEST high = 0;
|
|
|
2f9ed3 |
int want_slice = 0;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
@@ -1420,7 +1417,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
|
|
|
2f9ed3 |
error (_("Cannot subscript non-array type"));
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (want_slice
|
|
|
2f9ed3 |
- && (kind == BOTH_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT))
|
|
|
2f9ed3 |
+ && ((kind & SUBARRAY_LOW_BOUND) != SUBARRAY_LOW_BOUND))
|
|
|
2f9ed3 |
low = low_bound;
|
|
|
2f9ed3 |
if (low < 0)
|
|
|
2f9ed3 |
error (_("Index less than zero"));
|
|
|
2f9ed3 |
@@ -1438,7 +1435,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
|
|
|
2f9ed3 |
CORE_ADDR addr;
|
|
|
2f9ed3 |
struct value *addrval, *tem;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- if (kind == BOTH_BOUND_DEFAULT || kind == HIGH_BOUND_DEFAULT)
|
|
|
2f9ed3 |
+ if ((kind & SUBARRAY_HIGH_BOUND) != SUBARRAY_HIGH_BOUND)
|
|
|
2f9ed3 |
high = high_bound;
|
|
|
2f9ed3 |
if (high < 0)
|
|
|
2f9ed3 |
error (_("High index less than zero"));
|
|
|
2f9ed3 |
diff --git a/gdb/testsuite/gdb.fortran/static-arrays.exp b/gdb/testsuite/gdb.fortran/static-arrays.exp
|
|
|
2f9ed3 |
new file mode 100644
|
|
|
2f9ed3 |
--- /dev/null
|
|
|
2f9ed3 |
+++ b/gdb/testsuite/gdb.fortran/static-arrays.exp
|
|
|
2f9ed3 |
@@ -0,0 +1,421 @@
|
|
|
2f9ed3 |
+# Copyright 2015 Free Software Foundation, Inc.
|
|
|
2f9ed3 |
+#
|
|
|
2f9ed3 |
+# Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
|
|
|
2f9ed3 |
+#
|
|
|
2f9ed3 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
2f9ed3 |
+# it under the terms of the GNU General Public License as published by
|
|
|
2f9ed3 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
2f9ed3 |
+# (at your option) any later version.
|
|
|
2f9ed3 |
+#
|
|
|
2f9ed3 |
+# This program is distributed in the hope that it will be useful,
|
|
|
2f9ed3 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2f9ed3 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
2f9ed3 |
+# GNU General Public License for more details.
|
|
|
2f9ed3 |
+#
|
|
|
2f9ed3 |
+# You should have received a copy of the GNU General Public License
|
|
|
2f9ed3 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+standard_testfile static-arrays.f90
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] } {
|
|
|
2f9ed3 |
+ return -1
|
|
|
2f9ed3 |
+}
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+if ![runto MAIN__] then {
|
|
|
2f9ed3 |
+ perror "couldn't run to breakpoint MAIN__"
|
|
|
2f9ed3 |
+ continue
|
|
|
2f9ed3 |
+}
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_breakpoint [gdb_get_line_number "BP1"]
|
|
|
2f9ed3 |
+gdb_continue_to_breakpoint "BP1" ".*BP1.*"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Tests subarrays of one dimensional arrays with subrange variations
|
|
|
2f9ed3 |
+gdb_test "print ar1" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \
|
|
|
2f9ed3 |
+ "print ar1."
|
|
|
2f9ed3 |
+gdb_test "print ar1\(4:7\)" "\\$\[0-9\]+ = \\(4, 5, 6, 7\\)" \
|
|
|
2f9ed3 |
+ "print ar1\(4:7\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(8:\)" "\\$\[0-9\]+ = \\(8, 9\\).*" \
|
|
|
2f9ed3 |
+ "print ar1\(8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(:3\)" "\\$\[0-9\]+ = \\(1, 2, 3\\).*" \
|
|
|
2f9ed3 |
+ "print ar1\(:3\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(:\)" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \
|
|
|
2f9ed3 |
+ "print ar1\(:\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Check assignment
|
|
|
2f9ed3 |
+gdb_test_no_output "set \$my_ary = ar1\(3:8\)"
|
|
|
2f9ed3 |
+gdb_test "print \$my_ary" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \
|
|
|
2f9ed3 |
+ "Assignment of subarray to variable"
|
|
|
2f9ed3 |
+gdb_test_no_output "set ar1\(5\) = 42"
|
|
|
2f9ed3 |
+ gdb_test "print ar1\(3:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(3, 4, 42, 6, 7, 8\\)" \
|
|
|
2f9ed3 |
+ "print ar1\(3:8\) after assignment"
|
|
|
2f9ed3 |
+gdb_test "print \$my_ary" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \
|
|
|
2f9ed3 |
+ "Assignment of subarray to variable after original array changed"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Test for subarrays of one dimensional arrays with literals
|
|
|
2f9ed3 |
+ gdb_test "print ar1\(3\)" "\\$\[0-9\]+ = 3" \
|
|
|
2f9ed3 |
+ "print ar1\(3\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Tests for subranges of 2 dimensional arrays with subrange variations
|
|
|
2f9ed3 |
+gdb_test "print ar2\(2:3, 3:4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 23, 33\\) \\( 24, 34\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(2:3, 3:4\)."
|
|
|
2f9ed3 |
+gdb_test "print ar2\(8:9,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(8:9,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(8:9,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(8:9,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar2\(8:,8:9\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(8:,8:9\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(8:,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(8:,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(8:,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(8:,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar2\(:2,2:3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 12, 22\\) \\( 13, 23\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(:2,2:3\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(:2,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 18, 28\\) \\( 19, 29\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(:2,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(:2,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 11, 21\\) \\( 12, 22\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(:2,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Test subranges of 2 dimensional arrays with literals and subrange variations
|
|
|
2f9ed3 |
+gdb_test "print ar2\(7, 3:6\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(73, 74, 75, 76\\)" \
|
|
|
2f9ed3 |
+ "print ar2\(7, 3:6\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(7,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(78, 79\\)" \
|
|
|
2f9ed3 |
+ "print ar2\(7,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(7,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(71, 72\\)" \
|
|
|
2f9ed3 |
+ "print ar2\(7,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar2\(7:8,4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(74, 84\\)" \
|
|
|
2f9ed3 |
+ "print ar2(7:8,4\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(8:,4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(84, 94\\)" \
|
|
|
2f9ed3 |
+ "print ar2\(8:,4\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(:2,4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(14, 24\\)" \
|
|
|
2f9ed3 |
+ "print ar2\(:2,4\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(3,4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = 34" \
|
|
|
2f9ed3 |
+ "print ar2\(3,4\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Test subarrays of 3 dimensional arrays with literals and subrange variations
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:4,3:4,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 237, 337, 437\\) \\( 247, 347, 447\\)\
|
|
|
2f9ed3 |
+ \\) \\( \\( 238, 338, 438\\) \\( 248, 348, 448\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:4,3:4,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,4:5,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 248, 348\\) \\( 258, 358\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 249, 349\\) \\( 259, 359\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,4:5,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,4:5,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 241, 341\\) \\( 251, 351\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 242, 342\\) \\( 252, 352\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,4:5,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,8:,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 287, 387\\) \\( 297, 397\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 288, 388\\) \\( 298, 398\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,8:,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,8:,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 288, 388\\) \\( 298, 398\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 289, 389\\) \\( 299, 399\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,8:,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,8:,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 281, 381\\) \\( 291, 391\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 282, 382\\) \\( 292, 392\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,8:,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,:2,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 217, 317\\) \\( 227, 327\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 218, 318\\) \\( 228, 328\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,:2,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,:2,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 218, 318\\) \\( 228, 328\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 219, 319\\) \\( 229, 329\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,:2,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,:2,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 211, 311\\) \\( 221, 321\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 212, 312\\) \\( 222, 322\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,:2,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,3:4,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 837, 937\\) \\( 847, 947\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 838, 938\\) \\( 848, 948\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,3:4,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,4:5,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 848, 948\\) \\( 858, 958\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 849, 949\\) \\( 859, 959\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,4:5,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,4:5,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 841, 941\\) \\( 851, 951\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 842, 942\\) \\( 852, 952\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,4:5,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,8:,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 887, 987\\) \\( 897, 997\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 888, 988\\) \\( 898, 998\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,8:,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,8:,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 888, 988\\) \\( 898, 998\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 889, 989\\) \\( 899, 999\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,8:,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,8:,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 881, 981\\) \\( 891, 991\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 882, 982\\) \\( 892, 992\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,8:,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,:2,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 817, 917\\) \\( 827, 927\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 818, 918\\) \\( 828, 928\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,:2,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,:2,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 818, 918\\) \\( 828, 928\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 819, 919\\) \\( 829, 929\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,:2,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,:2,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 811, 911\\) \\( 821, 921\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 812, 912\\) \\( 822, 922\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,:2,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,3:4,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 137, 237\\) \\( 147, 247\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 138, 238\\) \\( 148, 248\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3 \(:2,3:4,7:8\)."
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,3:4,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 138, 238\\) \\( 148, 248\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 139, 239\\) \\( 149, 249\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,3:4,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,3:4,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 131, 231\\) \\( 141, 241\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 132, 232\\) \\( 142, 242\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,3:4,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,8:,7:8\)" "\\$\[0-9\]+ = \\(\\( \\( 187, 287\\) \\(\
|
|
|
2f9ed3 |
+ 197, 297\\) \\) \\( \\( 188, 288\\) \\( 198, 298\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,8:,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,8:,8:\)" "\\$\[0-9\]+ = \\(\\( \\( 188, 288\\) \\( 198,\
|
|
|
2f9ed3 |
+ 298\\) \\) \\( \\( 189, 289\\) \\( 199, 299\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,8:,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,8:,:2\)" "\\$\[0-9\]+ = \\(\\( \\( 181, 281\\) \\( 191,\
|
|
|
2f9ed3 |
+ 291\\) \\) \\( \\( 182, 282\\) \\( 192, 292\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,8:,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,:2,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 117, 217\\) \\( 127, 227\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 118, 218\\) \\( 128, 228\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,:2,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,:2,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 118, 218\\) \\( 128, 228\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 119, 219\\) \\( 129, 229\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,:2,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,:2,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 112, 212\\) \\( 122, 222\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,:2,:2\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+#Tests for subarrays of 3 dimensional arrays with literals and subranges
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3,3:4,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 337, 347\\) \\( 338, 348\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3,3:4,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3,4:5,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 348, 358\\) \\( 349, 359\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3,4:5,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3,4:5,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 341, 351\\) \\( 342, 352\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3,4:5,:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3,4:5,3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(343, 353\\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3,4:5,3\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2,8:,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 287, 297\\) \\( 288, 298\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2,8:,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2,8:,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 288, 298\\) \\( 289, 299\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2,8:,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2,8:,:2\)"\
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 281, 291\\) \\( 282, 292\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2,8:,:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2,8:,3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(283, 293\\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2,8:,3\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2,:2,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 217, 227\\) \\( 218, 228\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2,:2,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2,:2,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 218, 228\\) \\( 219, 229\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2,:2,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2,:2,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 211, 221\\) \\( 212, 222\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2,:2,:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2,:2,3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(213, 223\\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2,:2,3\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3,4,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(347, 348\\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3,4,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3,4,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(348, 349\\)" \
|
|
|
2f9ed3 |
+i "print ar3\(3,4,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3,4,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(341, 342\\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3,4,:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(5,6,7\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = 567" \
|
|
|
2f9ed3 |
+ "print ar3\(5,6,7\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3:4,6,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 367, 467\\) \\( 368, 468\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3:4,6,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3:4,6,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 368, 468\\) \\( 369, 469\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3:4,6,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3:4,6,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 361, 461\\) \\( 362, 462\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3:4,6,:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3:4,6,5\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(365, 465\\)" \
|
|
|
2f9ed3 |
+ "print ar3\(3:4,6,5\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,6,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 867, 967\\) \\( 868, 968\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,6,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,6,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 868, 968\\) \\( 869, 969\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,6,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,6,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 861, 961\\) \\( 862, 962\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,6,:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,6,5\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(865, 965\\)" \
|
|
|
2f9ed3 |
+ "print ar3\(8:,6,5\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,6,7:8\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 167, 267\\) \\( 168, 268\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,6,7:8\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,6,8:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 168, 268\\) \\( 169, 269\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,6,8:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,6,:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 161, 261\\) \\( 162, 262\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,6,:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,6,5\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(165, 265\\)" \
|
|
|
2f9ed3 |
+ "print ar3\(:2,6,5\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "print ar3\(3:4,5:6,4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 354, 454\\) \\( 364, 464\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(3:4,5:6,4\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(8:,5:6,4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 854, 954\\) \\( 864, 964\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(8:,5:6,4\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(:2,5:6,4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 154, 254\\) \\( 164, 264\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(:2,5:6,4\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Stride > 1
|
|
|
2f9ed3 |
+gdb_test "print ar1\(2:6:2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(2, 4, 6\\)" \
|
|
|
2f9ed3 |
+ "print ar1\(2:6:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(2:6:2,3:4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 23, 43, 63\\) \\( 24, 44, 64\\) \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(2:6:2,3:4\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(2:6:2,3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(23, 43, 63\\)" \
|
|
|
2f9ed3 |
+ "print ar2\(2:6:2,3\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:6:2,3:5:2,4:7:3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 234, 434, 634\\) \\( 254, 454, 654\\)\
|
|
|
2f9ed3 |
+ \\) \\( \\( 237, 437, 637\\) \\( 257, 457, 657\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:6:2,3:5:2,4:7:3\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:6:2,5,4:7:3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 254, 454, 654\\) \\( 257, 457, 657\\)\
|
|
|
2f9ed3 |
+ \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:6:2,5,4:7:3\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Stride < 0
|
|
|
2f9ed3 |
+gdb_test "print ar1\(8:2:-2\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(8, 6, 4, 2\\)" \
|
|
|
2f9ed3 |
+ "print ar1\(8:2:-2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(8:2:-2,3:4\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 83, 63, 43, 23\\) \\( 84, 64, 44, 24\\)\
|
|
|
2f9ed3 |
+ \\)" \
|
|
|
2f9ed3 |
+ "print ar2\(8:2:-2,3:4\)"
|
|
|
2f9ed3 |
+gdb_test "print ar2\(2:6:2,3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(23, 43, 63\\)" \
|
|
|
2f9ed3 |
+ "print ar2\(2:6:2,3\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:3,7:3:-4,4:7:3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 274, 374\\) \\( 234, 334\\) \\) \\(\
|
|
|
2f9ed3 |
+ \\( 277, 377\\) \\( 237, 337\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:3,7:3:-4,4:7:3\)"
|
|
|
2f9ed3 |
+gdb_test "print ar3\(2:6:2,5,7:4:-3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( 257, 457, 657\\) \\( 254, 454, 654\\)\
|
|
|
2f9ed3 |
+ \\)" \
|
|
|
2f9ed3 |
+ "print ar3\(2:6:2,5,7:4:-3\)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Tests with negative and mixed indices
|
|
|
2f9ed3 |
+gdb_test "p ar4\(2:4, -2:1, -15:-14\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 261, 361, 461\\) \\( 271, 371, 471\\)\
|
|
|
2f9ed3 |
+ \\( 281, 381, 481\\) \\( 291, 391, 491\\) \\) \\( \\( 262,\
|
|
|
2f9ed3 |
+ 362, 462\\) \\( 272, 372, 472\\) \\( 282, 382, 482\\) \\( 292,\
|
|
|
2f9ed3 |
+ 392, 492\\) \\) \\)" \
|
|
|
2f9ed3 |
+ "print ar4(2:4, -2:1, -15:-14)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "p ar4\(7,-6:2:3,-7\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(729, 759, 789\\)" \
|
|
|
2f9ed3 |
+ "print ar4(7,-6:2:3,-7)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "p ar4\(9:2:-2, -6:2:3, -6:-15:-3\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 930, 730, 530, 330\\) \\( 960, 760,\
|
|
|
2f9ed3 |
+ 560, 360\\) \\( 990, 790, 590, 390\\) \\) \\( \\( 927, 727,\
|
|
|
2f9ed3 |
+ 527, 327\\) \\( 957, 757, 557, 357\\) \\( 987, 787, 587,\
|
|
|
2f9ed3 |
+ 387\\) \\) \\( \\( 924, 724, 524, 324\\) \\( 954, 754, 554,\
|
|
|
2f9ed3 |
+ 354\\) \\( 984, 784, 584, 384\\) \\) \\( \\( 921, 721, 521,\
|
|
|
2f9ed3 |
+ 321\\) \\( 951, 751, 551, 351\\) \\( 981, 781, 581, 381\\) \\)\
|
|
|
2f9ed3 |
+ \\)" \
|
|
|
2f9ed3 |
+ "print ar4(9:2:-2, -6:2:3, -6:-15:-3)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_test "p ar4\(:,:,:\)" \
|
|
|
2f9ed3 |
+ "\\$\[0-9\]+ = \\(\\( \\( 111, 211, 311, 411, 511, 611, 711,\
|
|
|
2f9ed3 |
+ 811, .*" \
|
|
|
2f9ed3 |
+ "print ar4(:,:,:)"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# Provoke error messages for bad user input
|
|
|
2f9ed3 |
+gdb_test "print ar1\(0:4\)" \
|
|
|
2f9ed3 |
+ "provided bound\\(s\\) outside array bound\\(s\\)" \
|
|
|
2f9ed3 |
+ "print ar1\(0:4\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(8:12\)" \
|
|
|
2f9ed3 |
+ "provided bound\\(s\\) outside array bound\\(s\\)" \
|
|
|
2f9ed3 |
+ "print ar1\(8:12\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(8:2:\)" \
|
|
|
2f9ed3 |
+ "A syntax error in expression, near `\\)'." \
|
|
|
2f9ed3 |
+ "print ar1\(8:2:\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(8:2:2\)" \
|
|
|
2f9ed3 |
+ "Wrong value provided for stride and boundaries" \
|
|
|
2f9ed3 |
+ "print ar1\(8:2:2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(2:8:-2\)" \
|
|
|
2f9ed3 |
+ "Wrong value provided for stride and boundaries" \
|
|
|
2f9ed3 |
+ "print ar1\(2:8:-2\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(2:7:0\)" \
|
|
|
2f9ed3 |
+ "Stride must not be 0" \
|
|
|
2f9ed3 |
+ "print ar1\(2:7:0\)"
|
|
|
2f9ed3 |
+gdb_test "print ar1\(3:7\) = 42" \
|
|
|
2f9ed3 |
+ "Invalid cast." \
|
|
|
2f9ed3 |
+ "Assignment of value to subarray"
|
|
|
2f9ed3 |
diff --git a/gdb/testsuite/gdb.fortran/static-arrays.f90 b/gdb/testsuite/gdb.fortran/static-arrays.f90
|
|
|
2f9ed3 |
new file mode 100644
|
|
|
2f9ed3 |
--- /dev/null
|
|
|
2f9ed3 |
+++ b/gdb/testsuite/gdb.fortran/static-arrays.f90
|
|
|
2f9ed3 |
@@ -0,0 +1,55 @@
|
|
|
2f9ed3 |
+! Copyright 2015 Free Software Foundation, Inc.
|
|
|
2f9ed3 |
+!
|
|
|
2f9ed3 |
+! Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
|
|
|
2f9ed3 |
+!
|
|
|
2f9ed3 |
+! This program is free software; you can redistribute it and/or modify
|
|
|
2f9ed3 |
+! it under the terms of the GNU General Public License as published by
|
|
|
2f9ed3 |
+! the Free Software Foundation; either version 3 of the License, or
|
|
|
2f9ed3 |
+! (at your option) any later version.
|
|
|
2f9ed3 |
+!
|
|
|
2f9ed3 |
+! This program is distributed in the hope that it will be useful,
|
|
|
2f9ed3 |
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2f9ed3 |
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
2f9ed3 |
+! GNU General Public License for more details.
|
|
|
2f9ed3 |
+!
|
|
|
2f9ed3 |
+! You should have received a copy of the GNU General Public License
|
|
|
2f9ed3 |
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+subroutine sub
|
|
|
2f9ed3 |
+ integer, dimension(9) :: ar1
|
|
|
2f9ed3 |
+ integer, dimension(9,9) :: ar2
|
|
|
2f9ed3 |
+ integer, dimension(9,9,9) :: ar3
|
|
|
2f9ed3 |
+ integer, dimension(10,-7:3, -15:-5) :: ar4
|
|
|
2f9ed3 |
+ integer :: i,j,k
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ ar1 = 1
|
|
|
2f9ed3 |
+ ar2 = 1
|
|
|
2f9ed3 |
+ ar3 = 1
|
|
|
2f9ed3 |
+ ar4 = 4
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ ! Resulting array ar3 looks like ((( 111, 112, 113, 114,...)))
|
|
|
2f9ed3 |
+ do i = 1, 9, 1
|
|
|
2f9ed3 |
+ ar1(i) = i
|
|
|
2f9ed3 |
+ do j = 1, 9, 1
|
|
|
2f9ed3 |
+ ar2(i,j) = i*10 + j
|
|
|
2f9ed3 |
+ do k = 1, 9, 1
|
|
|
2f9ed3 |
+ ar3(i,j,k) = i*100 + j*10 + k
|
|
|
2f9ed3 |
+ end do
|
|
|
2f9ed3 |
+ end do
|
|
|
2f9ed3 |
+ end do
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ do i = 1, 10, 1
|
|
|
2f9ed3 |
+ do j = -7, 3, 1
|
|
|
2f9ed3 |
+ do k = -15, -5, 1
|
|
|
2f9ed3 |
+ ar4(i,j,k) = i*100 + (j+8)*10 + (k+16)
|
|
|
2f9ed3 |
+ end do
|
|
|
2f9ed3 |
+ end do
|
|
|
2f9ed3 |
+ end do
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ ar1(1) = 11 !BP1
|
|
|
2f9ed3 |
+ return
|
|
|
2f9ed3 |
+end
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+program testprog
|
|
|
2f9ed3 |
+ call sub
|
|
|
2f9ed3 |
+end
|
|
|
2f9ed3 |
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
|
|
|
2f9ed3 |
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
|
|
|
2f9ed3 |
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
|
|
|
2f9ed3 |
@@ -98,3 +98,7 @@ gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not allocated"
|
|
|
2f9ed3 |
gdb_test "ptype vla2(5, 45, 20)" \
|
|
|
2f9ed3 |
"no such vector element \\\(vector not allocated\\\)" \
|
|
|
2f9ed3 |
"ptype vla2(5, 45, 20) not allocated"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds"]
|
|
|
2f9ed3 |
+gdb_continue_to_breakpoint "vla1-neg-bounds"
|
|
|
2f9ed3 |
+gdb_test "ptype vla1" "type = $real \\(-2:1,-5:4,-3:-1\\)" "ptype vla1 negative bounds"
|
|
|
2f9ed3 |
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
|
|
|
2f9ed3 |
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
|
|
|
2f9ed3 |
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
|
|
|
2f9ed3 |
@@ -44,3 +44,7 @@ gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
|
|
|
2f9ed3 |
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
|
|
|
2f9ed3 |
gdb_continue_to_breakpoint "pvla-associated"
|
|
|
2f9ed3 |
gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds"]
|
|
|
2f9ed3 |
+gdb_continue_to_breakpoint "vla1-neg-bounds"
|
|
|
2f9ed3 |
+gdb_test "print sizeof(vla1)" " = 480" "print sizeof vla1 negative bounds"
|
|
|
2f9ed3 |
diff --git a/gdb/testsuite/gdb.fortran/vla-stride.exp b/gdb/testsuite/gdb.fortran/vla-stride.exp
|
|
|
2f9ed3 |
new file mode 100644
|
|
|
2f9ed3 |
--- /dev/null
|
|
|
2f9ed3 |
+++ b/gdb/testsuite/gdb.fortran/vla-stride.exp
|
|
|
2f9ed3 |
@@ -0,0 +1,44 @@
|
|
|
2f9ed3 |
+# Copyright 2016 Free Software Foundation, Inc.
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
2f9ed3 |
+# it under the terms of the GNU General Public License as published by
|
|
|
2f9ed3 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
2f9ed3 |
+# (at your option) any later version.
|
|
|
2f9ed3 |
+#
|
|
|
2f9ed3 |
+# This program is distributed in the hope that it will be useful,
|
|
|
2f9ed3 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2f9ed3 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
2f9ed3 |
+# GNU General Public License for more details.
|
|
|
2f9ed3 |
+#
|
|
|
2f9ed3 |
+# You should have received a copy of the GNU General Public License
|
|
|
2f9ed3 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+standard_testfile ".f90"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
|
|
|
2f9ed3 |
+ {debug f90 quiet}] } {
|
|
|
2f9ed3 |
+ return -1
|
|
|
2f9ed3 |
+}
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+if ![runto MAIN__] then {
|
|
|
2f9ed3 |
+ perror "couldn't run to breakpoint MAIN__"
|
|
|
2f9ed3 |
+ continue
|
|
|
2f9ed3 |
+}
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_breakpoint [gdb_get_line_number "re-reverse-elements"]
|
|
|
2f9ed3 |
+gdb_continue_to_breakpoint "re-reverse-elements"
|
|
|
2f9ed3 |
+gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \
|
|
|
2f9ed3 |
+ "print re-reverse-elements"
|
|
|
2f9ed3 |
+gdb_test "print pvla(1)" " = 1" "print first re-reverse-element"
|
|
|
2f9ed3 |
+gdb_test "print pvla(10)" " = 10" "print last re-reverse-element"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_breakpoint [gdb_get_line_number "odd-elements"]
|
|
|
2f9ed3 |
+gdb_continue_to_breakpoint "odd-elements"
|
|
|
2f9ed3 |
+gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements"
|
|
|
2f9ed3 |
+gdb_test "print pvla(1)" " = 1" "print first odd-element"
|
|
|
2f9ed3 |
+gdb_test "print pvla(5)" " = 9" "print last odd-element"
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+gdb_breakpoint [gdb_get_line_number "single-element"]
|
|
|
2f9ed3 |
+gdb_continue_to_breakpoint "single-element"
|
|
|
2f9ed3 |
+gdb_test "print pvla" " = \\\(5\\\)" "print single-element"
|
|
|
2f9ed3 |
+gdb_test "print pvla(1)" " = 5" "print one single-element"
|
|
|
2f9ed3 |
diff --git a/gdb/testsuite/gdb.fortran/vla-stride.f90 b/gdb/testsuite/gdb.fortran/vla-stride.f90
|
|
|
2f9ed3 |
new file mode 100644
|
|
|
2f9ed3 |
--- /dev/null
|
|
|
2f9ed3 |
+++ b/gdb/testsuite/gdb.fortran/vla-stride.f90
|
|
|
2f9ed3 |
@@ -0,0 +1,29 @@
|
|
|
2f9ed3 |
+! Copyright 2016 Free Software Foundation, Inc.
|
|
|
2f9ed3 |
+!
|
|
|
2f9ed3 |
+! This program is free software; you can redistribute it and/or modify
|
|
|
2f9ed3 |
+! it under the terms of the GNU General Public License as published by
|
|
|
2f9ed3 |
+! the Free Software Foundation; either version 3 of the License, or
|
|
|
2f9ed3 |
+! (at your option) any later version.
|
|
|
2f9ed3 |
+!
|
|
|
2f9ed3 |
+! This program is distributed in the hope that it will be useful,
|
|
|
2f9ed3 |
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2f9ed3 |
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
2f9ed3 |
+! GNU General Public License for more details.
|
|
|
2f9ed3 |
+!
|
|
|
2f9ed3 |
+! You should have received a copy of the GNU General Public License
|
|
|
2f9ed3 |
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+program vla_stride
|
|
|
2f9ed3 |
+ integer, target, allocatable :: vla (:)
|
|
|
2f9ed3 |
+ integer, pointer :: pvla (:)
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ allocate(vla(10))
|
|
|
2f9ed3 |
+ vla = (/ (I, I = 1,10) /)
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ pvla => vla(10:1:-1)
|
|
|
2f9ed3 |
+ pvla => pvla(10:1:-1)
|
|
|
2f9ed3 |
+ pvla => vla(1:10:2) ! re-reverse-elements
|
|
|
2f9ed3 |
+ pvla => vla(5:4:-2) ! odd-elements
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ pvla => null() ! single-element
|
|
|
2f9ed3 |
+end program vla_stride
|
|
|
2f9ed3 |
diff --git a/gdb/testsuite/gdb.fortran/vla.f90 b/gdb/testsuite/gdb.fortran/vla.f90
|
|
|
2f9ed3 |
--- a/gdb/testsuite/gdb.fortran/vla.f90
|
|
|
2f9ed3 |
+++ b/gdb/testsuite/gdb.fortran/vla.f90
|
|
|
2f9ed3 |
@@ -54,4 +54,14 @@ program vla
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
allocate (vla3 (2,2)) ! vla2-deallocated
|
|
|
2f9ed3 |
vla3(:,:) = 13
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ allocate (vla1 (-2:1, -5:4, -3:-1))
|
|
|
2f9ed3 |
+ l = allocated(vla1)
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ vla1(:, :, :) = 1
|
|
|
2f9ed3 |
+ vla1(-2, -3, -1) = -231
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ deallocate (vla1) ! vla1-neg-bounds
|
|
|
2f9ed3 |
+ l = allocated(vla1)
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
end program vla
|
|
|
2f9ed3 |
diff --git a/gdb/valarith.c b/gdb/valarith.c
|
|
|
2f9ed3 |
--- a/gdb/valarith.c
|
|
|
2f9ed3 |
+++ b/gdb/valarith.c
|
|
|
2f9ed3 |
@@ -187,11 +187,17 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
|
|
|
2f9ed3 |
struct type *array_type = check_typedef (value_type (array));
|
|
|
2f9ed3 |
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
|
|
|
2f9ed3 |
ULONGEST elt_size = type_length_units (elt_type);
|
|
|
2f9ed3 |
- ULONGEST elt_offs = elt_size * (index - lowerbound);
|
|
|
2f9ed3 |
+ LONGEST elt_offs = index - lowerbound;
|
|
|
2f9ed3 |
+ LONGEST elt_stride = TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ if (elt_stride != 0)
|
|
|
2f9ed3 |
+ elt_offs *= elt_stride;
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ elt_offs *= elt_size;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
if (index < lowerbound
|
|
|
2f9ed3 |
|| (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
|
|
|
2f9ed3 |
- && elt_offs >= type_length_units (array_type))
|
|
|
2f9ed3 |
+ && abs (elt_offs) >= type_length_units (array_type))
|
|
|
2f9ed3 |
|| (VALUE_LVAL (array) != lval_memory
|
|
|
2f9ed3 |
&& TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)))
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
diff --git a/gdb/valops.c b/gdb/valops.c
|
|
|
2f9ed3 |
--- a/gdb/valops.c
|
|
|
2f9ed3 |
+++ b/gdb/valops.c
|
|
|
2f9ed3 |
@@ -3792,56 +3792,195 @@ value_of_this_silent (const struct language_defn *lang)
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
struct value *
|
|
|
2f9ed3 |
value_slice (struct value *array, int lowbound, int length)
|
|
|
2f9ed3 |
+{
|
|
|
2f9ed3 |
+ /* Pass unaltered arguments to VALUE_SLICE_1, plus a default stride
|
|
|
2f9ed3 |
+ value of '1', which returns every element between LOWBOUND and
|
|
|
2f9ed3 |
+ (LOWBOUND + LENGTH). We also provide a default CALL_COUNT of '1'
|
|
|
2f9ed3 |
+ as we are only considering the highest dimension, or we are
|
|
|
2f9ed3 |
+ working on a one dimensional array. So we call VALUE_SLICE_1
|
|
|
2f9ed3 |
+ exactly once. */
|
|
|
2f9ed3 |
+ return value_slice_1 (array, lowbound, length, 1, 1);
|
|
|
2f9ed3 |
+}
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+/* VALUE_SLICE_1 is called for each array dimension to calculate the number
|
|
|
2f9ed3 |
+ of elements as defined by the subscript expression.
|
|
|
2f9ed3 |
+ CALL_COUNT is used to determine if we are calling the function once, e.g.
|
|
|
2f9ed3 |
+ we are working on the current dimension of ARRAY, or if we are calling
|
|
|
2f9ed3 |
+ the function repeatedly. In the later case we need to take elements
|
|
|
2f9ed3 |
+ from the TARGET_TYPE of ARRAY.
|
|
|
2f9ed3 |
+ With a CALL_COUNT greater than 1 we calculate the offsets for every element
|
|
|
2f9ed3 |
+ that should be in the result array. Then we fetch the contents and then
|
|
|
2f9ed3 |
+ copy them into the result array. The result array will have one dimension
|
|
|
2f9ed3 |
+ less than the input array, so later on we need to recreate the indices and
|
|
|
2f9ed3 |
+ ranges in the calling function. */
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+struct value *
|
|
|
2f9ed3 |
+value_slice_1 (struct value *array, int lowbound, int length,
|
|
|
2f9ed3 |
+ int stride_length, int call_count)
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
struct type *slice_range_type, *slice_type, *range_type;
|
|
|
2f9ed3 |
- LONGEST lowerbound, upperbound;
|
|
|
2f9ed3 |
- struct value *slice;
|
|
|
2f9ed3 |
- struct type *array_type;
|
|
|
2f9ed3 |
+ struct type *array_type = check_typedef (value_type (array));
|
|
|
2f9ed3 |
+ struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
|
|
|
2f9ed3 |
+ unsigned int elt_size, elt_offs;
|
|
|
2f9ed3 |
+ LONGEST ary_high_bound, ary_low_bound;
|
|
|
2f9ed3 |
+ struct value *v;
|
|
|
2f9ed3 |
+ int slice_range_size, i = 0, row_count = 1, elem_count = 1;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- array_type = check_typedef (value_type (array));
|
|
|
2f9ed3 |
+ /* Check for legacy code if we are actually dealing with an array or
|
|
|
2f9ed3 |
+ string. */
|
|
|
2f9ed3 |
if (TYPE_CODE (array_type) != TYPE_CODE_ARRAY
|
|
|
2f9ed3 |
&& TYPE_CODE (array_type) != TYPE_CODE_STRING)
|
|
|
2f9ed3 |
error (_("cannot take slice of non-array"));
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- range_type = TYPE_INDEX_TYPE (array_type);
|
|
|
2f9ed3 |
- if (get_discrete_bounds (range_type, &lowerbound, &upperbound) < 0)
|
|
|
2f9ed3 |
- error (_("slice from bad array or bitstring"));
|
|
|
2f9ed3 |
+ ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (array_type));
|
|
|
2f9ed3 |
+ ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (array_type));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* When we are working on a multi-dimensional array, we need to get the
|
|
|
2f9ed3 |
+ attributes of the underlying type. */
|
|
|
2f9ed3 |
+ if (call_count > 1)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (elt_type));
|
|
|
2f9ed3 |
+ ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (elt_type));
|
|
|
2f9ed3 |
+ elt_type = check_typedef (TYPE_TARGET_TYPE (elt_type));
|
|
|
2f9ed3 |
+ row_count = TYPE_LENGTH (array_type)
|
|
|
2f9ed3 |
+ / TYPE_LENGTH (TYPE_TARGET_TYPE (array_type));
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* With a stride of '1', the number of elements per result row is equal to
|
|
|
2f9ed3 |
+ the LENGTH of the subarray. With non-default stride values, we skip
|
|
|
2f9ed3 |
+ elements, but have to add the start element to the total number of
|
|
|
2f9ed3 |
+ elements per row. */
|
|
|
2f9ed3 |
+ if (stride_length == 1)
|
|
|
2f9ed3 |
+ elem_count = length;
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ elem_count = ((length - 1) / stride_length) + 1;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ elt_size = TYPE_LENGTH (elt_type);
|
|
|
2f9ed3 |
+ elt_offs = lowbound - ary_low_bound;
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- if (lowbound < lowerbound || length < 0
|
|
|
2f9ed3 |
- || lowbound + length - 1 > upperbound)
|
|
|
2f9ed3 |
- error (_("slice out of range"));
|
|
|
2f9ed3 |
+ elt_offs *= elt_size;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Check for valid user input. In case of Fortran this was already done
|
|
|
2f9ed3 |
+ in the calling function. */
|
|
|
2f9ed3 |
+ if (call_count == 1
|
|
|
2f9ed3 |
+ && (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
|
|
|
2f9ed3 |
+ && elt_offs >= TYPE_LENGTH (array_type)))
|
|
|
2f9ed3 |
+ error (_("no such vector element"));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* CALL_COUNT is 1 when we are dealing either with the highest dimension
|
|
|
2f9ed3 |
+ of the array, or a one dimensional array. Set RANGE_TYPE accordingly.
|
|
|
2f9ed3 |
+ In both cases we calculate how many rows/elements will be in the output
|
|
|
2f9ed3 |
+ array by setting slice_range_size. */
|
|
|
2f9ed3 |
+ if (call_count == 1)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ range_type = TYPE_INDEX_TYPE (array_type);
|
|
|
2f9ed3 |
+ slice_range_size = ary_low_bound + elem_count - 1;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Check if the array bounds are valid. */
|
|
|
2f9ed3 |
+ if (get_discrete_bounds (range_type, &ary_low_bound, &ary_high_bound) < 0)
|
|
|
2f9ed3 |
+ error (_("slice from bad array or bitstring"));
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ /* When CALL_COUNT is greater than 1, we are dealing with an array of arrays.
|
|
|
2f9ed3 |
+ So we need to get the type below the current one and set the RANGE_TYPE
|
|
|
2f9ed3 |
+ accordingly. */
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ range_type = TYPE_INDEX_TYPE (TYPE_TARGET_TYPE (array_type));
|
|
|
2f9ed3 |
+ slice_range_size = ary_low_bound + (row_count * elem_count) - 1;
|
|
|
2f9ed3 |
+ ary_low_bound = TYPE_LOW_BOUND (range_type);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
/* FIXME-type-allocation: need a way to free this type when we are
|
|
|
2f9ed3 |
- done with it. */
|
|
|
2f9ed3 |
- slice_range_type = create_static_range_type ((struct type *) NULL,
|
|
|
2f9ed3 |
- TYPE_TARGET_TYPE (range_type),
|
|
|
2f9ed3 |
- lowbound,
|
|
|
2f9ed3 |
- lowbound + length - 1);
|
|
|
2f9ed3 |
+ done with it. */
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
+ slice_range_type = create_static_range_type (NULL, TYPE_TARGET_TYPE (range_type),
|
|
|
2f9ed3 |
+ ary_low_bound, slice_range_size);
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- struct type *element_type = TYPE_TARGET_TYPE (array_type);
|
|
|
2f9ed3 |
- LONGEST offset
|
|
|
2f9ed3 |
- = (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type));
|
|
|
2f9ed3 |
+ struct type *element_type;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* When both CALL_COUNT and STRIDE_LENGTH equal 1, we can use the legacy
|
|
|
2f9ed3 |
+ code for subarrays. */
|
|
|
2f9ed3 |
+ if (call_count == 1 && stride_length == 1)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ element_type = TYPE_TARGET_TYPE (array_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ slice_type = create_array_type (NULL, element_type, slice_range_type);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- slice_type = create_array_type ((struct type *) NULL,
|
|
|
2f9ed3 |
- element_type,
|
|
|
2f9ed3 |
- slice_range_type);
|
|
|
2f9ed3 |
- TYPE_CODE (slice_type) = TYPE_CODE (array_type);
|
|
|
2f9ed3 |
+ TYPE_CODE (slice_type) = TYPE_CODE (array_type);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
|
|
|
2f9ed3 |
- slice = allocate_value_lazy (slice_type);
|
|
|
2f9ed3 |
+ if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
|
|
|
2f9ed3 |
+ v = allocate_value_lazy (slice_type);
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ v = allocate_value (slice_type);
|
|
|
2f9ed3 |
+ value_contents_copy (v,
|
|
|
2f9ed3 |
+ value_embedded_offset (v),
|
|
|
2f9ed3 |
+ array,
|
|
|
2f9ed3 |
+ value_embedded_offset (array) + elt_offs,
|
|
|
2f9ed3 |
+ elt_size * longest_to_int (length));
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ /* With a CALL_COUNT or STRIDE_LENGTH are greater than 1 we are working
|
|
|
2f9ed3 |
+ on a range of ranges. So we copy the relevant elements into the
|
|
|
2f9ed3 |
+ new array we return. */
|
|
|
2f9ed3 |
else
|
|
|
2f9ed3 |
{
|
|
|
2f9ed3 |
- slice = allocate_value (slice_type);
|
|
|
2f9ed3 |
- value_contents_copy (slice, 0, array, offset,
|
|
|
2f9ed3 |
- type_length_units (slice_type));
|
|
|
2f9ed3 |
+ int j, offs_store = elt_offs;
|
|
|
2f9ed3 |
+ LONGEST dst_offset = 0;
|
|
|
2f9ed3 |
+ LONGEST src_row_length = TYPE_LENGTH (TYPE_TARGET_TYPE (array_type));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ if (call_count == 1)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ /* When CALL_COUNT is equal to 1 we are working on the current range
|
|
|
2f9ed3 |
+ and use these elements directly. */
|
|
|
2f9ed3 |
+ element_type = TYPE_TARGET_TYPE (array_type);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ /* Working on an array of arrays, the type of the elements is the type
|
|
|
2f9ed3 |
+ of the subarrays' type. */
|
|
|
2f9ed3 |
+ element_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (array_type));
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ slice_type = create_array_type (NULL, element_type, slice_range_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* If we have a one dimensional array, we copy its TYPE_CODE. For a
|
|
|
2f9ed3 |
+ multi dimensional array we copy the embedded type's TYPE_CODE. */
|
|
|
2f9ed3 |
+ if (call_count == 1)
|
|
|
2f9ed3 |
+ TYPE_CODE (slice_type) = TYPE_CODE (array_type);
|
|
|
2f9ed3 |
+ else
|
|
|
2f9ed3 |
+ TYPE_CODE (slice_type) = TYPE_CODE (TYPE_TARGET_TYPE (array_type));
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ v = allocate_value (slice_type);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Iterate through the rows of the outer array and set the new offset
|
|
|
2f9ed3 |
+ for each row. */
|
|
|
2f9ed3 |
+ for (i = 0; i < row_count; i++)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ elt_offs = offs_store + i * src_row_length;
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
+ /* Iterate through the elements in each row to copy only those. */
|
|
|
2f9ed3 |
+ for (j = 1; j <= elem_count; j++)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ /* Fetches the contents of ARRAY and copies them into V. */
|
|
|
2f9ed3 |
+ value_contents_copy (v, dst_offset, array, elt_offs, elt_size);
|
|
|
2f9ed3 |
+ elt_offs += elt_size * stride_length;
|
|
|
2f9ed3 |
+ dst_offset += elt_size;
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- set_value_component_location (slice, array);
|
|
|
2f9ed3 |
- set_value_offset (slice, value_offset (array) + offset);
|
|
|
2f9ed3 |
+ set_value_component_location (v, array);
|
|
|
2f9ed3 |
+ if (VALUE_LVAL (v) == lval_register)
|
|
|
2f9ed3 |
+ {
|
|
|
2f9ed3 |
+ VALUE_REGNUM (v) = VALUE_REGNUM (array);
|
|
|
2f9ed3 |
+ VALUE_NEXT_FRAME_ID (v) = VALUE_NEXT_FRAME_ID (array);
|
|
|
2f9ed3 |
+ }
|
|
|
2f9ed3 |
+ set_value_offset (v, value_offset (array) + elt_offs);
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
- return slice;
|
|
|
2f9ed3 |
+ return v;
|
|
|
2f9ed3 |
}
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
/* Create a value for a FORTRAN complex number. Currently most of the
|
|
|
2f9ed3 |
diff --git a/gdb/value.h b/gdb/value.h
|
|
|
2f9ed3 |
--- a/gdb/value.h
|
|
|
2f9ed3 |
+++ b/gdb/value.h
|
|
|
2f9ed3 |
@@ -1139,6 +1139,8 @@ extern struct value *varying_to_slice (struct value *);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
extern struct value *value_slice (struct value *, int, int);
|
|
|
2f9ed3 |
|
|
|
2f9ed3 |
+extern struct value *value_slice_1 (struct value *, int, int, int, int);
|
|
|
2f9ed3 |
+
|
|
|
2f9ed3 |
extern struct value *value_literal_complex (struct value *, struct value *,
|
|
|
2f9ed3 |
struct type *);
|
|
|
2f9ed3 |
|