From: "Maciej W. Rozycki" <macro@embecosm.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org, Andrew Burgess <aburgess@redhat.com>,
Richard Bunt <Richard.Bunt@arm.com>
Subject: Re: [PATCH v3 2/5] GDB: Fix the mess with value byte/bit range types
Date: Fri, 10 Feb 2023 14:18:01 +0000 (GMT) [thread overview]
Message-ID: <alpine.DEB.2.20.2302011247300.7841@tpp.orcam.me.uk> (raw)
In-Reply-To: <87k012lgol.fsf@tromey.com>
On Tue, 31 Jan 2023, Tom Tromey wrote:
> >>>>> "Maciej" == Maciej W Rozycki <macro@embecosm.com> writes:
>
> Maciej> Consistently use the LONGEST and ULONGEST types for value byte/bit
> Maciej> offsets and lengths respectively, avoiding slient truncation for ranges
> Maciej> exceeding the 32-bit span, which may cause incorrect matching. Also
> Maciej> report a conversion overflow on byte ranges that cannot be expressed in
> Maciej> terms of bits with these data types, e.g.:
>
> Maciej> (gdb) print one_hundred[1LL << 58]
> Maciej> Integer overflow in data location calculation
> Maciej> (gdb) print one_hundred[(-1LL << 58) - 1]
> Maciej> Integer overflow in data location calculation
> Maciej> (gdb)
>
> Maciej> Previously such accesses would be let through with unpredictable results
> Maciej> produced.
>
> Thank you. I'm curious how you found the spots to change.
I have backtraced by hand, that is I started from `value_bits_available'
and `insert_into_bit_range_vector' looking for the call sites recursively.
> Maciej> + if (offset != ((offset & mask) ^ sign) - sign
> Maciej> + || length != ((length & mask) ^ sign) - sign
> Maciej> + || (length > 0 && (~offset & (offset + length - 1) & sign) != 0))
> Maciej> + error (_("Integer overflow in data location calculation"));
>
> Terrifying. And to my surprise we don't seem to have any sort of
> generic sign extension macro.
Indeed, and neither in BFD. We could have a use for one at least in
bfd/elfxx-mips.c and gdb/mips-tdep.c; probably many others. This could go
in bfd/bfd-in.h just as BFD_ALIGN, or libiberty.
Maciej
next prev parent reply other threads:[~2023-02-10 14:18 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 [this message]
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
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=alpine.DEB.2.20.2302011247300.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).