[Dwarf-discuss] DW_OP_piece limits and assumptions

Todd Allen todd.allen
Thu Apr 28 10:19:14 GMT 2005


> 
> 1. Are there any limits to the size of the result returned by
> DW_OP_piece? There doesn't appear to be an explicit restriction, so I'm
> wondering if there ought to be one or not. There seem to be the
> following choices:
> 
> a) Limit the expression size to the size of an address, so that the
> Dwarf expression stack can be used to hold the result.
> 
> b) Let the expression be an arbitrary size, and either keep the result
> in a separate storage area, or permit the expression stack to hold an
> arbitrary-sized value. I think the latter is needed in case the
> intermediate result of DW_OP_piece is used by any subsequent Dwarf
> operator in the expression.
> 
> 
> 2. Are there any limits to the size of the operand? This is similar to
> the first question. If option (a) is selected above, then the size of
> the operand would have to be the size (in bytes) of an address. If (b)
> then the size can be unlimited.
> 
> 
> 3. There is an implied combining operation that occurs when a Dwarf
> expression contains two or more DW_OP_piece operators. I'd like to see
> this combining made explicit in the description of DW_OP_piece.
> 

Most of the operators specifically say that they push a value onto the stack.
Sometimes the note is at the start of the section.  That text is
conspicuously absent from DW_OP_piece.

So, DW_OP_fbreg 20 pushes the address fp+20 onto the stack.  (It says so at
the beginning of 2.4.1.2.)  It's just the address (i.e. location) being
pushed, and not the value.  So its size being an address is just fine.  

But DW_OP_piece pops a value from the stack to get a location (address or
register), and doesn't push anything.  So, you could think of it storing to a
separate area, if you like, but how the DW_OP_piece's are interpreted and
used is entirely up to the consumer.  Because the DW_OP_piece doesn't push
anything onto the stack, I don't see how it could be used in further
operations.

If you did have an address that required combining to obtain, and you need to
do something further with it, like dereference it, I expect you could do it
with the standard shifty/masky operators.  Something like this:

   DW_OP_breg1            
   DW_OP_lit16            
   DW_OP_shl              
   DW_OP_breg2            
   DW_OP_constu 255       
   DW_OP_and              
   WD_OP_plus             
   DW_OP_deref            

So, answers to specific questions:

   1) b) It allows arbitrary size, and technically stores nowhere, but a
         customer can think of it as storing to some internal representation
         not described by Dwarf.
   2) There are no limits to the size of the operand.  The value popped from
      the stack is an address and has the size of an address.  The operand
      that's part of the DW_OP_piece is the size of the piece of the value,
      and has no particular limit.
   3) I don't see a need for this, since nothing ever gets pushed to the
      stack anyway.

And a further justification for not limiting the size of an object described
with DW_OP_piece's is one of the most common uses: describing values of type
"long long", where such values don't fit in a single register.  We must be
able to use two or more DW_OP_piece's to describe the locations where the
various pieces are.  And naturally, the resultant description is for an
object which is larger than an address.

-- 
Todd Allen
Concurrent Computer Corporation




More information about the Dwarf-discuss mailing list