[Dwarf-discuss] Constant expressions in locations lists

Cary Coutant cary@cup.hp.com
Wed Mar 7 18:20:59 GMT 2007


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.

If I'm missing something that would allow this, I'd be happy to learn  
of it. Otherwise, I have a fairly simple suggestion:

I propose to add a new "DW_OP_addressof" operator (it could also be  
named "DW_OP_ref" or "DW_OP_lvalue" -- I haven't picked a favorite  
yet) that would turn the value on the top of the stack into a  
reference to that constant value. A location expression ending with  
this operator would be valid anywhere a DW_OP_regx operator is valid,  
and could also be applied to the portion of a location expression  
described by DW_OP_piece.

An alternative that we considered was to extend the location list  
definition to provide a way of distinguishing each location list  
entry as either a location expression or a constant value. I prefer  
the new operator, though, as it's more flexible and less impact  
overall to the DWARF spec.

-cary





More information about the Dwarf-discuss mailing list