diff options
author | Maciej W. Rozycki <macro@embecosm.com> | 2022-01-19 21:55:10 +0000 |
---|---|---|
committer | Maciej W. Rozycki <macro@embecosm.com> | 2022-01-19 21:55:10 +0000 |
commit | 476f77a94cd51aede979e1b54c46cebe2ec9dde9 (patch) | |
tree | 23255051608cdb4f8385d31a2137b34ecbb35db0 /gdb/f-lang.c | |
parent | 2ddd4c6082edcc92d57115152f8311f67b7bdd95 (diff) | |
download | gdb-476f77a94cd51aede979e1b54c46cebe2ec9dde9.zip gdb-476f77a94cd51aede979e1b54c46cebe2ec9dde9.tar.gz gdb-476f77a94cd51aede979e1b54c46cebe2ec9dde9.tar.bz2 |
Respect `set print repeats' with Fortran arrays
Implement `set print repeats' handling for Fortran arrays. Currently
the setting is ignored and always treated as if no limit was set.
Unlike the generic array walker implemented decades ago the Fortran one
is a proper C++ class. Rather than trying to mimic the old walker then,
which turned out a bit of a challenge where interacting with the `set
print elements' setting, write it entirely from scratch, by adding an
extra specialization handler method for processing dimensions other than
the innermost one and letting the specialization class call the `walk_1'
method from the handler as it sees fit. This way repeats can be tracked
and the next inner dimension recursed into as a need arises only, or
unconditionally in the base class.
Keep track of the dimension number being handled in the class rather as
a parameter to the walker so that it does not have to be passed across
by the specialization class.
Use per-dimension element count tracking, needed to terminate processing
early when the limit set by `set print elements' is hit. This requires
extra care too where the limit triggers exactly where another element
that is a subarray begins. In that case rather than recursing we need
to terminate processing or lone `(...)' would be printed. Additionally
if the skipped element is the last one in the current dimension we need
to print `...' by hand, because `continue_walking' won't print it at the
upper level, because it can see the last element has already been taken
care of.
Preserve the existing semantics of `set print elements' where the total
count of the elements handled is matched against the trigger level which
is unlike with the C/C++ array printer where the per-dimension element
count is used instead.
Output now looks like:
(gdb) set print repeats 4
(gdb) print array_2d
$1 = ((2, <repeats 5 times>) <repeats 5 times>)
(gdb) set print elements 12
(gdb) print array_2d
$2 = ((2, <repeats 5 times>) (2, <repeats 5 times>) (2, 2, ...) ...)
(gdb)
for a 5 by 5 array filled with the value of 2.
Amend existing test cases accordingly that rely on the current incorrect
behavior and explicitly request that there be no limit for printing
repeated elements there.
Add suitable test cases as well covering sliced arrays in particular.
Co-Authored-By: Andrew Burgess <andrew.burgess@embecosm.com>
Diffstat (limited to 'gdb/f-lang.c')
-rw-r--r-- | gdb/f-lang.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 3ef7597..d181f38 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -263,7 +263,7 @@ public: will be creating values for each element as we load them and then copy them into the M_DEST value. Set a value mark so we can free these temporary values. */ - void start_dimension (bool inner_p) + void start_dimension (LONGEST nelts, bool inner_p) { if (inner_p) { |