[Dwarf-Discuss] Representing the location of smaller values in vector registers

Andreas Arnez arnez at linux.vnet.ibm.com
Thu Mar 10 01:00:31 PST 2016

On Thu, Mar 10 2016, Cary Coutant wrote:

> Adrian was looking for guidance to understand what the spec says about
> placement of smaller values in larger registers. He found some
> guidance in the section on DW_OP_piece, but nowhere else, leading him
> to ask if clang should have been using DW_OP_piece to describe this
> case. That simple statement under DW_OP_piece should also apply under
> the DW_OP_reg operators, and if it had been there, it would have been
> much clearer that DW_OP_piece is totally unnecessary for his example.

Right, and I think now that we're at it, we should pay some attention to
the details.  For instance: Can a DWARF consumer assume that DW_OP_reg*
followed by DW_OP_piece(size of object type) is always equivalent to
omitting the piece operation?

As a related topic, I think that the current description of the piece
operations should be improved as well.  While the placement of
DW_OP_piece in a register is clearly stated to depend on the ABI, the
statement about DW_OP_bit_piece sounds very different: "...the offset is
from the least significant bit end of the register."  In the latter case
DWARF obviously prescribes a *specific* placement scheme, independent
from the ABI, for no apparent reason, and without defining the term
"least significant bit end".

I stumbled upon this because I noticed that the implementation of piece
operations in GDB is completely broken, and apart from fixing the
various obvious bugs, I'm still trying to figure out how the piece
operations should really behave.

For a more in-depth discussion about issues with register pieces see my
article here:


Andreas Arnez

More information about the Dwarf-Discuss mailing list