aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:04 -0700
commit3aef2a07686a5cc2b359e07fd26e42ad77fffa25 (patch)
tree90a87f565495412cbc421c85bea0ffb1629da08b /gdb
parentacee94686be0601a096c5d6e09c531c41318a429 (diff)
downloadgdb-3aef2a07686a5cc2b359e07fd26e42ad77fffa25.zip
gdb-3aef2a07686a5cc2b359e07fd26e42ad77fffa25.tar.gz
gdb-3aef2a07686a5cc2b359e07fd26e42ad77fffa25.tar.bz2
Split out eval_op_memval
This splits UNOP_MEMVAL into a new function for future use. This new function is also used to hande UNOP_MEMVAL_TYPE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_memval): New function. (evaluate_subexp_standard): Use it.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c31
2 files changed, 23 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1bfac7e..7d348f3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * eval.c (eval_op_memval): New function.
+ (evaluate_subexp_standard): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_alignof): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/eval.c b/gdb/eval.c
index 729933f..86b61b4 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1894,6 +1894,21 @@ eval_op_alignof (struct type *expect_type, struct expression *exp,
return value_from_longest (size_type, align);
}
+/* A helper function for UNOP_MEMVAL. */
+
+static struct value *
+eval_op_memval (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *arg1, struct type *type)
+{
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value_zero (type, lval_memory);
+ else
+ return value_at_lazy (type, value_as_address (arg1));
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -2817,24 +2832,14 @@ evaluate_subexp_standard (struct type *expect_type,
case UNOP_MEMVAL:
(*pos) += 2;
arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (exp->elts[pc + 1].type, lval_memory);
- else
- return value_at_lazy (exp->elts[pc + 1].type,
- value_as_address (arg1));
+ return eval_op_memval (expect_type, exp, noside, arg1,
+ exp->elts[pc + 1].type);
case UNOP_MEMVAL_TYPE:
arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
type = value_type (arg1);
arg1 = evaluate_subexp (expect_type, exp, pos, noside);
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type, lval_memory);
- else
- return value_at_lazy (type, value_as_address (arg1));
+ return eval_op_memval (expect_type, exp, noside, arg1, type);
case UNOP_PREINCREMENT:
arg1 = evaluate_subexp (expect_type, exp, pos, noside);