[Dwarf-Discuss] Semantics of DW_OP_(b)reg
Mon Mar 20 16:59:21 GMT 2017
On Mon, Mar 20, 2017 at 09:23:36AM -0700, Adrian Prantl wrote:
> > On Mar 17, 2017, at 2:49 PM, David Anderson <davea42 at linuxmail.org> wrote:
> > On 03/17/2017 01:18 PM, Adrian Prantl wrote:
> >> Are these two expressions equivalent?
> >> 1. DW_OP_breg1 0 DW_OP_breg2 0 DW_OP_plus DW_OP_stack_value
> >> 2. DW_OP_reg1 DW_OP_reg2 DW_OP_plus DW_OP_stack_value
> > In DW4 (DW5 has same text)
> > These operations name a register location. To fetch the contents of a
> > register, it is necessary to
> > use one of the register based addressing operations, such as DW_OP_bregx
> > (see Section
> > 126.96.36.199).
> > To me that means that 2. above cannot work.
> Thanks for the clarification!
> To summarize in my own words: in DWARF 4+, a DW_OP_reg(x) may only appear in a register location description, which implies that it must either be the only operation in an expression, or embedded inside an expression that takes a register location description as an argument, such as DW_OP_entry_value.
> In particular, this means that these two location descriptions are equivalent:
> 1. DW_OP_breg1 0 DW_OP_stack_value ; implicit location description
> 2. DW_OP_reg1 ; register location description
They are not equivalent. The former is, the value of this and this can be
computed by adding 0 to the value of register 1, the latter the value lives
in the register 1. To the debug info consumer, 1. is something you can't
really modify if you e.g. want to change the value of some variable, while
2. can be modified.
> This is illegal:
> 1. DW_OP_reg1 DW_OP_deref
> And these are also equivalent:
> 1. DW_OP_breg1 0 DW_OP_deref DW_OP_stack_value ; implicit loc. desc.
> 2. DW_OP_breg1 0 ; memory loc. desc.
Again, same difference as above, the former can't be modified, the latter
More information about the Dwarf-discuss