From: Keven Boell <keven.boell@intel.com>
To: gdb-patches@sourceware.org
Cc: sanimir.agovic@intel.com, Keven Boell <keven.boell@intel.com>
Subject: [V3 05/21] vla: use value constructor instead of raw-buffer manipulation
Date: Wed, 10 Sep 2014 09:22:00 -0000 [thread overview]
Message-ID: <1410340929-20653-6-git-send-email-keven.boell@intel.com> (raw)
In-Reply-To: <1410340929-20653-1-git-send-email-keven.boell@intel.com>
Instead of pre-computing indices into a fortran array re-use
the value_* interfaces to subscript a fortran array.
2014-05-28 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
* f-valprint.c (f77_create_arrayprint_offset_tbl): Remove
function.
(F77_DIM_SIZE, F77_DIM_OFFSET): Remove macro.
(f77_print_array_1): Use value_subscript to subscript a
value array.
(f77_print_array): Remove call to f77_create_arrayprint_offset_tbl.
(f_val_print): Use value_field to construct a field value.
---
gdb/f-valprint.c | 118 ++++++++++++++++++------------------------------------
1 file changed, 39 insertions(+), 79 deletions(-)
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index c7581a8..4c45b83 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -37,8 +37,6 @@
extern void _initialize_f_valprint (void);
static void info_common_command (char *, int);
-static void f77_create_arrayprint_offset_tbl (struct type *,
- struct ui_file *);
static void f77_get_dynamic_length_of_aggregate (struct type *);
int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
@@ -46,15 +44,6 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
/* Array which holds offsets to be applied to get a row's elements
for a given array. Array also holds the size of each subarray. */
-/* The following macro gives us the size of the nth dimension, Where
- n is 1 based. */
-
-#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
-
-/* The following gives us the offset for row n where n is 1-based. */
-
-#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
-
int
f77_get_lowerbound (struct type *type)
{
@@ -112,47 +101,6 @@ f77_get_dynamic_length_of_aggregate (struct type *type)
* TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
}
-/* Function that sets up the array offset,size table for the array
- type "type". */
-
-static void
-f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
-{
- struct type *tmp_type;
- int eltlen;
- int ndimen = 1;
- int upper, lower;
-
- tmp_type = type;
-
- while (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
- {
- upper = f77_get_upperbound (tmp_type);
- lower = f77_get_lowerbound (tmp_type);
-
- F77_DIM_SIZE (ndimen) = upper - lower + 1;
-
- tmp_type = TYPE_TARGET_TYPE (tmp_type);
- ndimen++;
- }
-
- /* Now we multiply eltlen by all the offsets, so that later we
- can print out array elements correctly. Up till now we
- know an offset to apply to get the item but we also
- have to know how much to add to get to the next item. */
-
- ndimen--;
- eltlen = TYPE_LENGTH (tmp_type);
- F77_DIM_OFFSET (ndimen) = eltlen;
- while (--ndimen > 0)
- {
- eltlen *= F77_DIM_SIZE (ndimen + 1);
- F77_DIM_OFFSET (ndimen) = eltlen;
- }
-}
-
-
-
/* Actual function which prints out F77 arrays, Valaddr == address in
the superior. Address == the address in the inferior. */
@@ -165,41 +113,56 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
const struct value_print_options *options,
int *elts)
{
+ struct type *range_type = TYPE_INDEX_TYPE (check_typedef (type));
+ CORE_ADDR addr = address + embedded_offset;
+ LONGEST lowerbound, upperbound;
int i;
+ get_discrete_bounds (range_type, &lowerbound, &upperbound);
+
if (nss != ndimensions)
{
- for (i = 0;
- (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max);
+ size_t dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
+ size_t offs = 0;
+
+ for (i = lowerbound;
+ (i < upperbound + 1 && (*elts) < options->print_max);
i++)
{
+ struct value *subarray = value_from_contents_and_address
+ (TYPE_TARGET_TYPE (type), value_contents_for_printing_const (val)
+ + offs, addr + offs);
+
fprintf_filtered (stream, "( ");
- f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
- valaddr,
- embedded_offset + i * F77_DIM_OFFSET (nss),
- address,
- stream, recurse, val, options, elts);
+ f77_print_array_1 (nss + 1, ndimensions, value_type (subarray),
+ value_contents_for_printing (subarray),
+ value_embedded_offset (subarray),
+ value_address (subarray),
+ stream, recurse, subarray, options, elts);
+ offs += dim_size;
fprintf_filtered (stream, ") ");
}
- if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
+ if (*elts >= options->print_max && i < upperbound)
fprintf_filtered (stream, "...");
}
else
{
- for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
+ for (i = lowerbound; i < upperbound + 1 && (*elts) < options->print_max;
i++, (*elts)++)
{
- val_print (TYPE_TARGET_TYPE (type),
- valaddr,
- embedded_offset + i * F77_DIM_OFFSET (ndimensions),
- address, stream, recurse,
- val, options, current_language);
+ struct value *elt = value_subscript ((struct value *)val, i);
+
+ val_print (value_type (elt),
+ value_contents_for_printing (elt),
+ value_embedded_offset (elt),
+ value_address (elt), stream, recurse,
+ elt, options, current_language);
- if (i != (F77_DIM_SIZE (nss) - 1))
+ if (i != upperbound)
fprintf_filtered (stream, ", ");
if ((*elts == options->print_max - 1)
- && (i != (F77_DIM_SIZE (nss) - 1)))
+ && (i != upperbound))
fprintf_filtered (stream, "...");
}
}
@@ -226,12 +189,6 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
Type node corrupt! F77 arrays cannot have %d subscripts (%d Max)"),
ndimensions, MAX_FORTRAN_DIMS);
- /* Since F77 arrays are stored column-major, we set up an
- offset table to get at the various row's elements. The
- offset table contains entries for both offset and subarray size. */
-
- f77_create_arrayprint_offset_tbl (type, stream);
-
f77_print_array_1 (1, ndimensions, type, valaddr, embedded_offset,
address, stream, recurse, val, options, &elts);
}
@@ -376,12 +333,15 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
fprintf_filtered (stream, "( ");
for (index = 0; index < TYPE_NFIELDS (type); index++)
{
- int offset = TYPE_FIELD_BITPOS (type, index) / 8;
+ struct value *field = value_field
+ ((struct value *)original_value, index);
+
+ val_print (value_type (field),
+ value_contents_for_printing (field),
+ value_embedded_offset (field),
+ value_address (field), stream, recurse + 1,
+ field, options, current_language);
- val_print (TYPE_FIELD_TYPE (type, index), valaddr,
- embedded_offset + offset,
- address, stream, recurse + 1,
- original_value, options, current_language);
if (index != TYPE_NFIELDS (type) - 1)
fputs_filtered (", ", stream);
}
--
1.7.9.5
next prev parent reply other threads:[~2014-09-10 9:22 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 9:22 [V3 00/21] Fortran dynamic array support Keven Boell
2014-09-10 9:22 ` [V3 01/21] vla: introduce allocated/associated flags Keven Boell
2014-09-10 9:22 ` [V3 13/21] test: dynamic arrays passed to subroutines Keven Boell
2014-09-10 9:22 ` [V3 03/21] vla: make field selection work with vla Keven Boell
2014-09-10 9:22 ` [V3 15/21] test: evaluating allocation/association status Keven Boell
2014-09-10 9:22 ` [V3 21/21] test: stride support for dynamic arrays Keven Boell
2014-09-10 9:22 ` [V3 02/21] vla: make dynamic fortran arrays functional Keven Boell
2014-09-10 9:22 ` Keven Boell [this message]
2014-09-10 9:22 ` [V3 18/21] test: dynamic string evaluations Keven Boell
2014-09-10 9:22 ` [V3 09/21] vla: add stride support to fortran arrays Keven Boell
2014-09-10 9:22 ` [V3 14/21] test: correct ptype of dynamic arrays in Fortran Keven Boell
2014-09-10 9:22 ` [V3 19/21] test: basic MI test for the dynamic array support Keven Boell
2014-09-10 9:22 ` [V3 07/21] vla: changed string length semantic Keven Boell
2014-09-10 9:22 ` [V3 08/21] vla: get Fortran dynamic strings working Keven Boell
2014-09-10 9:22 ` [V3 16/21] test: dynamic arrays passed to functions Keven Boell
2014-09-10 9:22 ` [V3 11/21] test: basic tests for dynamic array evaluations in Fortran Keven Boell
2014-09-10 9:22 ` [V3 04/21] vla: reconstruct value to compute bounds of target type Keven Boell
2014-09-10 9:22 ` [V3 10/21] vla: add NEWS entry for dynamic array support Keven Boell
2014-09-10 17:03 ` Eli Zaretskii
2014-09-10 9:22 ` [V3 12/21] test: evaluate dynamic arrays using Fortran primitives Keven Boell
2014-09-10 9:22 ` [V3 06/21] vla: get dynamic array corner cases to work Keven Boell
2014-09-10 9:22 ` [V3 17/21] test: accessing dynamic array history values Keven Boell
2014-09-10 9:22 ` [V3 20/21] test: test sizeof for dynamic fortran arrays Keven Boell
2014-10-02 8:35 ` PING: [V3 00/21] Fortran dynamic array support Tobias Burnus
2014-10-02 15:00 ` Joel Brobecker
2014-11-17 8:59 ` Tobias Burnus
2014-11-17 10:05 ` Joel Brobecker
2014-12-09 8:00 ` Tobias Burnus
2014-12-09 9:18 ` Joel Brobecker
2014-12-09 10:03 ` Keven Boell
2015-02-04 13:22 ` Tobias Burnus
2015-02-04 14:18 ` Joel Brobecker
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=1410340929-20653-6-git-send-email-keven.boell@intel.com \
--to=keven.boell@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=sanimir.agovic@intel.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).