From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id F3EE33858433 for ; Fri, 20 Jan 2023 13:42:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F3EE33858433 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-lf1-x12b.google.com with SMTP id d30so8144746lfv.8 for ; Fri, 20 Jan 2023 05:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gWozHeBAZT7O2UPt/RqNYruKlQABU2IWJxBbEOe4hns=; b=gedPWEGCOhUoLg/htymtzruVn3hYZiCI2zO1kolflIVi7K5efNbiIj1rRocjtO0ygr QBbuUvdE7YO3JqvkPjoRLXFeCMDgB2xVNNuXI2WPC63xZnqbwYKvRxpCG1NVBKMGUdg4 F0H5UI7TuOUM81IcqpOMEme7m7uOHVSXTl3a8f1rnQQltpaJjOL6A06dVFSw/UYL+pC8 +tEMvRE8+qO8lNoEVlxykg/Uqg1dM/LrOWSx1bnMS9VECEgKF8u7dFGV1AYgug5n2kpr HpqfImtOP/CrZQ6cRx3iZTev0r2PRrTVy6EaUhhsgABDfTPqzeS0+8T/dSGrqE6eu+SJ UTNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gWozHeBAZT7O2UPt/RqNYruKlQABU2IWJxBbEOe4hns=; b=kOO5FCjSFKz8zW+JcEzGC52woTQyelhxyujAojoZ9naIfCgAJJ7HtfMvU3DOlPIY50 NRyBDEp5giaFw2oWOpDUI/GeEj8+LPmY9k48x9yR3TT+BYSxVChaSucJAFGogefrh7t7 Rhg7/Y7PX1iTCepI9sGlK6F2uaqP78wi8fjf8c797X3W5liNdFvEidWDFF/mDID7kga6 Y14YZTn7qQzBLMvJrgkMl2pXnsSJPckxoJU6vwWQqF5j9+hKvKS/P15V+kwLKMnMtI4P hP7d0T2O4aeG4/MyZ8wDsyd/06rW4+RX+sLYP9Iq888UB+lotiAdJmNeOTIffr6Xn3cE pMzw== X-Gm-Message-State: AFqh2kr7WfBa6CWMBY4YkevAwgIt3KzatMyBexnAU3EDX6YDmUqrj+1C e6rIdLzwrcTx0+mUOYIVH8DfqA== X-Google-Smtp-Source: AMrXdXv23tH4dLJJrofHZWDUlKBAXUsgDhIVXcXLRjsZc3QTCQlnu6Q8IViMhnvUG25IOyFfP4Ez/A== X-Received: by 2002:a05:6512:1196:b0:4cb:ea9:b0d7 with SMTP id g22-20020a056512119600b004cb0ea9b0d7mr4759444lfr.9.1674222144404; Fri, 20 Jan 2023 05:42:24 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id i8-20020a056512006800b004d05d3ed213sm2684819lfo.83.2023.01.20.05.42.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jan 2023 05:42:14 -0800 (PST) Date: Fri, 20 Jan 2023 13:41:55 +0000 (GMT) From: "Maciej W. Rozycki" To: Andrew Burgess cc: gdb-patches@sourceware.org, Tom Tromey , Richard Bunt Subject: Re: [PATCH v2 1/5] GDB: Ignore `max-value-size' setting with value history accesses In-Reply-To: <87zgamflwz.fsf@redhat.com> Message-ID: References: <87zgamflwz.fsf@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.5 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 13 Jan 2023, Andrew Burgess wrote: > > @@ -1752,12 +1763,14 @@ value_release_to_mark (const struct valu > > return result; > > } > > > > -/* Return a copy of the value ARG. > > - It contains the same contents, for same memory address, > > - but it's a different block of storage. */ > > +/* Return a copy of the value ARG. It contains the same contents, > > + for the same memory address, but it's a different block of storage. > > + If CHECK_SIZE is true, then throw an exception whenever the size > > + of memory allocated for the contents of the value would exceed > > + max-value-size. */ > > > > -struct value * > > -value_copy (const value *arg) > > +static struct value * > > +value_copy (const value *arg, bool check_size) > > { > > struct type *encl_type = value_enclosing_type (arg); > > struct value *val; > > @@ -1765,7 +1778,7 @@ value_copy (const value *arg) > > if (value_lazy (arg)) > > val = allocate_value_lazy (encl_type); > > else > > - val = allocate_value (encl_type); > > + val = allocate_value (encl_type, check_size); > > I wonder, maybe value_copy should never check the max-value-size. As > you point out above, the max-value-size was introduced to catch cases > where attempting to read a value from the inferior would cause GDB to > try an allocate a stupid amount of memory. > > We don't currently have any mechanism in GDB to try an cap the > cumulative memory usage across all values, which suggests that > currently, once a value has been read into GDB we assume we can safely > make as many copies as we want. > > And so, is there any reason why value_copy shouldn't always disable the > size check? I had to investigate that and found out that in addition to value history accesses `value_copy' is only used for internal variables (which is fine; I guess that's one reason for the minimum of 16 set for `max-value-size'), and then an obscure piece of code called `make_cv_value'. Said function is only referred to from Python and Scheme support code, and its interaction with `max-value-size' is not covered by the testsuite. I have added a suitable test case then and that has verified it is indeed fine for `value_copy' to always disable the size check. Thank you for the suggestion then. Since I missed a couple of copyright year updates with the original submission and also Tom's recent conversion requires the use of `allow_ada_tests' rather than `skip_ada_tests' in Ada test cases, I'll respin the patch series with all the necessary updates. Maciej