Split out eval_op_var_entry_value
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
This splits OP_VAR_ENTRY_VALUE into a new function for future use.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* eval.c (eval_op_var_entry_value): New function.
(evaluate_subexp_standard): Use it.

gdb/ChangeLog
gdb/eval.c

index a6dbb7ee633829fc466d11cc873f0319a8bd203e..94af28072a565ddb4d562ab99433cbf8db461c96 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * eval.c (eval_op_var_entry_value): New function.
+       (evaluate_subexp_standard): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * eval.c (eval_op_scope): New function.
index 11a705327f289efb9fc6234932ac41da11b91960..b40125271556dd11dba420e329f92a89a46c518f 100644 (file)
@@ -1198,6 +1198,26 @@ eval_op_scope (struct type *expect_type, struct expression *exp,
   return arg1;
 }
 
+/* Helper function that implements the body of OP_VAR_ENTRY_VALUE.  */
+
+static struct value *
+eval_op_var_entry_value (struct type *expect_type, struct expression *exp,
+                        enum noside noside, symbol *sym)
+{
+  if (noside == EVAL_SKIP)
+    return eval_skip_value (exp);
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
+    return value_zero (SYMBOL_TYPE (sym), not_lval);
+
+  if (SYMBOL_COMPUTED_OPS (sym) == NULL
+      || SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL)
+    error (_("Symbol \"%s\" does not have any specific entry value"),
+          sym->print_name ());
+
+  struct frame_info *frame = get_selected_frame (NULL);
+  return SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry (sym, frame);
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
                          struct expression *exp, int *pos,
@@ -1273,23 +1293,11 @@ evaluate_subexp_standard (struct type *expect_type,
 
     case OP_VAR_ENTRY_VALUE:
       (*pos) += 2;
-      if (noside == EVAL_SKIP)
-       return eval_skip_value (exp);
 
       {
        struct symbol *sym = exp->elts[pc + 1].symbol;
-       struct frame_info *frame;
-
-       if (noside == EVAL_AVOID_SIDE_EFFECTS)
-         return value_zero (SYMBOL_TYPE (sym), not_lval);
-
-       if (SYMBOL_COMPUTED_OPS (sym) == NULL
-           || SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL)
-         error (_("Symbol \"%s\" does not have any specific entry value"),
-                sym->print_name ());
 
-       frame = get_selected_frame (NULL);
-       return SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry (sym, frame);
+       return eval_op_var_entry_value (expect_type, exp, noside, sym);
       }
 
     case OP_FUNC_STATIC_VAR: