[Dwarf-discuss] Interpretation of FBREG: implied deref of frame_base?

Jim Blandy jimb
Wed Apr 20 17:39:25 GMT 2005


> Recall that there are two independent expressions being evaluated: the
> DW_OP_fbreg itself, and the expression at DW_AT_frame_base.
> 
> If I understand correctly, those who suggest that an automatic deference
> should be performed are in effect saying that FBREG works like this:
> 
> 1. evaluate the DW_AT_frame_base expression
> 2. dereference the value from step 1
> 3. add the DW_OP_fbreg operand

Evaluating Dwarf location expressions can yield two different kinds of
results: addresses (e.g., DW_OP_fbreg 4), and registers (e.g.,
DW_OP_reg1).  They always have to be handled separately.  The GNU
tools just apply a reasonable interpretation to a result (a register
instead of an address) that is otherwise meaningless.

I see step 2 as more like coercing an lvalue to an rvalue in C: if the
DW_AT_frame_base expression leaves an address on the stack, that is
the frame base address.  If it results in a register, then that
register's value is the frame base address.  The "extra dereference"
only occurs when the expression produces a register name, and there's
no other meaningful interpretation of the result.

> One of the problems with this approach is that the compiler must
> construct a DW_AT_frame_base expression that yields the *address* of the
> value. While it's easy to see how this is done for registers, how about
> for a memory location? Now you need an address of an address. I believe
> this is an unreasonable interpretation.

Using the above conventions, there's no need to construct artificial
addresses for things you've computed.

> In my opinion, the FBREG operator works like this:
> 
> 1. evaluate the DW_AT_frame_base expression
> 2. add the DW_OP_fbreg operand
> 
> In other words, the evaluation of DW_AT_frame_base needs to return a
> usable value on its own, without any additional dereferencing. Ron
> Brender pointed out examples in the Dwarf spec that supports this
> interpretation therefore I'd like to believe this is what was originally
> intended.

There are existing compilers and debuggers in widespread use that
accept register names as DW_AT_frame_base results.  The current
convention is unambiguous.  It doesn't seem worthwhile breaking them.





More information about the Dwarf-discuss mailing list