From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/6] gdb: use TARGET_CHAR_BIT more in dwarf2/expr.c
Date: Fri, 15 May 2026 08:44:12 -0600 [thread overview]
Message-ID: <87o6igivgj.fsf@tromey.com> (raw)
In-Reply-To: <87y0hkdgs4.fsf@redhat.com> (Andrew Burgess's message of "Fri, 15 May 2026 13:00:11 +0100")
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
Andrew> if (!check_optimized)
Andrew> copy_bitwise (v_contents, offset,
Andrew> - buffer.data (), bits_to_skip % 8,
Andrew> + buffer.data (), bits_to_skip % TARGET_CHAR_BIT,
Andrew> this_size_bits, bits_big_endian);
>> In this situation it seems to me that gdb is manipulating host-side data.
Andrew> Aren't the value contents pulled from the inferior though? And
Andrew> bits_to_skip and this_size_bits are all from DWARF properties that
Andrew> describe the inferior's data, so I don't understand why TARGET_CHAR_BIT
Andrew> wouldn't be correct? I got really confused trying to reason this all
Andrew> through.
Yeah, I think it's confusing as well, and I'm not really sure if I am
correct.
But, my reasoning is that here we are dealing with host-side data. It
is stored as 8-bit bytes in 'buffer'.
And, in this spot we are dealing with bit offsets. To find the correct
data, we have to convert this to a byte offset in 'buffer' -- but buffer
is in host-side units and so, I think, we need a host-side conversion.
If the DWARF originally specified the offset as a byte offset, then it
was already multiplied by TARGET_CHAR_BIT when converting to a bit
offset.
Alternatively if the DWARF originally specified the offset as a bit
offset, bit offsets aren't dependent on the byte size. So using the
host size is still correct since that will find the correct data in
'buffer'.
Andrew> Maybe the 8-bit byte assumption is just baked into GDB too much?
My feeling is yes. If gdb ever had to target a machine with 9-bit bytes
I would quit and start a farm or learn deep-sea welding. Something
easy.
I think there's been some attempt at targeting a machine with 16-bit
"bytes" (see the addressable_memory_unit_size gdbarch hook). Some
multiple of 8 is maybe doable.
Andrew> I eventually just decided to drop this patch from the series.
I'm sorry about that. I do think it's fine to do, as a marker for what
might need to change.
Tom
next prev parent reply other threads:[~2026-05-15 14:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 10:07 [PATCH 0/6] Fix aggregate types, synthetic pointers, and computed locations bug Andrew Burgess
2026-05-12 10:07 ` [PATCH 1/6] gdb: int to bool conversion in valprint.{c,h} Andrew Burgess
2026-05-13 14:48 ` Tom Tromey
2026-05-12 10:07 ` [PATCH 2/6] gdb: use TARGET_CHAR_BIT more in dwarf2/expr.c Andrew Burgess
2026-05-13 15:05 ` Tom Tromey
2026-05-15 12:00 ` Andrew Burgess
2026-05-15 14:44 ` Tom Tromey [this message]
2026-05-12 10:07 ` [PATCH 3/6] gdb: fix coerce_pieced_ref for multi-piece values Andrew Burgess
2026-05-14 18:53 ` Tom Tromey
2026-05-12 10:07 ` [PATCH 4/6] gdb: rename argument in valprint_check_validity Andrew Burgess
2026-05-13 16:23 ` Tom Tromey
2026-05-12 10:07 ` [PATCH 5/6] gdb: remove embedded_offset argument that is always 0 Andrew Burgess
2026-05-13 15:27 ` Tom Tromey
2026-05-12 10:07 ` [PATCH 6/6] gdb: use value::embedded_offset in check_pieced_synthetic_pointer Andrew Burgess
2026-05-14 19:00 ` Tom Tromey
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=87o6igivgj.fsf@tromey.com \
--to=tom@tromey.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/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