|
Jan Kratochvil |
fdbd5e3 |
http://sourceware.org/ml/gdb-patches/2016-02/msg00842.html
|
|
Jan Kratochvil |
fdbd5e3 |
Subject: [PATCH v2 4/6] fortran: enable parsing of stride parameter for subranges
|
|
Jan Kratochvil |
fdbd5e3 |
|
|
Jan Kratochvil |
046f33b |
From: Christoph Weinmann <christoph.t.weinmann@intel.com>
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
Allow the user to provide a stride parameter for Fortran
|
|
Jan Kratochvil |
046f33b |
subarrays. The stride parameter can be any integer except
|
|
Jan Kratochvil |
046f33b |
'0'. The default stride value is '1'.
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
2013-11-27 Christoph Weinmann <christoph.t.weinmann@intel.com>
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
* eval.c (value_f90_subarray): Add expression evaluation
|
|
Jan Kratochvil |
046f33b |
for a stride parameter in a Fortran range expression.
|
|
Jan Kratochvil |
046f33b |
* f-exp.y: Add yacc rules for writing info on the elt stack
|
|
Jan Kratochvil |
046f33b |
when the user provided a stride argument.
|
|
Jan Kratochvil |
046f33b |
* f-lang.h (F90_RANGE): Add field to enum to show when a
|
|
Jan Kratochvil |
046f33b |
stride was provided by the user.
|
|
Jan Kratochvil |
046f33b |
* parse.c (operator_length_standard): Check if a stride
|
|
Jan Kratochvil |
046f33b |
value was provided, and increment argument counter
|
|
Jan Kratochvil |
046f33b |
accordingly.
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
Signed-off-by: Christoph Weinmann <christoph.t.weinmann@intel.com>
|
|
Jan Kratochvil |
046f33b |
---
|
|
Jan Kratochvil |
fdbd5e3 |
gdb/eval.c | 10 +++++++++-
|
|
Jan Kratochvil |
fdbd5e3 |
gdb/f-exp.y | 33 +++++++++++++++++++++++++++++++--
|
|
Jan Kratochvil |
fdbd5e3 |
gdb/f-lang.h | 5 +++--
|
|
Jan Kratochvil |
fdbd5e3 |
gdb/parse.c | 3 +++
|
|
Jan Kratochvil |
046f33b |
4 files changed, 46 insertions(+), 5 deletions(-)
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
diff --git a/gdb/eval.c b/gdb/eval.c
|
|
Jan Kratochvil |
fdbd5e3 |
index 9b8b051..308ada3 100644
|
|
Jan Kratochvil |
046f33b |
--- a/gdb/eval.c
|
|
Jan Kratochvil |
046f33b |
+++ b/gdb/eval.c
|
|
Jan Kratochvil |
046f33b |
@@ -438,7 +438,7 @@ value_f90_subarray (struct value *array, struct expression *exp,
|
|
Jan Kratochvil |
046f33b |
struct subscript_range
|
|
Jan Kratochvil |
046f33b |
{
|
|
Jan Kratochvil |
046f33b |
enum f90_range_type f90_range_type;
|
|
Jan Kratochvil |
046f33b |
- LONGEST low, high;
|
|
Jan Kratochvil |
046f33b |
+ LONGEST low, high, stride;
|
|
Jan Kratochvil |
046f33b |
}
|
|
Jan Kratochvil |
046f33b |
range;
|
|
Jan Kratochvil |
046f33b |
LONGEST number;
|
|
Jan Kratochvil |
046f33b |
@@ -488,6 +488,14 @@ value_f90_subarray (struct value *array, struct expression *exp,
|
|
Jan Kratochvil |
046f33b |
== SUBARRAY_HIGH_BOUND)
|
|
Jan Kratochvil |
046f33b |
range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp,
|
|
Jan Kratochvil |
046f33b |
pos, noside));
|
|
Jan Kratochvil |
046f33b |
+
|
|
Jan Kratochvil |
046f33b |
+ /* Assign the user's stride value if provided. */
|
|
Jan Kratochvil |
046f33b |
+ if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
|
|
Jan Kratochvil |
046f33b |
+ range->stride = value_as_long (evaluate_subexp (NULL_TYPE, exp,
|
|
Jan Kratochvil |
046f33b |
+ pos, noside));
|
|
Jan Kratochvil |
046f33b |
+ /* Assign the default stride value '1'. */
|
|
Jan Kratochvil |
046f33b |
+ else
|
|
Jan Kratochvil |
046f33b |
+ range->stride = 1;
|
|
Jan Kratochvil |
046f33b |
}
|
|
Jan Kratochvil |
046f33b |
/* User input is an index. E.g.: "p arry(5)". */
|
|
Jan Kratochvil |
046f33b |
else
|
|
Jan Kratochvil |
046f33b |
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
|
|
Jan Kratochvil |
fdbd5e3 |
index b1206de..5151fee 100644
|
|
Jan Kratochvil |
046f33b |
--- a/gdb/f-exp.y
|
|
Jan Kratochvil |
046f33b |
+++ b/gdb/f-exp.y
|
|
Jan Kratochvil |
046f33b |
@@ -316,8 +316,8 @@ arglist : arglist ',' exp %prec ABOVE_COMMA
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
subrange: exp ':' exp %prec ABOVE_COMMA
|
|
Jan Kratochvil |
046f33b |
{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
|
Jan Kratochvil |
046f33b |
- write_exp_elt_longcst (pstate,
|
|
Jan Kratochvil |
046f33b |
- SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
|
|
Jan Kratochvil |
046f33b |
+ | SUBARRAY_HIGH_BOUND);
|
|
Jan Kratochvil |
046f33b |
write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
|
Jan Kratochvil |
046f33b |
;
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
@@ -339,6 +339,35 @@ subrange: ':' %prec ABOVE_COMMA
|
|
Jan Kratochvil |
046f33b |
write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
|
Jan Kratochvil |
046f33b |
;
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
+/* Each subrange type can have a stride argument. */
|
|
Jan Kratochvil |
046f33b |
+subrange: exp ':' exp ':' exp %prec ABOVE_COMMA
|
|
Jan Kratochvil |
046f33b |
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
|
|
Jan Kratochvil |
046f33b |
+ | SUBARRAY_HIGH_BOUND
|
|
Jan Kratochvil |
046f33b |
+ | SUBARRAY_STRIDE);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
|
Jan Kratochvil |
046f33b |
+ ;
|
|
Jan Kratochvil |
046f33b |
+
|
|
Jan Kratochvil |
046f33b |
+subrange: exp ':' ':' exp %prec ABOVE_COMMA
|
|
Jan Kratochvil |
046f33b |
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
|
|
Jan Kratochvil |
046f33b |
+ | SUBARRAY_STRIDE);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
|
Jan Kratochvil |
046f33b |
+ ;
|
|
Jan Kratochvil |
046f33b |
+
|
|
Jan Kratochvil |
046f33b |
+subrange: ':' exp ':' exp %prec ABOVE_COMMA
|
|
Jan Kratochvil |
046f33b |
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND
|
|
Jan Kratochvil |
046f33b |
+ | SUBARRAY_STRIDE);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
|
Jan Kratochvil |
046f33b |
+ ;
|
|
Jan Kratochvil |
046f33b |
+
|
|
Jan Kratochvil |
046f33b |
+subrange: ':' ':' exp %prec ABOVE_COMMA
|
|
Jan Kratochvil |
046f33b |
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_longcst (pstate, SUBARRAY_STRIDE);
|
|
Jan Kratochvil |
046f33b |
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
|
Jan Kratochvil |
046f33b |
+ ;
|
|
Jan Kratochvil |
046f33b |
+
|
|
Jan Kratochvil |
046f33b |
complexnum: exp ',' exp
|
|
Jan Kratochvil |
046f33b |
{ }
|
|
Jan Kratochvil |
046f33b |
;
|
|
Jan Kratochvil |
046f33b |
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
|
|
Jan Kratochvil |
fdbd5e3 |
index 4d56bf7..0ad57af 100644
|
|
Jan Kratochvil |
046f33b |
--- a/gdb/f-lang.h
|
|
Jan Kratochvil |
046f33b |
+++ b/gdb/f-lang.h
|
|
Jan Kratochvil |
046f33b |
@@ -44,8 +44,9 @@ extern void f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
enum f90_range_type
|
|
Jan Kratochvil |
046f33b |
{
|
|
Jan Kratochvil |
046f33b |
- SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" */
|
|
Jan Kratochvil |
046f33b |
- SUBARRAY_HIGH_BOUND = 0x2 /* "(:high)" */
|
|
Jan Kratochvil |
046f33b |
+ SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" or "(low::)" */
|
|
Jan Kratochvil |
046f33b |
+ SUBARRAY_HIGH_BOUND = 0x2, /* "(:high)" or "(:high:)" */
|
|
Jan Kratochvil |
046f33b |
+ SUBARRAY_STRIDE = 0x4 /* "(::stride)" */
|
|
Jan Kratochvil |
046f33b |
};
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
/* A common block. */
|
|
Jan Kratochvil |
046f33b |
diff --git a/gdb/parse.c b/gdb/parse.c
|
|
Jan Kratochvil |
fdbd5e3 |
index d500279..07248c3 100644
|
|
Jan Kratochvil |
046f33b |
--- a/gdb/parse.c
|
|
Jan Kratochvil |
046f33b |
+++ b/gdb/parse.c
|
|
Jan Kratochvil |
046f33b |
@@ -1018,6 +1018,9 @@ operator_length_standard (const struct expression *expr, int endpos,
|
|
Jan Kratochvil |
046f33b |
if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
|
|
Jan Kratochvil |
046f33b |
args++;
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
+ if ((range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
|
|
Jan Kratochvil |
046f33b |
+ args++;
|
|
Jan Kratochvil |
046f33b |
+
|
|
Jan Kratochvil |
046f33b |
break;
|
|
Jan Kratochvil |
046f33b |
|
|
Jan Kratochvil |
046f33b |
default:
|
|
Jan Kratochvil |
046f33b |
--
|
|
Jan Kratochvil |
fdbd5e3 |
2.5.0
|
|
Jan Kratochvil |
fdbd5e3 |
|