[Dwarf-Discuss] DW_CFA_def_cfa_expression vs DW_CFA_def_cfa_register

Roland McGrath roland at redhat.com
Thu Apr 22 22:30:35 PDT 2010


> There is nothing in the description of DW_CFA_* to suggest that there are
> any hidden values, a stack for CFA definitions, or that any previous register
> or offset values that are no longer valid are somehow reinstated.
> 
> Following DW_DEF_cfa_expression, there are no saved or hidden register
> or offset values.  There is simply an expression used to compute the CFA.

That's how I had read it before.  If that's the intent of the standard, I
think the wording for DW_CFA_def_cfa_* should be explicit about it.  That
is, say that DW_CFA_def_cfa_{register,offset,offset_sf} are invalid after
DW_CFA_def_expression (or at the initial state) without an intervening
DW_CFA_def_cfa.

> In your example, I would suggest that following a DW_DEF_cfa_expression,
> you use DW_CFA_def_cfa with a register and offset.  If you intend the
> offset to be zero, you should specify it explicitly.

I wasn't asking as a potential producer, but as a consumer.  The example I
gave was one GCC emitted.  Other consumers apparently don't have a problem
with this in practice.  Whether that was intended or is happenstance,
either in existing consumers or in GCC as the producer, is not clear to me.

For example, GDB's CFI processor does save the "hidden" register number
and/or offset value.  There is no comment about it I've seen, so it seems
as likely as anything that this is just happenstance of how it stores its
state.  My CFI processor used a union where GDB uses sibling struct members
(so loses the "hidden" state), and diagnosed such sequences as invalid.  So
my processor refused to work on an FDE that at least one other processor
did work on.

If the conclusion is that this is indeed invalid and GCC is buggy to emit
it, that is fine by me.


Thanks,
Roland



More information about the Dwarf-Discuss mailing list