[review] gdb/fortran: array stride support
Tom Tromey (Code Review)
gerrit@gnutoolchain-gerrit.osci.io
Fri Nov 15 22:36:00 GMT 2019
Tom Tromey has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/627
......................................................................
Patch Set 1:
(3 comments)
Thanks for doing this. It looks essentially good to me, though I had
a few notes.
| --- /dev/null
| +++ /COMMIT_MSG
| @@ -1,0 +20,21 @@ information. The name is possibly a little inaccurate now, but this
| +still sort of makes sense, the structure represents information about
| +the bounds of the range, and also how to move from the lower to the
| +upper bound (the stride).
| +
| +I've added initial support for bit strides, but I've never actually
| +seen an example of this being generated. Further, I don't really see
| +right now how GDB would currently handle a bit stride that was not a
| +multiple of the byte size as the code in, for example,
| +valarith.c:value_subscripted_rvalue seems geared around byte
| +addressing. As a consequence if we see a bit stride that is not a
| +multiple of 8 then GDB will give a warning and then carry on, even
| +though the results are likely to be wrong.
PS1, Line 31:
I wonder if it would be better to "error" when evaluating
such an expression, to avoid giving incorrect answers.
| +
| +gdb/ChangeLog:
| +
| + * dwarf2read.c (read_subrange_type): Read bit and byte stride and
| + create a range with stride where appropriate.
| + * f-valprint.c (f77_print_array_1): Take the stride into account
| + when walking the array.
| + * gdbtypes.c (create_range_type): Initialise the stride to
| + constant zero.
| --- gdb/gdbtypes.c
| +++ gdb/gdbtypes.c
| @@ -978,17 +1007,18 @@ create_static_range_type (struct type *result_type, struct type *index_type,
| /* Predicate tests whether BOUNDS are static. Returns 1 if all bounds values
| are static, otherwise returns 0. */
|
| static int
| has_static_range (const struct range_bounds *bounds)
| {
| return (bounds->low.kind == PROP_CONST
| - && bounds->high.kind == PROP_CONST);
| + && bounds->high.kind == PROP_CONST
| + && bounds->stride.kind == PROP_CONST);
PS1, Line 1015:
It seems like this will not be true for types that don't
have a stride -- changing the semantics of this function.
Won't this negatively affect other cases?
| }
|
|
| /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
| TYPE. Return 1 if type is a range type, 0 if it is discrete (and
| bounds will fit in LONGEST), or -1 otherwise. */
|
| int
| get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
| --- gdb/gdbtypes.h
| +++ gdb/gdbtypes.h
| @@ -620,8 +620,19 @@ struct range_bounds
| + /* The stride value for this range. This can be stored in bits or bytes
| + based on the value of BYTE_STRIDE_P. It is optional to have a stride
| + value, if this range has no stride value defined then this will be set
| + to the constant zero. */
| +
| + struct dynamic_prop stride;
| +
| + /* If this is true this STRIDE is in bytes, otherwise STRIDE is in bits. */
| +
| + bool byte_stride_p;
PS1, Line 629:
Perhaps this should be at the end of the struct, so it packs better.
| +
| /* * The bias. Sometimes a range value is biased before storage.
| The bias is added to the stored bits to form the true value. */
|
| LONGEST bias;
|
| /* True if HIGH range bound contains the number of elements in the
| subrange. This affects how the final high bound is computed. */
|
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I9af2bcd1f2d4c56f76f5f3f9f89d8f06bef10d9a
Gerrit-Change-Number: 627
Gerrit-PatchSet: 1
Gerrit-Owner: Andrew Burgess <andrew.burgess@embecosm.com>
Gerrit-CC: Tom Tromey <tromey@sourceware.org>
Gerrit-Comment-Date: Fri, 15 Nov 2019 22:36:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
More information about the Gdb-patches
mailing list