[Dwarf-Discuss] Semantics of DW_OP_(b)reg
Adrian Prantl
aprantl@apple.com
Mon Mar 20 16:07:31 GMT 2017
> On Mar 17, 2017, at 3:26 PM, David Anderson <davea42 at linuxmail.org> wrote:
>
> On 03/17/2017 02:54 PM, Adrian Prantl wrote:
>> Would you say that the example in Appendix D, pg 291, line 23
>> DW_OP_entry_value 1 DW_OP_reg1 DW_OP_stack_value
>> is incorrect, because DW_OP_ref is not allowed outside of a register location description?
>
> DW5 2.5.1.7:
>
> DW_OP_entry_value
> The DW_OP_entry_value operation pushes the value that the described
> location held upon entering the current subprogram. It has two operands: an
> unsigned LEB128 length, followed by a block containing a DWARF
> expression or a register location description (see Section 2.6.1.1.3 on
> page 39).
> The length operand specifies the length in bytes of the block. If the block
> contains a DWARF expression, the DWARF expression is evaluated as if it
> had been evaluated upon entering the current subprogram. The DWARF
> expression assumes no values are present on the DWARF stack initially and
> results in exactly one value being pushed on the DWARF stack when
> completed. If the block contains a register location description,
> DW_OP_entry_value pushes the value that register had upon entering the
> current subprogram.
>
>
>
> Now this is interesting wording. Because it says 'described location'.
> I think there is a strong case for arguing that a register name does
> describe a 'thing' that held a value. And it says 'register location
> description' which is precisely 2.6.1.1.3 which reaffirms that
> idea. .
>
> DW_OP_entry_value 1 DW_OP_reg1
> pushes a value on the stack
> and if was handed a register name it must find the contents
> of that register and push it.
>
> DW_OP_stack_value then notifies (the debugger) that
> the object value is on the stack (it does not pop or push anything).
>
> So the example does seem (to me) to be correct DWARF.
> Quite a special case!
I see. It is legal because of the special wording in 2.5.1.7 that allows a register location description to be the argument of DW_OP_entry_value.
-- adrian
>
> DavidA.
>
More information about the Dwarf-discuss
mailing list