aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2expr.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-01-20 18:06:16 +0000
committerTom Tromey <tromey@redhat.com>2010-01-20 18:06:16 +0000
commitb966cb8abe34be31fae6aed3e6e9c9cc4c8696b2 (patch)
tree135afbf396f2c436a793397cf797a05ecb695ed8 /gdb/dwarf2expr.c
parent5ac169d4b6e2d88c670298a3246fc2a5d8a94aa4 (diff)
downloadfsf-binutils-gdb-b966cb8abe34be31fae6aed3e6e9c9cc4c8696b2.zip
fsf-binutils-gdb-b966cb8abe34be31fae6aed3e6e9c9cc4c8696b2.tar.gz
fsf-binutils-gdb-b966cb8abe34be31fae6aed3e6e9c9cc4c8696b2.tar.bz2
gdb
PR backtrace/10770: * valarith.c (value_binop): Handle BINOP_GTR, BINOP_LEQ, and BINOP_GEQ. Handle BINOP_NOTEQUAL in the signed case. * dwarf2expr.c (new_dwarf_expr_context): Allocate dwarf_stack_values, not CORE_ADDRs. (execute_stack_op): Change DW_OP_div and comparison operators to use signed operands. gdb/testsuite PR backtrace/10770: * gdb.dwarf2/pr10770.exp: New file. * gdb.dwarf2/pr10770.c: New file. * gdb.dwarf2/Makefile.in (EXECUTABLES): Add pr10770.
Diffstat (limited to 'gdb/dwarf2expr.c')
-rw-r--r--gdb/dwarf2expr.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 5e27d38..ed21edf 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -44,7 +44,8 @@ new_dwarf_expr_context (void)
retval = xcalloc (1, sizeof (struct dwarf_expr_context));
retval->stack_len = 0;
retval->stack_allocated = 10;
- retval->stack = xmalloc (retval->stack_allocated * sizeof (CORE_ADDR));
+ retval->stack = xmalloc (retval->stack_allocated
+ * sizeof (struct dwarf_stack_value));
retval->num_pieces = 0;
retval->pieces = 0;
retval->max_recursion_depth = 0x100;
@@ -712,7 +713,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
the right width. */
CORE_ADDR first, second;
enum exp_opcode binop;
- struct value *val1, *val2;
+ struct value *val1 = NULL, *val2 = NULL;
struct type *stype, *utype;
second = dwarf_expr_fetch (ctx, 0);
@@ -723,8 +724,6 @@ execute_stack_op (struct dwarf_expr_context *ctx,
utype = unsigned_address_type (ctx->gdbarch, ctx->addr_size);
stype = signed_address_type (ctx->gdbarch, ctx->addr_size);
- val1 = value_from_longest (utype, first);
- val2 = value_from_longest (utype, second);
switch (op)
{
@@ -733,6 +732,8 @@ execute_stack_op (struct dwarf_expr_context *ctx,
break;
case DW_OP_div:
binop = BINOP_DIV;
+ val1 = value_from_longest (stype, first);
+ val2 = value_from_longest (stype, second);
break;
case DW_OP_minus:
binop = BINOP_SUB;
@@ -764,26 +765,45 @@ execute_stack_op (struct dwarf_expr_context *ctx,
break;
case DW_OP_le:
binop = BINOP_LEQ;
+ val1 = value_from_longest (stype, first);
+ val2 = value_from_longest (stype, second);
break;
case DW_OP_ge:
binop = BINOP_GEQ;
+ val1 = value_from_longest (stype, first);
+ val2 = value_from_longest (stype, second);
break;
case DW_OP_eq:
binop = BINOP_EQUAL;
+ val1 = value_from_longest (stype, first);
+ val2 = value_from_longest (stype, second);
break;
case DW_OP_lt:
binop = BINOP_LESS;
+ val1 = value_from_longest (stype, first);
+ val2 = value_from_longest (stype, second);
break;
case DW_OP_gt:
binop = BINOP_GTR;
+ val1 = value_from_longest (stype, first);
+ val2 = value_from_longest (stype, second);
break;
case DW_OP_ne:
binop = BINOP_NOTEQUAL;
+ val1 = value_from_longest (stype, first);
+ val2 = value_from_longest (stype, second);
break;
default:
internal_error (__FILE__, __LINE__,
_("Can't be reached."));
}
+
+ /* We use unsigned operands by default. */
+ if (val1 == NULL)
+ val1 = value_from_longest (utype, first);
+ if (val2 == NULL)
+ val2 = value_from_longest (utype, second);
+
result = value_as_long (value_binop (val1, val2, binop));
}
break;