aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2003-05-14 22:45:41 +0000
committerKevin Buettner <kevinb@redhat.com>2003-05-14 22:45:41 +0000
commit18ec983167982fde21392b3be307aaf15fd12c0d (patch)
treebcd64f4457569ffe7cadc3ad94770e92cff57ecf
parentcd443671149f353d7b87c1a107d924adbf67712a (diff)
downloadgdb-18ec983167982fde21392b3be307aaf15fd12c0d.zip
gdb-18ec983167982fde21392b3be307aaf15fd12c0d.tar.gz
gdb-18ec983167982fde21392b3be307aaf15fd12c0d.tar.bz2
* 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.
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/dwarf2expr.c26
2 files changed, 24 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8f9f0b0..a62ecd3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 35e76f3..410cd54 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -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;