public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: "Maciej W. Rozycki" <macro@embecosm.com>
Cc: gdb-patches@sourceware.org,  Andrew Burgess <aburgess@redhat.com>,
	 Tom Tromey <tom@tromey.com>,
	 Richard Bunt <Richard.Bunt@arm.com>
Subject: Re: [PATCH v3 3/5] GDB: Only make data actually retrieved into value history available
Date: Tue, 31 Jan 2023 11:47:38 -0700	[thread overview]
Message-ID: <87fsbqlewl.fsf@tromey.com> (raw)
In-Reply-To: <alpine.DEB.2.20.2301211715160.7841@tpp.orcam.me.uk> (Maciej W. Rozycki's message of "Mon, 23 Jan 2023 23:14:06 +0000 (GMT)")

>>>>> "Maciej" == Maciej W Rozycki <macro@embecosm.com> writes:

Maciej> While it makes sense to allow accessing out-of-bounds elements in the 
Maciej> debuggee and see whatever there might happen to be there in memory (we 
Maciej> are a debugger and not a programming rules enforcement facility and we 
Maciej> want to make people's life easier in chasing bugs), e.g.:

Thank you for the patch.

Maciej> Index: src/gdb/defs.h
Maciej> ===================================================================
Maciej> --- src.orig/gdb/defs.h
Maciej> +++ src/gdb/defs.h
Maciej> @@ -469,6 +469,10 @@ enum val_prettyformat
Maciej>  #define	LONG_MAX ((long)(ULONG_MAX >> 1))   /* 0x7FFFFFFF for 32-bits */
Maciej>  #endif
 
Maciej> +#if !defined (LONG_MIN)                     /* 0x80000000 for 32-bits */
Maciej> +#define	LONG_MIN ((long) (~(long) 0 ^ LONG_MAX))
Maciej> +#endif

I wasn't aware of this code being here.

For LONG_*, I tend to think we don't need it.  <limits.h> should provide
it, and gnulib seems to think there aren't any systems without this:

https://www.gnu.org/software/gnulib/manual/html_node/limits_002eh.html

 
Maciej> +#if !defined (LONGEST_MIN)                 /* 0x8000000000000000 for 64-bits */
Maciej> +#define	LONGEST_MIN ((LONGEST) (~(LONGEST) 0 ^ LONGEST_MAX))
Maciej> +#endif

This one probably belongs in gdbsupport/common-types.h.

We should clean up this part of defs.h but I can do that.

Maciej> @@ -1950,6 +1955,15 @@ record_latest_value (struct value *val)
Maciej>       a value on the value history never changes.  */
Maciej>    if (value_lazy (val))
Maciej>      value_fetch_lazy (val);
Maciej> +
Maciej> +  /* Don't pretend we have anything available there in the history beyond
Maciej> +     the boundaries of the value recorded.  It's not like inferior memory
Maciej> +     where there is actual stuff underneath.  */
Maciej> +  ULONGEST length = value_enclosing_type (val)->length ();
Maciej> +  mark_value_bits_unavailable (val, LONGEST_MIN, 0 ^ LONGEST_MIN);
Maciej> +  mark_value_bits_unavailable (val, length * TARGET_CHAR_BIT,
Maciej> +			       LONGEST_MAX - length * TARGET_CHAR_BIT);

I'm struggling to understand why this is needed.
Like it seems to me that a value should always report that bytes outside
of its content range are unavailable.

Tom

  reply	other threads:[~2023-01-31 18:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-23 23:00 [PATCH v3 0/5] gdb: introduce limited array lengths while printing values Maciej W. Rozycki
2023-01-23 23:13 ` [PATCH v3 1/5] GDB: Ignore `max-value-size' setting with value history accesses Maciej W. Rozycki
2023-01-31 17:58   ` Tom Tromey
2023-02-10 14:17     ` Maciej W. Rozycki
2023-01-23 23:13 ` [PATCH v3 2/5] GDB: Fix the mess with value byte/bit range types Maciej W. Rozycki
2023-01-31 18:09   ` Tom Tromey
2023-02-10 14:18     ` Maciej W. Rozycki
2023-02-10 14:49       ` Tom Tromey
2023-01-23 23:14 ` [PATCH v3 3/5] GDB: Only make data actually retrieved into value history available Maciej W. Rozycki
2023-01-31 18:47   ` Tom Tromey [this message]
2023-02-10 14:18     ` Maciej W. Rozycki
2023-02-10 21:11       ` Tom Tromey
2023-01-23 23:14 ` [PATCH v3 4/5] GDB/testsuite: Add `-nonl' option to `gdb_test' Maciej W. Rozycki
2023-01-31 19:02   ` Tom Tromey
2023-01-23 23:14 ` [PATCH v3 5/5] GDB: Introduce limited array lengths while printing values Maciej W. Rozycki
2023-01-24 12:59   ` Eli Zaretskii
2023-01-31 20:49   ` Tom Tromey
2023-02-10 14:18     ` 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=87fsbqlewl.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=Richard.Bunt@arm.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@embecosm.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).