Issue 181205.1: Clarify DW_OP_piece documentation for parts of values that are optimized out

Author: Greg Clayton
Champion: Adrian Prantl
Date submitted: 2018-12-05
Date revised: 2021-10-04
Date closed: 2021-11-01
Type: Clarification
Status: Accepted
DWARF Version: 6
Section 2.6.1.2, pg 42

After someone posted a bug on bugzilla for LLDB regarding LLDB not showing 
that parts of a value were optimized out (https://bugs.llvm.org/show_bug.cgi?id=39869), 
I read the documentation on DW_OP_piece for clarification on what should be done 
when part of a value is optimized out. As the comments in the bug show, there is a 
mention in the DWARF specification in "2.6.1.1.1 Empty Location Descriptions" that 
says something about an empty location means the value might be optimized out. 

People reading the spec must currently read this and be able to infer that a 
location like:
DW_OP_piece: 6; ...
Means that the value starts with 6 optimized out bytes. Also, these optimized out 
bytes could be in the middle of a DWARF expression. It might be nice to clarify 
usage of DW_OP_piece to specify that parts of the value are optimized out.

I currently assume that if you run into a DW_OP_piece and the expression stack is 
empty, then the bytes for the piece are optimized out. What would happen if there 
was something on the stack and you needed to specify that 4 bytes of a value were 
optimized out? 


COMMENT

The normative text currently is indeed missing an explanation for undefined 
values, they are only mentioned in an example in Appendix D1.3.

The last question is a misunderstanding: DW_OP_piece operates outside of the
 DWARF stack. It is not possible to leave values on the DWARF stack beyond a
 DW_OP_piece, because the DWARF stack does not exist outside of a (non-composite)
 location description.

PROPOSED CHANGE:

Add the following normative text to 2.6.1.2:

A composition operation that follows an empty location description indicates
 that the piece is undefined, for example because it has been optimized away.

--
2021-10-04:  Updated.
2021-11-01:  Accepted.