From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 08315384A022 for ; Thu, 13 Aug 2020 12:58:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 08315384A022 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x443.google.com with SMTP id f7so5225632wrw.1 for ; Thu, 13 Aug 2020 05:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7OMhArXx4jHGArPy5Jy2KDE0Il94iMBXOoiAwZagqv4=; b=QAe8oESpOOfwHiVZ+yUwcMNfMgxjkqAmqrNQk1xOwQMpFYb6apnej80urzgpcp3oiv UHt4bKgmRIigaXHRXlBhfmR2es+0Fv3QCPaSoFdS3B9lNQDabnzGENWuSVVExSvFTPBx NBfkHB08G+RBS8hlv4ghkL4s46a4oRRtSEA3ExrwmkYQ7SdrzA5LRO9EQj4t7lPQH2tM 0hLtb4dNm+1lAEeBjoFTQMTkrrYfP3/kCXdDtJDX9I161zmQD+6nuroNn0YAxuZmdt6o O9wwM5ErikVuDFr18NSSwhfC8SobC7SU5N7l0E92iAYuTWPao6zflxBNZrm+yXfGeeMu Q95A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7OMhArXx4jHGArPy5Jy2KDE0Il94iMBXOoiAwZagqv4=; b=ct7e/OFYjIslmpuID0gjkZnv7gb1YDHiIOsZhOup45h7FdYy89ayJM5Bq3i4LCicHD BNEs/Bp/+Usc+8UyLy+hn7cLeFbyjbfKQF6qzDZuRptkHWVAsF+04qEvuDAvgrxaraTE JHmPxPBlK4jwtF+nb6NKfcWvKcvZWnQKUrHf3+VER96zRrtulz6ltR0tjNZiLjixf9/r Ag3IJnp9nPBIXZcWQxecaAl9i9lIqPz2LcMDefc3EPhGXHuKiRaEkHtTMy7TLgvjbW4u 4fy1fiQveipSvw9vEA0YvxMeh5isftpyF8hubN7sVhlSZSZWt80qF8aj4Za5YgvWI66i HcgQ== X-Gm-Message-State: AOAM530Daa5uOwLbVPCxtwByOJByhCqk+GEPiDGKQl9MUBFeE7J0Mpkt 6bjIQWXxCaA7T3QQVspzGO+Z0VYxBMM= X-Google-Smtp-Source: ABdhPJyWnDV+v+O6zXU3XGk9Nj7JigXGPfpIxvJLCMKrhHiYLv3bGQ18IF+KfirVjvuWr8gkN0CQlA== X-Received: by 2002:adf:f045:: with SMTP id t5mr4203690wro.288.1597323530641; Thu, 13 Aug 2020 05:58:50 -0700 (PDT) Received: from localhost (host86-186-80-213.range86-186.btcentralplus.com. [86.186.80.213]) by smtp.gmail.com with ESMTPSA id c15sm9121378wme.23.2020.08.13.05.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 05:58:49 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCH 0/8] Fortran Array Slicing and Striding Support Date: Thu, 13 Aug 2020 13:58:37 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2020 12:58:53 -0000 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