Issue 070426.1: Constant expressions in location lists

Author: Cary Coutant
Champion:
Date submitted: 2007-04-26
Date revised:
Date closed:
Type: Extension
Status: Accepted
DWARF Version: 4
Background

A problem we've come up with in improving our support for optimized  
code on HP-UX is in trying to describe a variable that sometimes has  
a constant value (not available in memory or in a register) during  
portions of its live range. A variable that is constant everywhere  
can be described by DW_AT_const_value, but there is no way (that I  
can see) to represent a constant value in a location list.

Proposal

I propose to add a new "DW_OP_implicit_value" operator that would  
provide the constant value for ranges where a variable has no actual  
location, but is known to have a constant value. Like the DW_OP_reg*  
operators, it must occur either alone or as the only operator in a  
piece expression.

Modify Section 2.5.1, "Register Name Operators", as follows:

   2.5.1  Register Name and Implicit Value Operators

   The following DWARF operations can be used to name a register
   or to provide an implicit value of arbitrary size and type.
   They can be used only in location expressions, and must be
   used alone (either as a DWARF expression consisting of just
   that one operation or as the sole operator in a piece
   expression).

   *Note that ...*

   1. DW_OP_reg0, ...
      ...

   2. DW_OP_regx
      ...

   3. DW_OP_implicit_value
      The DW_OP_implicit_value operation takes two operands:
      an unsigned LEB128 length, followed by a block
      representing the value in the native representation of the
      target machine. The length operand gives the length in
      bytes of the block that follows. This operation should be
      used only in location lists for ranges where the value of
      a variable does not exist in memory or in a register, but
      is known to be constant.

In Section 7.7.1, "DWARF Expressions", add the following row to  
Figure 22:

                                  No. of
   Operation               Code  Operands   Notes
   ----------------------------------------------------------------
   DW_OP_constant_value    0x9b      2      ULEB128 length followed
                                            by length bytes
   ----------------------------------------------------------------

==================================================================

Proposal accepted without modification.