* 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.
This commit is contained in:
Kevin Buettner 2003-05-14 22:45:41 +00:00
parent cd44367114
commit 18ec983167
2 changed files with 24 additions and 14 deletions

View file

@ -1,3 +1,15 @@
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.

View file

@ -39,8 +39,9 @@ new_dwarf_expr_context (void)
{
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;
}
@ -61,12 +62,10 @@ dwarf_expr_grow_stack (struct dwarf_expr_context *ctx, size_t need)
{
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;
}
}
@ -228,6 +227,8 @@ static void
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++;
@ -236,8 +237,6 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
LONGEST offset;
int bytes_read;
ctx->in_reg = 0;
switch (op)
{
case DW_OP_lit0:
@ -355,10 +354,9 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
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;
@ -367,9 +365,9 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
case DW_OP_regx:
op_ptr = read_uleb128 (op_ptr, op_end, &reg);
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;