Hi Roland,
On Mon, 2009-07-20 at 17:55 -0700, Roland McGrath wrote:
Now it perhaps makes sense to have dwarf_frame_register always yield
a
"simple location description". That is, either a DWARF expression or
register expression indicating an address, or one of those two followed
by DW_OP_stack_value, indicating a read-only computable value.
When would you need a register expression followed by DW_OP_stack_value?
The CFI "undefined" state is represented naturally by an
empty location
description. It means the same thing: you can't get it because it was
optimized out.
The corner that remains nonobvious is "same_value". This could be
represented for practical purposes just as a register location
expression {DW_OP_regx,regno} for a call on regno. But this bothers me
a little because then we hide one bit (literally) of information, a
distinction that can exist in the CFI (even if the semantics of making
that distinction are not clear). i.e., the CFI could give a register
rule that says it's in the same register, or even a DW_CFA_expression
giving DW_OP_reg* with that register number (though technically that's
not kosher since it's only a DWARF expression, not itself a location
description). That says "I'm saving it there" vs saying "I
haven't
touched it", which is a distinction I can understand in the abstract,
though it's hard to see what it actually means. But anyway, that amount
of vagueness gives me the inclination to represent "same_value" more
distinctly in the API with something that valid CFI could never encode,
so it's unambiguous. (I'm still thinking of "in-band" encoding
(i.e. just some choice of Dwarf_Op sequence), so "could never" is not
really true unless we check the expressions for it.)
I must admit to not really see when you need the information "it got
changed, but I put it back as is" versus "unchanged and in same place".
Off hand my best thoughts are to yield a one-op expression of just
either DW_OP_nop or DW_OP_GNU_uninit. Neither of these really means
something exactly analogous to this, but moreover neither of them can
validly appear alone as the sole op in a location description. Hmm.
Maybe DW_OP_stack_value itself is a good choice for the same_value
representation!
I couldn't find a definition for DW_OP_GNU_uninit. What does it express?
So it would be:
extern int dwarf_frame_register (Dwarf_Frame *frame, int regno,
Dwarf_Op ops_mem[3], Dwarf_Op **ops)
__nonnull_attribute__ (3, 4);
Return value -1 for errors, or number of operations at *NOPS.
An op sequence >1 long might end with DW_OP_stack_value,
with the same meaning as in a real location description.
0 means empty location description, i.e. DW_CFA_undefined.
An op sequence of just DW_OP_stack_value alone is a special case
meaning DW_CFA_same_value.
I admit to liking the return value 0 with *NOPS zero means CFI says the
caller's REGNO is same_value" here of the original better than using
DW_CFA_same_value as special marker.
Cheers,
Mark