[PATCH v2 2/3] [gdb] Add gdbarch_dwarf2_reg_piece_offset hook

Andreas Arnez arnez@linux.ibm.com
Tue Jan 21 18:18:42 GMT 2025


On Fri, Jan 17 2025, Tom Tromey wrote:

> Tom de Vries said the earlier issue was:
>
>     https://dwarfstd.org/issues/161206.2.html
>
> I can't speak for DWARF and TBH have as little to do with it as I can,
> but I asked about your case and Mark Wielaard suggested maybe re-filing.
>
> Personally I think bringing up the case of vector registers, where
> "least significant bit" isn't really well-defined, would improve the
> report.

Perhaps like this? --

    https://dwarfstd.org/issues/161206.1.html

So I think tried that before.  The rejection just states it as a fact
that the "least significant bit is well defined for registers and
values".  No explanation, no source, nothing.  My reasoning against that
claim was completely ignored.

Issue 161206.2 suggests that bit and byte pieces follow the same
placement rules.  Otherwise all DWARF producers and consumers would have
to maintain two different rulesets (and perhaps even in addition to the
non-piece rule, as implemented in GDB by the value_from_register gdbarch
method).  The rejection argues with compatibility, which IMHO seems
laughable, since no tool I know of had handled DWARF pieces even
remotely correctly until then, particularly on big-endian platforms.

But no matter how many rulesets for taking register pieces are needed,
the fact remains that the "least significant bit" isn't generally well
defined.  Thus I'd say whichever rule applies to DW_OP_bit_piece must be
ABI-defined instead.

While we're at it, I had filed another issue along with these two, about
implicit value pieces:

    https://dwarfstd.org/issues/161206.3.html

Again, the term "least significant bit" is used in a context where it
doesn't make sense.  And here the piece offset isn't even mentioned in
the description at all.  It's anyone's guess what happens with it, or if
it's ignored (as the current wording seems to imply).

> Simon also mentioned that the "DWARF for GPUs" work might be relevant.
> From our brief discussion on irc it sounded to me like they'd hit the
> same sort of issue and came to the same sort of conclusion.
>
> So I guess if you wanted to change this code to treat bit-piece as
> ABI-defined, and if this helped with some currently-existing code, then
> I'd be inclined to approve that.

Right, that's what I think needs to be done in the implementation.
Maybe I'll see if I can come up with a patch I feel somewhat comfortable
with.

Regarding the broken wording in the DWARF standard, I'm probably not the
right person to re-address this.  After my extremely frustrating
experience with the DWARF committee, I really don't feel like going
through the pain again.  And I'm not sure they'd even still talk to me.
However, I'd be happy to support anyone willing to try.  Perhaps someone
from the "DWARF for GPUs" work wants to take a shot?

>
> thanks,
> Tom

-- 
Andreas


More information about the Gdb-patches mailing list