From: christoph.t.weinmann@intel.com
To: jan.kratochvil@redhat.com, gdb-patches@sourceware.org
Cc: christoph.t.weinmann@intel.com
Subject: [PATCH v2 4/6] fortran: enable parsing of stride parameter for subranges
Date: Fri, 26 Feb 2016 13:11:00 -0000 [thread overview]
Message-ID: <1456492259-13807-5-git-send-email-christoph.t.weinmann@intel.com> (raw)
In-Reply-To: <1456492259-13807-1-git-send-email-christoph.t.weinmann@intel.com>
From: Christoph Weinmann <christoph.t.weinmann@intel.com>
Allow the user to provide a stride parameter for Fortran
subarrays. The stride parameter can be any integer except
'0'. The default stride value is '1'.
2013-11-27 Christoph Weinmann <christoph.t.weinmann@intel.com>
* eval.c (value_f90_subarray): Add expression evaluation
for a stride parameter in a Fortran range expression.
* f-exp.y: Add yacc rules for writing info on the elt stack
when the user provided a stride argument.
* f-lang.h (F90_RANGE): Add field to enum to show when a
stride was provided by the user.
* parse.c (operator_length_standard): Check if a stride
value was provided, and increment argument counter
accordingly.
Signed-off-by: Christoph Weinmann <christoph.t.weinmann@intel.com>
---
gdb/eval.c | 10 +++++++++-
gdb/f-exp.y | 33 +++++++++++++++++++++++++++++++--
gdb/f-lang.h | 5 +++--
gdb/parse.c | 3 +++
4 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/gdb/eval.c b/gdb/eval.c
index 9b8b051..308ada3 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -438,7 +438,7 @@ value_f90_subarray (struct value *array, struct expression *exp,
struct subscript_range
{
enum f90_range_type f90_range_type;
- LONGEST low, high;
+ LONGEST low, high, stride;
}
range;
LONGEST number;
@@ -488,6 +488,14 @@ value_f90_subarray (struct value *array, struct expression *exp,
== SUBARRAY_HIGH_BOUND)
range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp,
pos, noside));
+
+ /* Assign the user's stride value if provided. */
+ if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
+ range->stride = value_as_long (evaluate_subexp (NULL_TYPE, exp,
+ pos, noside));
+ /* Assign the default stride value '1'. */
+ else
+ range->stride = 1;
}
/* User input is an index. E.g.: "p arry(5)". */
else
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index b1206de..5151fee 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -316,8 +316,8 @@ arglist : arglist ',' exp %prec ABOVE_COMMA
subrange: exp ':' exp %prec ABOVE_COMMA
{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
- write_exp_elt_longcst (pstate,
- SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND);
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
+ | SUBARRAY_HIGH_BOUND);
write_exp_elt_opcode (pstate, OP_F90_RANGE); }
;
@@ -339,6 +339,35 @@ subrange: ':' %prec ABOVE_COMMA
write_exp_elt_opcode (pstate, OP_F90_RANGE); }
;
+/* Each subrange type can have a stride argument. */
+subrange: exp ':' exp ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
+ | SUBARRAY_HIGH_BOUND
+ | SUBARRAY_STRIDE);
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
+ ;
+
+subrange: exp ':' ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
+ | SUBARRAY_STRIDE);
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
+ ;
+
+subrange: ':' exp ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND
+ | SUBARRAY_STRIDE);
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
+ ;
+
+subrange: ':' ':' exp %prec ABOVE_COMMA
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
+ write_exp_elt_longcst (pstate, SUBARRAY_STRIDE);
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
+ ;
+
complexnum: exp ',' exp
{ }
;
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 4d56bf7..0ad57af 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -44,8 +44,9 @@ extern void f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
enum f90_range_type
{
- SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" */
- SUBARRAY_HIGH_BOUND = 0x2 /* "(:high)" */
+ SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" or "(low::)" */
+ SUBARRAY_HIGH_BOUND = 0x2, /* "(:high)" or "(:high:)" */
+ SUBARRAY_STRIDE = 0x4 /* "(::stride)" */
};
/* A common block. */
diff --git a/gdb/parse.c b/gdb/parse.c
index d500279..07248c3 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -1018,6 +1018,9 @@ operator_length_standard (const struct expression *expr, int endpos,
if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
args++;
+ if ((range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
+ args++;
+
break;
default:
--
2.5.0
next prev parent reply other threads:[~2016-02-26 13:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 13:11 [PATCH v2 0/6] fortran: multi-dimensional subarrays with strides christoph.t.weinmann
2016-02-26 13:11 ` christoph.t.weinmann [this message]
2016-02-26 13:11 ` [PATCH v2 6/6] fortran: test cases for subarray strides and slices christoph.t.weinmann
2016-02-26 13:11 ` [PATCH v2 5/6] fortran: calculate subarray with stride values christoph.t.weinmann
2016-02-26 13:11 ` [PATCH v2 1/6] fortran: allow multi-dimensional subarrays christoph.t.weinmann
2016-02-26 13:11 ` [PATCH v2 3/6] fortran: change subrange enum to bit field christoph.t.weinmann
2016-02-26 13:11 ` [PATCH v2 2/6] fortran: combine subarray and string computation christoph.t.weinmann
2016-02-26 21:00 ` [PATCH v2 0/6] fortran: multi-dimensional subarrays with strides Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456492259-13807-5-git-send-email-christoph.t.weinmann@intel.com \
--to=christoph.t.weinmann@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).