From: "Maciej W. Rozycki" <macro@embecosm.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches@sourceware.org, Tom Tromey <tom@tromey.com>,
Richard Bunt <Richard.Bunt@arm.com>
Subject: Re: [PATCH v2 1/5] GDB: Ignore `max-value-size' setting with value history accesses
Date: Fri, 20 Jan 2023 13:41:55 +0000 (GMT) [thread overview]
Message-ID: <alpine.DEB.2.20.2301200109370.7841@tpp.orcam.me.uk> (raw)
In-Reply-To: <87zgamflwz.fsf@redhat.com>
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
next prev parent reply other threads:[~2023-01-20 13:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 9:01 [PATCH v2 0/5] gdb: introduce limited array lengths while printing values Maciej W. Rozycki
2023-01-12 9:01 ` [PATCH v2 1/5] GDB: Ignore `max-value-size' setting with value history accesses Maciej W. Rozycki
2023-01-13 16:18 ` Andrew Burgess
2023-01-20 13:41 ` Maciej W. Rozycki [this message]
2023-01-12 9:01 ` [PATCH v2 2/5] GDB: Fix the mess with value byte/bit range types Maciej W. Rozycki
2023-01-12 9:02 ` [PATCH v2 3/5] GDB: Only make data actually retrieved into value history available Maciej W. Rozycki
2023-01-12 9:02 ` [PATCH v2 4/5] GDB/testsuite: Add `-nonl' option to `gdb_test' Maciej W. Rozycki
2023-01-12 9:02 ` [PATCH v2 5/5] GDB: Introduce limited array lengths while printing values Maciej W. Rozycki
2023-01-12 10:04 ` Eli Zaretskii
2023-01-12 10:58 ` Maciej W. Rozycki
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=alpine.DEB.2.20.2301200109370.7841@tpp.orcam.me.uk \
--to=macro@embecosm.com \
--cc=Richard.Bunt@arm.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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).