This is the mail archive of the
dwarf2@corp.sgi.com
mailing list for the dwarf2 project.
DW_OP_piece and optimisations
- To: DWARF2 at corp dot sgi dot com
- Subject: DW_OP_piece and optimisations
- From: "Keith.Walker" <Keith dot Walker at arm dot com>
- Date: Fri, 26 Jan 2001 11:57:08 +0000
- Reply-To: "Keith.Walker" <Keith dot Walker at arm dot com>
The following is a query/observation of a DW_OP_piece operator being
applied to an object which has been partially optimized away.
Take the following piece of code:
struct s {
int a;
int b;
int c;
};
int func (void)
{
struct s S;
S.b = 1;
return S.b;
}
Suppose that the compiler has optimized this to put "S.b" into a register
and optimized away "S.a" and "S.c".
Would it be valid to use the DW_OP_piece operator with no preceding DWARF
expression to indicate those parts of "S" which have been optimized away?
So, for example, "S"'s location might be described by the location expression:
{
DW_OP_piece 4 ! S.a optimized out
DW_OP_reg0 DW_OP_piece 4 ! S.b in R0
DW_OP_piece 4 ! S.c optimized out
}
As far as I can see the relevant quotes from the Standard are:
Section 2.5.2, Location Expressions
"An expression with zero operations is used to denote an object
that is present in the source code but not present in the object
code (perhaps because of optimization)."
Section 2.4.1.6,Special Operations
"DW_OP_piece takes a single argument, which is an unsigned
LEB128 number. The number describes the size in bytes of the
piece of the object referenced by the DWARF expression whose
result is at the top of the stack."
Is this a valid interpretation of the Standard to describe this situation
or have I combined 2 quotes which are not intended to be combined?
Is there a better way to describe this?
Or is there a requirement for a special DW_OP_ operation to describe an
"optimized out" location?
I would be interested in your comments.
Keith
Keith Walker keith.walker@arm.com Tel:+44 (1628) 427732