[Dwarf-discuss] PROPOSAL: Constant expressions in locations lists
Roland McGrath
roland@redhat.com
Tue Jun 5 08:14:44 GMT 2007
> My original proposal was (almost) exactly that, but several objected
> to that proposal on the basis that the DWARF expression stack is a
> simple stack of address-sized objects. Without a considerable
> overhaul of the DWARF expression language, it wouldn't be possible to
> describe constant values for anything other than integers no larger
> than a pointer.
That's not true. You can use DW_OP_piece (my proposal gave an example of a
two-word array described that way). It's entirely possible, though I
readily concede that it is awkward. (Also note that neither the status quo
nor the previous proposal allows a representation for an array or struct
that is partly constant and partly in described locations, as I propose
permitting via DW_OP_piece. That is really an orthogonal generalization
that could be applied to the block-constant specialty location expression too.)
> The new formulation sacrifices this ability to rematerialize a value for
> the ability to represent constant values of arbitrary type.
The proposal is presumably motivated by some real-world cases. Are there
in fact real-world cases where an address-variant value is sometimes a
constant that is very large, so that the DW_OP_piece method would be
inordinately ungainly? I don't doubt such constants exist, but I would be
surprised by the real-world examples of them arising in a variable in some
address ranges but not others. DW_AT_const_value already suffices for
large constants when a location list is not required.
I am not especially against a block-constant specialty location expression.
(I'm not convinced it's worthwhile to have a plethora of special-case
short-length operations as well as the general ULEB128 block form, it's
only an extra byte or two.) It seemed like a good opportunity to kill two
birds with one stone (three if you count DW_CFA_val_expression). My guess
is that rematerializable values are a more common real-world scenario that
would be useful to support than large constants in location subsets are a
common real-world scenario that matters to support gracefully (vs with some
discomfort and suboptimality using DW_OP_piece).
Thanks,
Roland
More information about the Dwarf-discuss
mailing list