[Dwarf-Discuss] DWARF piece questions

Andreas Arnez arnez@linux.vnet.ibm.com
Mon Dec 12 14:28:22 GMT 2016


On Fri, Dec 09 2016, Adrian Prantl wrote:

> Here's my take on this.

Thanks!

>> On Dec 9, 2016, at 11:11 AM, Andreas Arnez <arnez at linux.vnet.ibm.com> wrote:
>> 
>> Although I've already created public comments for (most of) this,
>> Michael Eager suggested that I post my questions regarding DWARF pieces
>> on this list (again).
>> 
>> All of these questions are related to the definition of DW_OP_piece and
>> DW_OP_bit_piece:
>> 
>> * Is "DW_OP_piece(n)" equivalent to "DW_OP_bit_piece(8*n, 0)"?
>
> I would think the answer to this is yes, and if it isn't I would
> really like to see the counterexample added to the Appendix.

Right, I think clarification would be appropriate either way.

Does anybody vote for "no"?

>> * What is the correct placement rule for register pieces?  ABI-defined
>>  or lsb0-ordered?  If lsb0-ordered, how exactly is that order defined
>>  for non-integer registers?
>
> "If the location is a register, the offset is from the least
> significant bit end of the register."
> Does this text from the latest draft answer the question?
> If not, can you give an example where it isn't?

The definition of DW_OP_piece differs, though: "[...] the placement of
the piece within that register is defined by the ABI."

>> * Shall DW_OP_bit_piece ignore the offset for stack- and implicit
>>  values?
>
> "If the location is any implicit value or stack value, the
> DW_OP_bit_piece operation describes a sequence of bits using the least
> significant bits of that value."
>
> No.

Really?  IMHO the wording implies that the least significant bit always
belongs to the piece.

>> * What is the "least significant bit" of an implicit value?  And is it
>>  intentional that the placement rule differs between implicit- and
>>  memory values?
>
> I don't know.
>
>> 
>> * Some DWARF producers describe a register pair just with a single
>>  DW_OP_reg<n>.  Can a register piece reach into the next register like
>>  that as well?
>
> You mean for a pair of r1,r2 they would emit only DW_OP_reg1? I don't
> think this use is supported by the DWARF specification.

OK.  Are there other opinions?

>> * Is "DW_OP_reg*" followed by "DW_OP_piece(size of object type)" always
>>  equivalent to omitting the piece operation?
>
> If sizeof(obj) == sizeof(reg) it is obviously.
> If sizeof(obj) > sizeof(reg) the expression is malformed because there
> are undefined bits in the object that should have been represented
> with an empty DW_OP_piece.

GCC may describe a long double struct member on x86 as

  DW_OP_regx: 33 (st0); DW_OP_piece: 16

where st0 is only 10 bytes wide.  Is that invalid then?

> If sizeof(obj) < sizeof(reg) the expression is overspecified, but
> still sound, so I would say yes.

So you'd say the placement rules for DW_OP_reg* and DW_OP_piece shall be
compatible, both defined by the ABI -- not necessarily lsb0-ordered?
And the bytes referred to by a "DW_OP_reg*"-location may depend on the
object's size, but not its type, right?

Note that this wouldn't work well with cases like the "SPU preferred
slots"; see https://sourceware.org/ml/gdb/2016-01/msg00013.html, section
2.2.

--
Andreas




More information about the Dwarf-discuss mailing list