On Tue, Jul 07, 2020 at 09:26:58AM +0000, Tomar, Sourabh Singh wrote: > Thanks for clarifying this. I went through literature and other stuff > available, it describes operation and semantics. Unfortunately I wasn't > able to get to the actual DWARF Issue/proposal when it was proposed. > > One small doubt still remains. It seems(to me) that DW_OP_stack_value and > DW_OP_implicit_value both can be used to describe most optimized > location/value of a variable. Then representing/choosing appropriate > operation involves matter like space/compactness(just like GCC does) or > maybe other factors too ? > > I'm unable to come-up with an motivating example where > DW_OP_implicit_value is indispensable. Would you please, if possible, > share an example(test case or any specific situation) covering this.
I wasn't involved in DWARF standard when DW_OP_implicit_value has been added, but it was added in DWARF4, where the DWARF stack could only hold integers (and only up to the size of address). So, DW_OP_implicit_value was the only way to hold floating point constants, or integers larger than address, or other non-integral values. It is like using DW_AT_const_value, except DW_AT_const_value, except that DW_AT_const_value is for the case when a variable etc. has the same value at all spots, while DW_OP_implicit_value can be used in .debug_loc, you can say the object has this constant value at certain locations, and another one at others. DW_OP_stack_value is for the cases where the value is computable using the DWARF stack operations. Jakub