From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 952513858D28 for ; Tue, 24 Jan 2023 12:59:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 952513858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKItC-0007us-Ja; Tue, 24 Jan 2023 07:59:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=XJ+0Do6UN+PN1MpURSlzjsBrQUTvqDaCZtBz4/408eU=; b=QPTDwrRchmfi GXgbZbH4TA0trRbCapgXStZs/yzpHzPiczU38ZJeBVqbtWQAcpFezuhP3kV0rEHYGlN09L0Wk+EyR YZuuvDwJhtgS980W3CZNh7oy1WtV96GtZBhkW+B7k+3yzv56O4oO7ZmslEtjhZCnwHPxS6P/rfHMm xb8Rnxw+8wcJTs6DJpe4Y51MeU8jc3UnOf9EbP+Rq6h0QnvMWdyBh6AHoRZPxLAWcW4myBDZrlTP8 go/hf6Jzc+gQkFOPuW7/nWxZylD+OFuRmAnJnD3sFvoGOeaXsyd/YTdEC3ULHeyQkhWKNj2Zjb3I1 4EmBRu/+leSeKLydL/qNYQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKItB-0006vj-Ux; Tue, 24 Jan 2023 07:59:02 -0500 Date: Tue, 24 Jan 2023 14:59:12 +0200 Message-Id: <83v8kwgkbj.fsf@gnu.org> From: Eli Zaretskii To: "Maciej W. Rozycki" Cc: gdb-patches@sourceware.org, aburgess@redhat.com, tom@tromey.com, Richard.Bunt@arm.com In-Reply-To: (macro@embecosm.com) Subject: Re: [PATCH v3 5/5] GDB: Introduce limited array lengths while printing values References: X-Spam-Status: No, score=1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Date: Mon, 23 Jan 2023 23:14:35 +0000 (GMT) > From: "Maciej W. Rozycki" > cc: Andrew Burgess , Tom Tromey , > Richard Bunt > > From: Andrew Burgess > > This commit introduces the idea of loading only part of an array in > order to print it, what I call "limited length" arrays. > > The motivation behind this work is to make it possible to print slices > of very large arrays, where very large means bigger than > `max-value-size'. > > Consider this GDB session with the current GDB: > > (gdb) set max-value-size 100 > (gdb) p large_1d_array > value requires 400 bytes, which is more than max-value-size > (gdb) p -elements 10 -- large_1d_array > value requires 400 bytes, which is more than max-value-size > > notice that the request to print 10 elements still fails, even though 10 > elements should be less than the max-value-size. With a patched version > of GDB: > > (gdb) p -elements 10 -- large_1d_array > $1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9...} > > So now the print has succeeded. It also has loaded `max-value-size' > worth of data into value history, so the recorded value can be accessed > consistently: > > (gdb) p -elements 10 -- $1 > $2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9...} > (gdb) p $1 > $3 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, > 20, 21, 22, 23, 24, } > (gdb) > > Accesses with other languages work similarly, although for Ada only > C-style [] array element/dimension accesses use history. For both Ada > and Fortran () array element/dimension accesses go straight to the > inferior, bypassing the value history just as with C pointers. > > Co-Authored-By: Maciej W. Rozycki > --- > Changes from v2: > > - Adjust for the `value_copy' update in 1/5. > > - Remove the handling of (dst_len != src_len) in `value_copy' where > `dst_len' is always the same as `src_len' (from the corresponding > settings in `val' assigned to from `arg' right beforehand). > > - Switch Ada and Fortran test cases to using `allow_ada_tests' and > `allow_fortran_tests' respectively. > > - Fix a couple of formatting issues involving spaces used instead of tabs. > > Changes from v1: > > - Load `max-value-size' worth data into the value history for limited > length accesses and mark the area beyond unavailable. > > - Handle the `output' command. > > - Expand test coverage. > --- > gdb/NEWS | 6 > gdb/doc/gdb.texinfo | 9 > gdb/f-valprint.c | 32 ++- > gdb/printcmd.c | 16 + > gdb/testsuite/gdb.ada/limited-length.exp | 264 +++++++++++++++++++++++++++ > gdb/testsuite/gdb.ada/limited-length/foo.adb | 37 +++ > gdb/testsuite/gdb.ada/limited-length/pck.adb | 25 ++ > gdb/testsuite/gdb.ada/limited-length/pck.ads | 21 ++ > gdb/testsuite/gdb.base/limited-length.c | 48 ++++ > gdb/testsuite/gdb.base/limited-length.exp | 242 ++++++++++++++++++++++++ > gdb/testsuite/gdb.fortran/limited-length.exp | 220 ++++++++++++++++++++++ > gdb/testsuite/gdb.fortran/limited-length.f90 | 39 +++ > gdb/valprint.c | 10 - > gdb/value.c | 186 +++++++++++++++++-- > gdb/value.h | 17 + > 15 files changed, 1147 insertions(+), 25 deletions(-) > create mode 100644 gdb/testsuite/gdb.ada/limited-length.exp > create mode 100644 gdb/testsuite/gdb.ada/limited-length/foo.adb > create mode 100644 gdb/testsuite/gdb.ada/limited-length/pck.adb > create mode 100644 gdb/testsuite/gdb.ada/limited-length/pck.ads > create mode 100644 gdb/testsuite/gdb.base/limited-length.c > create mode 100644 gdb/testsuite/gdb.base/limited-length.exp > create mode 100644 gdb/testsuite/gdb.fortran/limited-length.exp > create mode 100644 gdb/testsuite/gdb.fortran/limited-length.f90 Thanks, the documentation parts are OK.