[Dwarf-Discuss] DW_CFA_def_cfa_expression vs DW_CFA_def_cfa_register

Michael Eager eager@eagercon.com
Fri Apr 23 04:39:37 GMT 2010


Roland McGrath wrote:
> If an FDE contains:
> 
> 	...
> 	DW_CFA_def_cfa REGNO OFFSET
> 	...
> 	DW_def_cfa_expression BLOCK
> 	...
> 	DW_def_cfa_register REGNO
> 	...
> 
> then what is the offset value in force after DW_def_cfa_register?
> (The same question applies to the register number in force for
> a DW_CFA_def_cfa_offset{,_sf} after DW_def_cfa_expression.)
> 
> It seems to be implied that "current CFA state" is not either an expression
> block OR a (REGNO, OFFSET) pair, but rather is a (REGNO, OFFSET) pair AND
> an optional expression block that supercedes it.  DW_CFA_def_cfa* ops other
> than DW_CFA_def_cfa_expression remove the expression block from the current
> state, so the hidden REGNO and/or OFFSET (if not just replaced) again prevail.
> 
> Is that how it's intended to be read?  If so, it seems sufficiently
> nonobvious to merit some mention in the text for DW_CFA_def_cfa_expression.
> If not, and the case above is intended to reset OFFSET to zero or something
> like that, then the standard as written really doesn't say that at all and
> is incorrect.

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.

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.

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




More information about the Dwarf-discuss mailing list