[Dwarf-discuss] PROPOSAL: Constant expressions in locations lists

Cary Coutant cary at cup.hp.com
Thu Apr 26 14:59:54 PDT 2007

This is a revision of my original March 7 proposal. Based on feedback  
from that discussion and from the last DWARF workgroup meeting, I'm  
ready to submit this as a formal proposal for the next DWARF revision.

I kind of liked Ron's suggestion to have a pointer to a  
DW_TAG_constant DIE, but I didn't like the idea that it would be the  
first example of reference to a DIE from outside the debug_info  
section (and therefore something other than an attribute with form  



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.


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

   <i>Note that ...</i>

   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

More information about the Dwarf-Discuss mailing list