From 18a46dbee88ecb499c299673eb50a4d9cdaaefaa Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 27 Jul 2011 19:31:30 +0000 Subject: [PATCH] gdb/ 2011-07-27 Jan Kratochvil Pedro Alves * eval.c (evaluate_subexp_standard): Remove not_lval from all calls of value_one. * valops.c (value_one): Remove parameter lv. Do not pass it to itself. Assert the result kind. * value.h (value_one): Remove parameter lv. --- gdb/ChangeLog | 9 +++++++++ gdb/eval.c | 10 +++++----- gdb/valops.c | 10 ++++++---- gdb/value.h | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 27b5a33..1320db8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,4 +1,13 @@ 2011-07-27 Jan Kratochvil + Pedro Alves + + * eval.c (evaluate_subexp_standard): Remove not_lval from all calls of + value_one. + * valops.c (value_one): Remove parameter lv. Do not pass it to itself. + Assert the result kind. + * value.h (value_one): Remove parameter lv. + +2011-07-27 Jan Kratochvil Fix crash on lval_computed values. * valops.c (value_zero): Use not_lval for lval_computed. diff --git a/gdb/eval.c b/gdb/eval.c index 57a871f..c1c0280 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2198,7 +2198,7 @@ evaluate_subexp_standard (struct type *expect_type, { struct value *v_one, *retval; - v_one = value_one (value_type (arg2), not_lval); + v_one = value_one (value_type (arg2)); binop_promote (exp->language_defn, exp->gdbarch, &arg1, &v_one); retval = value_binop (arg1, v_one, op); return retval; @@ -2742,7 +2742,7 @@ evaluate_subexp_standard (struct type *expect_type, { struct value *tmp = arg1; - arg2 = value_one (value_type (arg1), not_lval); + arg2 = value_one (value_type (arg1)); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_ADD); } @@ -2766,7 +2766,7 @@ evaluate_subexp_standard (struct type *expect_type, { struct value *tmp = arg1; - arg2 = value_one (value_type (arg1), not_lval); + arg2 = value_one (value_type (arg1)); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_SUB); } @@ -2792,7 +2792,7 @@ evaluate_subexp_standard (struct type *expect_type, { struct value *tmp = arg1; - arg2 = value_one (value_type (arg1), not_lval); + arg2 = value_one (value_type (arg1)); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_ADD); } @@ -2819,7 +2819,7 @@ evaluate_subexp_standard (struct type *expect_type, { struct value *tmp = arg1; - arg2 = value_one (value_type (arg1), not_lval); + arg2 = value_one (value_type (arg1)); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_SUB); } diff --git a/gdb/valops.c b/gdb/valops.c index ee05d73..cd40c22 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -864,10 +864,10 @@ value_zero (struct type *type, enum lval_type lv) return val; } -/* Create a value of numeric type TYPE that is one, and return it. */ +/* Create a not_lval value of numeric type TYPE that is one, and return it. */ struct value * -value_one (struct type *type, enum lval_type lv) +value_one (struct type *type) { struct type *type1 = check_typedef (type); struct value *val; @@ -901,7 +901,7 @@ value_one (struct type *type, enum lval_type lv) val = allocate_value (type); for (i = 0; i < high_bound - low_bound + 1; i++) { - tmp = value_one (eltype, lv); + tmp = value_one (eltype); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), value_contents_all (tmp), TYPE_LENGTH (eltype)); } @@ -911,7 +911,9 @@ value_one (struct type *type, enum lval_type lv) error (_("Not a numeric type.")); } - VALUE_LVAL (val) = lv; + /* value_one result is never used for assignments to. */ + gdb_assert (VALUE_LVAL (val) == not_lval); + return val; } diff --git a/gdb/value.h b/gdb/value.h index 3bcd839..960384e 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -615,7 +615,7 @@ extern struct value *value_dynamic_cast (struct type *type, struct value *arg); extern struct value *value_zero (struct type *type, enum lval_type lv); -extern struct value *value_one (struct type *type, enum lval_type lv); +extern struct value *value_one (struct type *type); extern struct value *value_repeat (struct value *arg1, int count); -- 2.7.4