aboutsummaryrefslogtreecommitdiff
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:27:59 -0700
commit3e96c4fc0f4b286c96e6c95618c7f34293185308 (patch)
treef3f8263a86d65b95d0cf8789395a7afdcae5cded
parentf960a6176a3185a013db507c29d99d8c92eb21b9 (diff)
downloadbinutils-3e96c4fc0f4b286c96e6c95618c7f34293185308.zip
binutils-3e96c4fc0f4b286c96e6c95618c7f34293185308.tar.gz
binutils-3e96c4fc0f4b286c96e6c95618c7f34293185308.tar.bz2
Split out eval_op_structop_struct
This splits STRUCTOP_STRUCT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_structop_struct): New function. (evaluate_subexp_standard): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c25
2 files changed, 23 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b9b1c3f..f3cbdd0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * eval.c (eval_op_structop_struct): New function.
+ (evaluate_subexp_standard): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_ternop): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/eval.c b/gdb/eval.c
index afc79b2..753e914 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1338,6 +1338,22 @@ eval_op_ternop (struct type *expect_type, struct expression *exp,
return value_slice (array, lowbound, upperbound - lowbound + 1);
}
+/* A helper function for STRUCTOP_STRUCT. */
+
+static struct value *
+eval_op_structop_struct (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *arg1, const char *string)
+{
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ struct value *arg3 = value_struct_elt (&arg1, NULL, string,
+ NULL, "structure");
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3));
+ return arg3;
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -1929,13 +1945,8 @@ evaluate_subexp_standard (struct type *expect_type,
tem = longest_to_int (exp->elts[pc + 1].longconst);
(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- arg3 = value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
- NULL, "structure");
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3));
- return arg3;
+ return eval_op_structop_struct (expect_type, exp, noside, arg1,
+ &exp->elts[pc + 2].string);
case STRUCTOP_PTR:
tem = longest_to_int (exp->elts[pc + 1].longconst);