[Dwarf-Discuss] PROPOSAL: Constant expressions in location lists

Michael Eager eager@eagercon.com
Tue Jan 8 00:03:17 GMT 2008


Jim Blandy wrote:
> On Jan 6, 2008 7:38 PM, Michael Eager <eager at eagercon.com> wrote:
>>> There's no necessary restriction on what types of values a compiler
>>> might be able to optimize out; in the most general case, the values to
>>> be computed could be structures, large floating-point types, etc.  So
>>> DWARF needs to be able to describe how to compute values with
>>> arbitrary source types.
>> No, you only need to be able to interpret the instructions given
>> by the compiler to compute a machine value.  This does not require
>> that a debugger have a source language interpreter, and in particular,
>> it doesn't require DWARF to be able to describe arbitrary source
>> types.
> 
> I'm not sure I follow.  If the task is to be able to recompute values
> of variables that have been optimized out, and those variables could
> potentially have any type, then DWARF needs to be able to express how
> to compute the run-time, target representations of values of arbitrary
> type.

Yes, only target representations.  That's values that the hardware supports:
int and float.  These are the base types defined for the machine.

>>> DWARF does have DWARF expressions, but their semantics were
>>> deliberately restricted to computing address-sized values, to keep the
>>> specification simple and focussed.  We're now considering using DWARF
>>> expressions to compute (potentially) every type of value expressible
>>> in the source language.
>> This seems to exaggerate the problem.  You don't need to compute
>> "every value expressible in the source".  Instead you need to compute
>> every value expressible in the machine.  Machines have a very narrow
>> range of types, usually two: binary integer and floating point.  And
>> it may not be necessary to even compute that range -- all you care
>> about is bit patterns.
> 
> Yes --- but this isn't a simplification.  If the variable that has
> been optimized out has a class type (which I'll bet C++ compilers
> dealing with STL code do now), then the compiler would need to produce
> DWARF expressions that yield the run-time, target representation
> values having that class type.

But only values which are base types.  Every source language
type is composed of base types, either directly or indirectly.

>> As indicated above, it isn't clear that you need to implement
>> floating point operations in DWARF expressions.  But even if you
>> did, this is not by any means a task of "ridiculous complexity".
>> It would require perhaps a half-dozen well defined operations
>> which would operate on the top of the expression stack.
> 
> If we extend the DWARF expression stack to hold floating-point values,
> of various widths, then that would address the problem.  I think it
> would be more than a half-dozen operations, but still quite practical.
> I think we'll end up wanting to expand our set of arithmetic operators
> as well.

Agreed.

-- 
Michael Eager	 eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077




More information about the Dwarf-discuss mailing list