Issue 160621.1: More register location description clarifications

Author: Andrew Cagney
Champion:
Date submitted: 2016-06-21
Date revised:
Date closed:
Type: Editorial
Status: Accepted
DWARF Version: 5
Section 2.5.1.7 Special Oper, pg 34
This follows up earlier editorial changes put forward by Tommy Hoffner.

Rationale:

Based on my recollection of the discussion about "register location 
descriptions", while it was a significant optimization for a common case 
this wasn't clear from the description.

2.5.1.7 Special Operations; Page 34
2. DW_OP_entry_value

Change 1:

Order the "DWARF expression" and "register location description" text
consistently; i.e., have DWARF expression first.

Old:

It has two operands: an unsigned LEB128 length, followed by a
block containing a DWARF expression or a register location description
(see Section 2.6.1.1.3 on page 36). The length operand specifies the
length in bytes of the block. If the block contains a register
location description, DW_OP_entry_value pushes the value that register
had upon entering the current subprogram. If the block contains a
DWARF expression, the DWARF expression is evaluated as if it has been
evaluated upon entering the current subprogram.

New:

It has two operands: an unsigned LEB128 length, followed by a
block containing a DWARF expression or a register location description
(see Section 2.6.1.1.3 on page 36). The length operand specifies the
length in bytes of the block. If the block contains a DWARF
expression, the DWARF expression is evaluated as if it has been
evaluated upon entering the current subprogram. If the block contains
a register location description, DW_OP_entry_value pushes the value
that register had upon entering the current subprogram.

Change 2:

Append the following, which hopefully provides a rationale for "register 
location description", to the non-normative text that follows the above 
(See top of page 35).

New:

The register location description provides a more compact form for the
case where the value was in a register on entry to the subprogram.


Change 3.

D.1.3 DWARF Location Description Examples; Page 283

Re-order / add to the DW_OP_entry_value examples so that, where applicable,
show the "DWARF expression" form, and then follow that with the more compact 
"register location description" form as follows:

Before "DW_OP_entry_value 1 DW_OP_reg1" insert the new example:

DW_OP_entry_value 2 DW_OP_breg1 0
  The value register 1 contained upon entering the current subprogram is
  pushed on the stack.


Reword example "DW_OP_entry_value 1 DW_OP_reg1" to refer to the above, i.e.

Old:

DW_OP_entry_value 1 DW_OP_reg1
  The value register 1 contained upon entering the current subprogram is 
  pushed on the stack.

New:

DW_OP_entry_value 1 DW_OP_reg1
  Same as the previous example (push the value register 1 contained upon 
  entering the current subprogram) but use the more compact register 
  location description.


Reorder / Change the next two examples in the same way. i.e,:

Old:

DW_OP_entry_value 1 DW_OP_reg1 DW_OP_stack_value
  The value register 1 contained upon entering the current subprogram is 
  pushed on the stack. This value is the “contents” of an otherwise anonymous 
  location.

DW_OP_entry_value 2 DW_OP_breg1 0 DW_OP_stack_value
  The value register 1 contained upon entering the current subprogram (same 
  as the previous example) is pushed on the stack. This value is the “contents” 
  of an otherwise anonymous location. This and the previous location description 
  are equivalent; the previous one is shorter, however.

New:

DW_OP_entry_value 2 DW_OP_breg1 0 DW_OP_stack_value
  The value register 1 contained upon entering the current subprogram is 
  pushed on the stack. This value is the “contents” of an otherwise anonymous 
  location.

DW_OP_entry_value 1 DW_OP_reg1 DW_OP_stack_value
  Same as the previous example (use the value register 1 contained upon 
  entering the current subprogram as the "contents") but use the more compact
  register location description.


--
12/06/2016 -- Accepted.