+2003-05-14 Kevin Buettner <kevinb@redhat.com>
+
+ * dwarf2expr.c (new_dwarf_expr_context): Set ``stack_len'' to
+ correctly indicate an empty stack and ``stack_allocated'' to the
+ indicate the number of elements initially allocated.
+ (dwarf_expr_grow_stack): Simplify method for computing new
+ stack size. Don't loop infinitely if ``stack_len'' is zero.
+ (execute_stack_op): Move ``ctx->in_reg'' initialization
+ out of loop. Allow DW_OP_reg0 ... DW_OP_reg31 and DW_OP_regx to
+ be used in conjuction with DW_OP_piece. Revise error message
+ accordingly.
+
2003-05-14 Theodore A. Roth <troth@openavr.org>
* MAINTAINERS: Update my email address.
{
struct dwarf_expr_context *retval;
retval = xcalloc (1, sizeof (struct dwarf_expr_context));
- retval->stack_len = 10;
- retval->stack = xmalloc (10 * sizeof (CORE_ADDR));
+ retval->stack_len = 0;
+ retval->stack_allocated = 10;
+ retval->stack = xmalloc (retval->stack_allocated * sizeof (CORE_ADDR));
return retval;
}
{
if (ctx->stack_len + need > ctx->stack_allocated)
{
- size_t templen = ctx->stack_len * 2;
- while (templen < (ctx->stack_len + need))
- templen *= 2;
+ size_t newlen = ctx->stack_len + need + 10;
ctx->stack = xrealloc (ctx->stack,
- templen * sizeof (CORE_ADDR));
- ctx->stack_allocated = templen;
+ newlen * sizeof (CORE_ADDR));
+ ctx->stack_allocated = newlen;
}
}
execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
unsigned char *op_end)
{
+ ctx->in_reg = 0;
+
while (op_ptr < op_end)
{
enum dwarf_location_atom op = *op_ptr++;
LONGEST offset;
int bytes_read;
- ctx->in_reg = 0;
-
switch (op)
{
case DW_OP_lit0:
case DW_OP_reg29:
case DW_OP_reg30:
case DW_OP_reg31:
- /* NOTE: in the presence of DW_OP_piece this check is incorrect. */
- if (op_ptr != op_end)
+ if (op_ptr != op_end && *op_ptr != DW_OP_piece)
error ("DWARF-2 expression error: DW_OP_reg operations must be "
- "used alone.");
+ "used either alone or in conjuction with DW_OP_piece.");
result = op - DW_OP_reg0;
ctx->in_reg = 1;
case DW_OP_regx:
op_ptr = read_uleb128 (op_ptr, op_end, ®);
- if (op_ptr != op_end)
+ if (op_ptr != op_end && *op_ptr != DW_OP_piece)
error ("DWARF-2 expression error: DW_OP_reg operations must be "
- "used alone.");
+ "used either alone or in conjuction with DW_OP_piece.");
result = reg;
ctx->in_reg = 1;