Browse Source

gdb:

* value.h (value_non_lval): Declare.
	* value.c (value_non_lval): New function.
	* eval.c (evaluate_subexp_standard) <UNOP_POSTINCREMENT,
	UNOP_POSTDECREMENT>: Call value_non_lval to ensure to return a
	non-lvalue.

gdb/testsuite:
	* gdb.base/exprs.exp: Add tests for pre-/post- in-/decrement operators.
binutils-2_21-branch
Ken Werner 16 years ago
parent
commit
c37f7098e9
  1. 8
      gdb/ChangeLog
  2. 8
      gdb/eval.c
  3. 4
      gdb/testsuite/ChangeLog
  4. 9
      gdb/testsuite/gdb.base/exprs.exp
  5. 20
      gdb/value.c
  6. 2
      gdb/value.h

8
gdb/ChangeLog

@ -1,3 +1,11 @@
2010-11-03 Ken Werner <ken.werner@de.ibm.com>
* value.h (value_non_lval): Declare.
* value.c (value_non_lval): New function.
* eval.c (evaluate_subexp_standard) <UNOP_POSTINCREMENT,
UNOP_POSTDECREMENT>: Call value_non_lval to ensure to return a
non-lvalue.
2010-11-02 Doug Evans <dje@google.com>
New python module gdb.printing, and new commands info pretty-printer,

8
gdb/eval.c

@ -2782,6 +2782,8 @@ evaluate_subexp_standard (struct type *expect_type,
}
else
{
arg3 = value_non_lval (arg1);
if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
arg2 = value_ptradd (arg1, 1);
else
@ -2794,7 +2796,7 @@ evaluate_subexp_standard (struct type *expect_type,
}
value_assign (arg1, arg2);
return arg1;
return arg3;
}
case UNOP_POSTDECREMENT:
@ -2807,6 +2809,8 @@ evaluate_subexp_standard (struct type *expect_type,
}
else
{
arg3 = value_non_lval (arg1);
if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
arg2 = value_ptradd (arg1, -1);
else
@ -2819,7 +2823,7 @@ evaluate_subexp_standard (struct type *expect_type,
}
value_assign (arg1, arg2);
return arg1;
return arg3;
}
case OP_THIS:

4
gdb/testsuite/ChangeLog

@ -1,3 +1,7 @@
2010-11-03 Ken Werner <ken.werner@de.ibm.com>
* gdb.base/exprs.exp: Add tests for pre-/post- in-/decrement operators.
2010-11-02 Doug Evans <dje@google.com>
* gdb.python/py-pp-maint.c: New file.

9
gdb/testsuite/gdb.base/exprs.exp

@ -253,3 +253,12 @@ gdb_test "set output-radix 8" ".*"
test_expr "print red" "\\$\[0-9\]* = red"
test_expr "print/d red" "\\$\[0-9\]* = 0"
gdb_test "set output-radix 10" ".*"
# Pre-/post in-/decrement tests.
gdb_test "set variable v_int = 1" ""
gdb_test "print v_int++" "\\$\[0-9\]* = 1"
gdb_test "print ++v_int" "\\$\[0-9\]* = 3"
gdb_test "print v_int--" "\\$\[0-9\]* = 3"
gdb_test "print --v_int" "\\$\[0-9\]* = 1"
gdb_test "print v_int++ = 5" "Left operand of assignment is not an lvalue."
gdb_test "print v_int-- = 5" "Left operand of assignment is not an lvalue."

20
gdb/value.c

@ -826,6 +826,26 @@ value_copy (struct value *arg)
return val;
}
/* Return a version of ARG that is non-lvalue. */
struct value *
value_non_lval (struct value *arg)
{
if (VALUE_LVAL (arg) != not_lval)
{
struct type *enc_type = value_enclosing_type (arg);
struct value *val = allocate_value (enc_type);
memcpy (value_contents_all_raw (val), value_contents_all (arg),
TYPE_LENGTH (enc_type));
val->type = arg->type;
set_value_embedded_offset (val, value_embedded_offset (arg));
set_value_pointed_to_offset (val, value_pointed_to_offset (arg));
return val;
}
return arg;
}
void
set_value_component_location (struct value *component,
const struct value *whole)

2
gdb/value.h

@ -711,6 +711,8 @@ extern void preserve_values (struct objfile *);
extern struct value *value_copy (struct value *);
extern struct value *value_non_lval (struct value *);
extern void preserve_one_value (struct value *, struct objfile *, htab_t);
/* From valops.c */

Loading…
Cancel
Save