diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
commit | ea2d29f7bccc5221c5ad43e3a90464623b5ec807 (patch) | |
tree | 17502a9b657f65c2e9d1fc1a02f16be71dc0f773 | |
parent | 8c9b6e7689157423ae99f89f30791d70214ef87b (diff) | |
download | binutils-ea2d29f7bccc5221c5ad43e3a90464623b5ec807.zip binutils-ea2d29f7bccc5221c5ad43e3a90464623b5ec807.tar.gz binutils-ea2d29f7bccc5221c5ad43e3a90464623b5ec807.tar.bz2 |
Split out eval_op_scope
This splits OP_SCOPE into a new function for future use.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* eval.c (eval_op_scope): New function.
(evaluate_subexp_standard): Use it.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/eval.c | 27 |
2 files changed, 24 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b1436a1..a6dbb7e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey <tom@tromey.com> + + * eval.c (eval_op_scope): New function. + (evaluate_subexp_standard): Use it. + 2021-03-06 Chernov Sergey <klen_s@mail.ru> PR gdb/27528: @@ -1182,6 +1182,22 @@ is_integral_or_integral_reference (struct type *type) && is_integral_type (TYPE_TARGET_TYPE (type))); } +/* Helper function that implements the body of OP_SCOPE. */ + +static struct value * +eval_op_scope (struct type *expect_type, struct expression *exp, + enum noside noside, + struct type *type, const char *string) +{ + if (noside == EVAL_SKIP) + return eval_skip_value (exp); + struct value *arg1 = value_aggregate_elt (type, string, expect_type, + 0, noside); + if (arg1 == NULL) + error (_("There is no field named %s"), string); + return arg1; +} + struct value * evaluate_subexp_standard (struct type *expect_type, struct expression *exp, int *pos, @@ -1208,14 +1224,9 @@ evaluate_subexp_standard (struct type *expect_type, case OP_SCOPE: tem = longest_to_int (exp->elts[pc + 2].longconst); (*pos) += 4 + BYTES_TO_EXP_ELEM (tem + 1); - if (noside == EVAL_SKIP) - return eval_skip_value (exp); - arg1 = value_aggregate_elt (exp->elts[pc + 1].type, - &exp->elts[pc + 3].string, - expect_type, 0, noside); - if (arg1 == NULL) - error (_("There is no field named %s"), &exp->elts[pc + 3].string); - return arg1; + return eval_op_scope (expect_type, exp, noside, + exp->elts[pc + 1].type, + &exp->elts[pc + 3].string); case OP_LONG: (*pos) += 3; |