[Dwarf-discuss] Constant expressions in locations lists

Jim Blandy jimb@red-bean.com
Thu Mar 8 22:12:08 GMT 2007


On 3/8/07, Chris Quenelle <Chris.Quenelle at sun.com> wrote:
> I don't like the idea of using DW_AT_location to describe a constant
> value for a variable.  It's confusing.
>
> It might be more understandable to add DW_AT_value as an attribute,
> make it work just like DW_AT_location, but have it imply that the result
> of evaluating the stack is a value instead of a location.
> (It could be used as a super-set of DW_AT_location)
>
> Of course, the whole idea that it points to a "location list"
> is also confusing....

The case to consider (which I think was brought up) is where a
variable is constant at some points in the code, and has different
homes at other points.  The appeal of a DW_OP_constant_value operator
is that it fits nicely into a location list, and can be used for
pieces of a value that is only partly const.  We could get the same
behavior from a separate attribute, but weaving the two together would
be hairy.

However we decide to do it, we'll need to emphasize that "constant
value" locations are only to be used when a variable has no location,
but its value is known.  For example, immediately after a statement
like:

   a = 3;

the value of a is known to be a constant, but if a is in fact located
in a register which has now had 3 stored into it, describing the
location of a as "a constant" would be annoying, since it would
prevent you from assigning to it even though that's perfectly
feasible.




More information about the Dwarf-discuss mailing list