diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-01-18 22:38:29 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-02-25 16:03:22 +0000 |
commit | 9e80cfa14ed0bdec20361ae78e74ccb937de3428 (patch) | |
tree | aa831e6bb05b27a4bf20cb60824cb65ae3c9635f /gdb/valarith.c | |
parent | 09624f1fece637e17c0c31f6b7589466402ea407 (diff) | |
download | gdb-9e80cfa14ed0bdec20361ae78e74ccb937de3428.zip gdb-9e80cfa14ed0bdec20361ae78e74ccb937de3428.tar.gz gdb-9e80cfa14ed0bdec20361ae78e74ccb937de3428.tar.bz2 |
gdb/fortran: Support negative array stride in one limited case
This commit adds support for negative Fortran array strides in one
limited case, that is the case of a single element array with a
negative array stride.
The changes in this commit will be required in order for more general
negative array stride support to work correctly, however, right now
other problems in GDB prevent negative array strides from working in
the general case.
The reason negative array strides don't currently work in the general
case is that when dealing with such arrays, the base address for the
objects data is actually the highest addressed element, subsequent
elements are then accessed with a negative offset from that address,
and GDB is not currently happy with this configuration.
The changes here can be summarised as, stop treating signed values as
unsigned, specifically, the array stride, and offsets calculated using
the array stride.
This issue was identified on the mailing list by Sergio:
https://sourceware.org/ml/gdb-patches/2020-01/msg00360.html
The test for this issue is a new one written by me as the copyright
status of the original test is currently unknown.
gdb/ChangeLog:
* gdbtypes.c (create_array_type_with_stride): Handle negative
array strides.
* valarith.c (value_subscripted_rvalue): Likewise.
gdb/testsuite/ChangeLog:
* gdb.fortran/derived-type-striding.exp: Add a new test.
* gdb.fortran/derived-type-striding.f90: Add pointer variable for
new test.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r-- | gdb/valarith.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index 79b1486..be0e073 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -187,7 +187,7 @@ value_subscripted_rvalue (struct value *array, LONGEST index, LONGEST lowerbound { struct type *array_type = check_typedef (value_type (array)); struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); - ULONGEST elt_size = type_length_units (elt_type); + LONGEST elt_size = type_length_units (elt_type); /* Fetch the bit stride and convert it to a byte stride, assuming 8 bits in a byte. */ @@ -199,7 +199,7 @@ value_subscripted_rvalue (struct value *array, LONGEST index, LONGEST lowerbound elt_size = stride / (unit_size * 8); } - ULONGEST elt_offs = elt_size * (index - lowerbound); + LONGEST elt_offs = elt_size * (index - lowerbound); if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type) |