[gdb] Add gdbarch_dwarf2_reg_piece_offset hook

In rw_pieced_value, when reading/writing part of a register, DW_OP_piece and
DW_OP_bit_piece are handled the same, but the standard tells us:
- DW_OP_piece: if the piece is located in a register, but does not occupy the
  entire register, the placement of the piece within that register is defined
  by the ABI.
- DW_OP_bit_piece: if the location is a register, the offset is from the least
  significant bit end of the register.

Add a new hook gdbarch_dwarf2_reg_piece_offset that allows us to define the
ABI-specific behaviour for DW_OP_piece.

The default implementation of the hook is the behaviour of DW_OP_bit_piece, so
there should not be any functional changes.

Tested on s390x-linux.

Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Tom de Vries
2025-01-15 17:02:00 +01:00
parent c4606bdbd5
commit b034bb3877
6 changed files with 91 additions and 6 deletions

View File

@@ -829,6 +829,22 @@ allocate and return a struct value with all value attributes
invalid=False,
)
Method(
comment="""
For a DW_OP_piece located in a register, but not occupying the
entire register, return the placement of the piece within that
register as defined by the ABI.
""",
type="ULONGEST",
name="dwarf2_reg_piece_offset",
params=[
("int", "regnum"),
("ULONGEST", "size")
],
predefault="default_dwarf2_reg_piece_offset",
invalid=False,
)
Method(
type="CORE_ADDR",
name="pointer_to_address",