[Dwarf-discuss] Re: Interpretation of FBREG: implied deref of frame_base?
David Anderson
davea
Mon Apr 18 20:55:24 GMT 2005
On Mon, Apr 18, 2005 at 02:38:16PM -0500, jeff nelson wrote:
> I'm a debugger developer on OpenVMS. One of the compilers I support is
> emitting a DW_AT_base_frame attribute that contains a single operator,
> DW_OP_regx. I believe this is incorrect, and that the compiler should
> emit a DW_OP_bregx instead. The difference is that the regx operator
> "names" the register whereas bregx resolves to the register value.
Daniel Jacobowitz writes:
>My interpretation is that the compiler is correct. The value of
>DW_AT_frame_base is a location description; DW_OP_reg1 means "the frame
>base is stored in reg1", and DW_OP_breg1 0 means "the address of the
>frame base is value_of_reg1 + 0". If it's a register, "dereference" it
>automatically.
Not the first time DW_OP_reg1 (for example) has confused everyone
(me included).
While I agree the document is unclear, I lean toward the
interpretation that Daniel provides. In this framework
DW_AT_frame_base DW_OP_reg1
and
DW_AT_frame_base DW_OP_breg1 0
with a location expression of
DW_OP_fbreg -20
both mean the same thing:
get the value of reg 1 (dereference it, that is) and add -20
to get the address of the local variable.
(DW_OP_regx 1
has the same fuzzy issues as DW_OP_reg1.)
The alternative is to say (AFAICT) that "DW_AT_frame_base DW_OP_reg1"
has no meaning.
Now for a normal location expression it *is* impossible
to add things like this:
DW_OP_PLUS DW_OP_reg3 DW_OP_lit20 // illegal
There does not seem to be a way to say 'the value is the contents
of reg3 plus the value 20'. Because it's a location expression
and this illegal use is not computing a location it is
computing a value (illegally).
So normally DW_OP_reg3 must appear alone and must not be combined
with anything (and for DW_OP_regx 3 the same)
Since DW_OP_fbreg -20 is unambiguously computing a location
(not a value) I suspect Daniel is right, and an automatic dereference
is in order.
My $0.02
David Anderson
More information about the Dwarf-discuss
mailing list