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:58 -0700
commit9b1d8af6833dd32ebc03c6372f98c432101dcf92 (patch)
treec5ccbbb4e0850f756dbf9e7f7f07a7059b4969dd
parentc0df928969781cca1c270ed835407d0222cd1da7 (diff)
downloadbinutils-9b1d8af6833dd32ebc03c6372f98c432101dcf92.zip
binutils-9b1d8af6833dd32ebc03c6372f98c432101dcf92.tar.gz
binutils-9b1d8af6833dd32ebc03c6372f98c432101dcf92.tar.bz2
Split out eval_op_func_static_var
This splits OP_FUNC_STATIC_VAR into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_func_static_var): New function. (evaluate_subexp_standard): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c29
2 files changed, 24 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3e13478..a549ce0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * eval.c (eval_op_func_static_var): New function.
+ (evaluate_subexp_standard): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_var_msym_value): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/eval.c b/gdb/eval.c
index ee77122..c365943 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1234,6 +1234,23 @@ eval_op_var_msym_value (struct type *expect_type, struct expression *exp,
return val;
}
+/* Helper function that implements the body of OP_FUNC_STATIC_VAR. */
+
+static struct value *
+eval_op_func_static_var (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ value *func, const char *var)
+{
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ CORE_ADDR addr = value_address (func);
+ const block *blk = block_for_pc (addr);
+ struct block_symbol sym = lookup_symbol (var, blk, VAR_DOMAIN, NULL);
+ if (sym.symbol == NULL)
+ error (_("No symbol \"%s\" in specified context."), var);
+ return evaluate_var_value (noside, sym.block, sym.symbol);
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -1318,17 +1335,9 @@ evaluate_subexp_standard (struct type *expect_type,
{
value *func = evaluate_subexp_standard (NULL, exp, pos, noside);
- CORE_ADDR addr = value_address (func);
-
- const block *blk = block_for_pc (addr);
- const char *var = &exp->elts[pc + 2].string;
-
- struct block_symbol sym = lookup_symbol (var, blk, VAR_DOMAIN, NULL);
-
- if (sym.symbol == NULL)
- error (_("No symbol \"%s\" in specified context."), var);
- return evaluate_var_value (noside, sym.block, sym.symbol);
+ return eval_op_func_static_var (expect_type, exp, noside, func,
+ &exp->elts[pc + 2].string);
}
case OP_LAST: