I have a couple of questions regarding the semantics of DW_OP_reg(x) and DW_OP_breg(x). LLVM's DWARF expression generator (which was written with DWARF 2 in mind) treats DW_OP_breg as synonymous with DW_OP_reg DW_OP_deref, but I get the impression that that may not be correct in DWARF 4+. However, before making any changes to LLVM, I wanted to make sure that I actually understand the semantics correctly.
My understanding is that the presence of DW_OP_stack_value (or DW_OP_implicit_value) is what distinguishes a memory location description (2.6.1.1.2; top of stack is the address of our value) from an implicit location description (2.6.1.1.4; top of stack is the value itself). A location description with only a DW_OP_reg is a register location description (2.6.1.1.3 the value is the contents of the register). >From reading Section 2.6.1.1, it sounds as if DW_OP_reg should only be used >when it is the only operation in an expression. The non-normative text in >2.6.1.1.4 seems to confirm that, but the language is vague and avoids making >any reference to the DWARF expression stack: > 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 What is the effect of DW_OP_reg on the DWARF expression stack? Is it legal to use DW_OP_reg in an implicit or memory location description? I'm asking because it looks like the semantics of DW_OP_reg in terms of the stack are never described, but it is used in an example in Appendix D as part of an implicit location description (DW_OP_entry_value 1 DW_OP_reg1 DW_OP_stack_value). Assuming that the example is correct, and that it is legal to use DW_OP_reg inside a memory or implicit location description, below are a couple of pointed questions: 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 Are these two expressions equivalent? 1. DW_OP_reg1 ; is this a register location? 2. DW_OP_breg1 0 ; is this a memory location? Are these two expressions equivalent? 1. DW_OP_reg1 DW_OP_deref ; is this a memory location? 2. DW_OP_breg1 0 Are these two expressions equivalent? 1. DW_OP_reg1 2. DW_OP_breg1 0 DW_OP_stack_value Are these two expressions equivalent? 1. DW_OP_reg1 DW_OP_deref DW_OP_stack_value 2. DW_OP_breg1 0 Are these two expressions equivalent? 3. DW_OP_breg1 0 DW_OP_deref DW_OP_stack_value 2. DW_OP_breg1 0 thanks, adrian _______________________________________________ Dwarf-Discuss mailing list [email protected] http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
