[Dwarf-Discuss] Semantics of DW_OP_(b)reg

David Anderson davea42@linuxmail.org
Fri Mar 17 22:26:01 GMT 2017


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!

DavidA.




More information about the Dwarf-discuss mailing list