From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 0/8] Fortran Array Slicing and Striding Support
Date: Thu, 13 Aug 2020 13:58:37 +0100 [thread overview]
Message-ID: <cover.1597319264.git.andrew.burgess@embecosm.com> (raw)
This series adds support to GDB's CLI for taking slices (including
with strides) from a Fortrn array, so after this series, things like
this will work:
(gdb) p array (8:3:-2,2:9:3)
$2 = ((18, 16, 14) (48, 46, 44) (78, 76, 74))
There have been a couple of attempts to provide Fortran array
slice/stride support in the past that I'm aware of:
https://sourceware.org/pipermail/gdb-patches/2017-September/143121.html
https://sourceware.org/pipermail/gdb-patches/2016-February/131539.html
I know that some variation of these patches are currently used in
Fedora's GDB[1] and the GDB installed on my Fedora machine can pass
most of the tests I've added here.
However, having looked at the past implementations that were posted to
the list, the approach I'm taking here is a little different.
The previous approaches took the approach of walking each dimension of
the array, at each dimension extracting a slighlt smaller slice.
Though this approach is fine, it does have one problem related to
memory usage and large arrays. If the original array is large, and
extracting the slice for the first dimension would exceed the
max-value-size, then GDB would be unable to load the slice, even if
the final value would have been under the max-value-size.
The patches presented here have the following features:
- The type of the array slice, including upper and lower bounds,
correctly match the behaviour within Fortran.
- Extracting small slices from very large arrays will not exceed the
max-value-size.
- The extracted slice is (by default) an in-memory lvalue, which
aliases onto the original array and can be assigned to, and have
addresses of elements taken and the results will be correct.
- A Fortran compiler will sometimes repack arrays to make the slice
data contiguous, GDB can do this too when it is essential, and can
optionally do this in all cases if the user requires.
- Repacking is again done with an eye to memory usage, so repacking a
small slice from a large array will not exceed the max-value-size.
I don't propose that these patches, or at least the later patches in
this series, be merged before the GDB 10 branching, but I would be
interested in any feedback.
Thanks,
Andrew
[1] https://sourceware.org/pipermail/gdb-patches/2016-April/132383.html
---
Andrew Burgess (8):
gdbsupport: Provide global operators |=, &=, and ^= for enum bit flags
gdbsupport: Make function arguments constant in enum-flags.h
gdb/fortran: Clean up array/string expression evaluation
gdb/fortran: Move Fortran expression handling into f-lang.c
gdb/fortran: Change whitespace when printing arrays
gdb: Convert enum range_type to a bit field enum
gdb/testsuite: Add missing expected results
gdb/fortran: Add support for Fortran array slices at the GDB prompt
gdb/ChangeLog | 102 +++
gdb/Makefile.in | 1 +
gdb/NEWS | 13 +
gdb/doc/ChangeLog | 7 +
gdb/doc/gdb.texinfo | 30 +
gdb/eval.c | 225 +----
gdb/expprint.c | 114 ++-
gdb/expression.h | 39 +-
gdb/f-array-walker.h | 255 ++++++
gdb/f-exp.y | 52 +-
gdb/f-lang.c | 779 ++++++++++++++++++
gdb/f-lang.h | 19 +-
gdb/f-valprint.c | 187 +++--
gdb/fortran-operator.def | 8 +
gdb/gdbtypes.c | 12 +-
gdb/parse.c | 25 +-
gdb/parser-defs.h | 16 +
gdb/rust-exp.y | 21 +-
gdb/rust-lang.c | 25 +-
gdb/std-operator.def | 8 -
gdb/testsuite/ChangeLog | 22 +
.../gdb.fortran/array-slices-bad.exp | 69 ++
.../gdb.fortran/array-slices-bad.f90 | 42 +
.../gdb.fortran/array-slices-sub-slices.exp | 111 +++
.../gdb.fortran/array-slices-sub-slices.f90 | 96 +++
gdb/testsuite/gdb.fortran/array-slices.exp | 264 +++++-
gdb/testsuite/gdb.fortran/array-slices.f90 | 364 +++++++-
.../gdb.fortran/class-allocatable-array.exp | 2 +-
gdb/testsuite/gdb.fortran/multi-dim.exp | 2 +-
gdb/testsuite/gdb.fortran/vla-sizeof.exp | 4 +-
gdb/testsuite/gdb.fortran/vla-type.exp | 6 +-
gdb/testsuite/gdb.mi/mi-vla-fortran.exp | 2 +-
gdbsupport/ChangeLog | 22 +
gdbsupport/enum-flags.h | 50 +-
34 files changed, 2485 insertions(+), 509 deletions(-)
create mode 100644 gdb/f-array-walker.h
create mode 100644 gdb/testsuite/gdb.fortran/array-slices-bad.exp
create mode 100644 gdb/testsuite/gdb.fortran/array-slices-bad.f90
create mode 100644 gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
create mode 100644 gdb/testsuite/gdb.fortran/array-slices-sub-slices.f90
--
2.25.4
next reply other threads:[~2020-08-13 12:58 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 12:58 Andrew Burgess [this message]
2020-08-13 12:58 ` [PATCH 1/8] gdbsupport: Provide global operators |=, &=, and ^= for enum bit flags Andrew Burgess
2020-08-15 17:16 ` Tom Tromey
2020-08-16 9:13 ` Andrew Burgess
2020-08-17 10:40 ` Andrew Burgess
2020-08-20 16:00 ` Pedro Alves
2020-08-21 14:49 ` Pedro Alves
2020-08-21 15:57 ` Andrew Burgess
2020-08-21 18:10 ` Pedro Alves
2020-08-13 12:58 ` [PATCH 2/8] gdbsupport: Make function arguments constant in enum-flags.h Andrew Burgess
2020-08-15 19:45 ` Tom Tromey
2020-08-16 9:08 ` Andrew Burgess
2020-08-13 12:58 ` [PATCH 3/8] gdb/fortran: Clean up array/string expression evaluation Andrew Burgess
2020-08-13 12:58 ` [PATCH 4/8] gdb/fortran: Move Fortran expression handling into f-lang.c Andrew Burgess
2020-08-13 12:58 ` [PATCH 5/8] gdb/fortran: Change whitespace when printing arrays Andrew Burgess
2020-08-13 12:58 ` [PATCH 6/8] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-08-13 12:58 ` [PATCH 7/8] gdb/testsuite: Add missing expected results Andrew Burgess
2020-08-13 12:58 ` [PATCH 8/8] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-08-13 13:31 ` Eli Zaretskii
2020-08-26 14:49 ` [PATCHv2 00/10] Fortran Array Slicing and Striding Support Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 01/10] Rewrite valid-expr.h's internals in terms of the detection idiom (C++17/N4502) Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 02/10] Use type_instance_flags more throughout Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 03/10] Rewrite enum_flags, add unit tests, fix problems Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 04/10] gdb: additional changes to make use of type_instance_flags more Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 05/10] gdb/fortran: Clean up array/string expression evaluation Andrew Burgess
2020-09-19 8:53 ` Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 06/10] gdb/fortran: Move Fortran expression handling into f-lang.c Andrew Burgess
2020-09-19 8:53 ` Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 07/10] gdb/fortran: Change whitespace when printing arrays Andrew Burgess
2020-09-19 8:54 ` Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 08/10] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 09/10] gdb/testsuite: Add missing expected results Andrew Burgess
2020-09-18 9:53 ` Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 10/10] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-08-26 17:02 ` Eli Zaretskii
2020-09-19 9:47 ` [PATCHv3 0/2] Fortran Array Slicing and Striding Support Andrew Burgess
2020-09-19 9:48 ` [PATCHv3 1/2] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-09-19 13:50 ` Simon Marchi
2020-09-19 9:48 ` [PATCHv3 2/2] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-09-19 10:03 ` Eli Zaretskii
2020-09-28 9:40 ` [PATCHv4 0/3] Fortran Array Slicing and Striding Support Andrew Burgess
2020-09-28 9:40 ` [PATCHv4 1/3] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-09-28 9:40 ` [PATCHv4 2/3] gdb: rename 'enum range_type' to 'enum range_flag' Andrew Burgess
2020-09-28 9:40 ` [PATCHv4 3/3] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-09-28 9:52 ` Eli Zaretskii
2020-10-11 18:12 ` [PATCHv5 0/4] Fortran Array Slicing and Striding Support Andrew Burgess
2020-10-11 18:12 ` [PATCHv5 1/4] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-10-20 20:16 ` Tom Tromey
2020-10-11 18:12 ` [PATCHv5 2/4] gdb: rename 'enum range_type' to 'enum range_flag' Andrew Burgess
2020-10-20 20:16 ` Tom Tromey
2020-10-11 18:12 ` [PATCHv5 3/4] gdb/fortran: add support for parsing array strides in expressions Andrew Burgess
2020-10-12 13:21 ` Simon Marchi
2020-10-20 20:17 ` Tom Tromey
2020-10-22 10:42 ` Andrew Burgess
2020-10-11 18:12 ` [PATCHv5 4/4] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-10-12 14:10 ` Simon Marchi
2020-10-20 20:45 ` Tom Tromey
2020-10-29 11:08 ` Andrew Burgess
2020-10-31 22:16 ` [PATCHv6] " Andrew Burgess
2020-11-12 12:09 ` Andrew Burgess
2020-11-12 18:58 ` Tom Tromey
2020-11-19 11:56 ` Andrew Burgess
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=cover.1597319264.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/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).