Rename fprintf_symbol_filtered
[binutils-gdb.git] / gdb / eval.c
index 3ea814f067766f1bfaa0055889401b71d2898c54..1211930a377c712a239ff70a25f4029c02540dc3 100644 (file)
@@ -1,6 +1,6 @@
 /* Evaluate expressions for GDB.
 
-   Copyright (C) 1986-2021 Free Software Foundation, Inc.
+   Copyright (C) 1986-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "regcache.h"
 #include "user-regs.h"
 #include "valprint.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
 #include "objfiles.h"
 #include "typeprint.h"
 #include <ctype.h>
 #include "expop.h"
 #include "c-exp.h"
+#include "inferior.h"
 
 \f
 /* Parse the string EXP as a C expression, evaluate it,
@@ -92,7 +93,7 @@ struct value *
 expression::evaluate (struct type *expect_type, enum noside noside)
 {
   gdb::optional<enable_thread_stack_temporaries> stack_temporaries;
-  if (target_has_execution ()
+  if (target_has_execution () && inferior_ptid != null_ptid
       && language_defn->la_language == language_cplus
       && !thread_stack_temporaries_enabled_p (inferior_thread ()))
     stack_temporaries.emplace (inferior_thread ());
@@ -280,7 +281,7 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch,
     return;
 
   if (is_fixed_point_type (type1) || is_fixed_point_type (type2))
-        return;
+    return;
 
   if (type1->code () == TYPE_CODE_DECFLOAT
       || type2->code () == TYPE_CODE_DECFLOAT)
@@ -563,7 +564,7 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var)
       if (noside != EVAL_AVOID_SIDE_EFFECTS)
        throw;
 
-      ret = value_zero (SYMBOL_TYPE (var), not_lval);
+      ret = value_zero (var->type (), not_lval);
     }
 
   return ret;
@@ -578,10 +579,10 @@ var_value_operation::evaluate (struct type *expect_type,
                               struct expression *exp,
                               enum noside noside)
 {
-  symbol *var = std::get<0> (m_storage);
-  if (SYMBOL_TYPE (var)->code () == TYPE_CODE_ERROR)
+  symbol *var = std::get<0> (m_storage).symbol;
+  if (var->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (var->print_name ());
-  return evaluate_var_value (noside, std::get<1> (m_storage), var);
+  return evaluate_var_value (noside, std::get<0> (m_storage).block, var);
 }
 
 } /* namespace expr */
@@ -601,14 +602,6 @@ evaluate_var_msym_value (enum noside noside,
     return value_at_lazy (the_type, address);
 }
 
-/* Helper for returning a value when handling EVAL_SKIP.  */
-
-value *
-eval_skip_value (expression *exp)
-{
-  return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
-}
-
 /* See expression.h.  */
 
 value *
@@ -695,8 +688,16 @@ operation::evaluate_funcall (struct type *expect_type,
   std::vector<value *> vals (args.size ());
 
   value *callee = evaluate_with_coercion (exp, noside);
+  struct type *type = value_type (callee);
+  if (type->code () == TYPE_CODE_PTR)
+    type = TYPE_TARGET_TYPE (type);
   for (int i = 0; i < args.size (); ++i)
-    vals[i] = args[i]->evaluate_with_coercion (exp, noside);
+    {
+      if (i < type->num_fields ())
+       vals[i] = args[i]->evaluate (type->field (i).type (), exp, noside);
+      else
+       vals[i] = args[i]->evaluate_with_coercion (exp, noside);
+    }
 
   return evaluate_subexp_do_call (exp, noside, callee, vals,
                                  function_name, expect_type);
@@ -718,12 +719,13 @@ var_value_operation::evaluate_funcall (struct type *expect_type,
 
   struct symbol *symp;
   find_overload_match (argvec, NULL, NON_METHOD,
-                      NULL, std::get<0> (m_storage),
+                      NULL, std::get<0> (m_storage).symbol,
                       NULL, &symp, NULL, 0, noside);
 
-  if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR)
+  if (symp->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (symp->print_name ());
-  value *callee = evaluate_var_value (noside, std::get<1> (m_storage), symp);
+  value *callee = evaluate_var_value (noside, std::get<0> (m_storage).block,
+                                     symp);
 
   return evaluate_subexp_do_call (exp, noside, callee, argvec,
                                  nullptr, expect_type);
@@ -870,6 +872,8 @@ structop_base_operation::evaluate_funcall
      (struct type *expect_type, struct expression *exp, enum noside noside,
       const std::vector<operation_up> &args)
 {
+  /* Allocate space for the function call arguments, Including space for a
+     `this' pointer at the start.  */
   std::vector<value *> vals (args.size () + 1);
   /* First, evaluate the structure into vals[0].  */
   enum exp_opcode op = opcode ();
@@ -916,9 +920,13 @@ structop_base_operation::evaluate_funcall
        }
     }
 
+  /* Evaluate the arguments.  The '+ 1' here is to allow for the `this'
+     pointer we placed into vals[0].  */
   for (int i = 0; i < args.size (); ++i)
     vals[i + 1] = args[i]->evaluate_with_coercion (exp, noside);
-  gdb::array_view<value *> arg_view = vals;
+
+  /* The array view includes the `this' pointer.  */
+  gdb::array_view<value *> arg_view (vals);
 
   int static_memfuncp;
   value *callee;
@@ -939,7 +947,7 @@ structop_base_operation::evaluate_funcall
     {
       struct value *temp = vals[0];
 
-      callee = value_struct_elt (&temp, &vals[1], tstr,
+      callee = value_struct_elt (&temp, arg_view, tstr,
                                 &static_memfuncp,
                                 op == STRUCTOP_STRUCT
                                 ? "structure" : "structure pointer");
@@ -983,8 +991,6 @@ 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)
@@ -998,10 +1004,8 @@ 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);
+    return value_zero (sym->type (), not_lval);
 
   if (SYMBOL_COMPUTED_OPS (sym) == NULL
       || SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL)
@@ -1017,14 +1021,15 @@ eval_op_var_entry_value (struct type *expect_type, struct expression *exp,
 struct value *
 eval_op_var_msym_value (struct type *expect_type, struct expression *exp,
                        enum noside noside, bool outermost_p,
-                       minimal_symbol *msymbol, struct objfile *objfile)
+                       bound_minimal_symbol msymbol)
 {
-  value *val = evaluate_var_msym_value (noside, objfile, msymbol);
+  value *val = evaluate_var_msym_value (noside, msymbol.objfile,
+                                       msymbol.minsym);
 
   struct type *type = value_type (val);
   if (type->code () == TYPE_CODE_ERROR
       && (noside != EVAL_AVOID_SIDE_EFFECTS || !outermost_p))
-    error_unknown_type (msymbol->print_name ());
+    error_unknown_type (msymbol.minsym->print_name ());
   return val;
 }
 
@@ -1035,8 +1040,6 @@ 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);
@@ -1075,19 +1078,22 @@ eval_op_register (struct type *expect_type, struct expression *exp,
     return val;
 }
 
-/* Helper function that implements the body of OP_STRING.  */
+namespace expr
+{
 
-struct value *
-eval_op_string (struct type *expect_type, struct expression *exp,
-               enum noside noside, int len, const char *string)
+value *
+string_operation::evaluate (struct type *expect_type,
+                           struct expression *exp,
+                           enum noside noside)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
+  const std::string &str = std::get<0> (m_storage);
   struct type *type = language_string_char_type (exp->language_defn,
                                                 exp->gdbarch);
-  return value_string (string, len, type);
+  return value_string (str.c_str (), str.size (), type);
 }
 
+} /* namespace expr */
+
 /* Helper function that implements the body of OP_OBJC_SELECTOR.  */
 
 struct value *
@@ -1095,28 +1101,11 @@ eval_op_objc_selector (struct type *expect_type, struct expression *exp,
                       enum noside noside,
                       const char *sel)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
-
   struct type *selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
   return value_from_longest (selector_type,
                             lookup_child_selector (exp->gdbarch, sel));
 }
 
-/* Helper function that implements the body of BINOP_CONCAT.  */
-
-struct value *
-eval_op_concat (struct type *expect_type, struct expression *exp,
-               enum noside noside, struct value *arg1, struct value *arg2)
-{
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
-  if (binop_user_defined_p (BINOP_CONCAT, arg1, arg2))
-    return value_x_binop (arg1, arg2, BINOP_CONCAT, OP_NULL, noside);
-  else
-    return value_concat (arg1, arg2);
-}
-
 /* A helper function for TERNOP_SLICE.  */
 
 struct value *
@@ -1124,8 +1113,6 @@ eval_op_ternop (struct type *expect_type, struct expression *exp,
                enum noside noside,
                struct value *array, struct value *low, struct value *upper)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   int lowbound = value_as_long (low);
   int upperbound = value_as_long (upper);
   return value_slice (array, lowbound, upperbound - lowbound + 1);
@@ -1138,9 +1125,7 @@ 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,
+  struct value *arg3 = value_struct_elt (&arg1, {}, string,
                                         NULL, "structure");
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3));
@@ -1154,9 +1139,6 @@ eval_op_structop_ptr (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);
-
   /* Check to see if operator '->' has been overloaded.  If so replace
      arg1 with the value returned by evaluating operator->().  */
   while (unop_user_defined_p (STRUCTOP_PTR, arg1))
@@ -1199,7 +1181,7 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp,
       }
   }
 
-  struct value *arg3 = value_struct_elt (&arg1, NULL, string,
+  struct value *arg3 = value_struct_elt (&arg1, {}, string,
                                         NULL, "structure pointer");
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3));
@@ -1215,9 +1197,6 @@ eval_op_member (struct type *expect_type, struct expression *exp,
 {
   long mem_offset;
 
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
-
   struct value *arg3;
   struct type *type = check_typedef (value_type (arg2));
   switch (type->code ())
@@ -1256,8 +1235,6 @@ eval_op_add (struct type *expect_type, struct expression *exp,
             enum noside noside,
             struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (BINOP_ADD, arg1, arg2))
     return value_x_binop (arg1, arg2, BINOP_ADD, OP_NULL, noside);
   else if (ptrmath_type_p (exp->language_defn, value_type (arg1))
@@ -1280,8 +1257,6 @@ eval_op_sub (struct type *expect_type, struct expression *exp,
             enum noside noside,
             struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (BINOP_SUB, arg1, arg2))
     return value_x_binop (arg1, arg2, BINOP_SUB, OP_NULL, noside);
   else if (ptrmath_type_p (exp->language_defn, value_type (arg1))
@@ -1308,8 +1283,6 @@ eval_op_binary (struct type *expect_type, struct expression *exp,
                enum noside noside, enum exp_opcode op,
                struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (op, arg1, arg2))
     return value_x_binop (arg1, arg2, op, OP_NULL, noside);
   else
@@ -1355,8 +1328,6 @@ eval_op_subscript (struct type *expect_type, struct expression *exp,
                   enum noside noside, enum exp_opcode op,
                   struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (op, arg1, arg2))
     return value_x_binop (arg1, arg2, op, OP_NULL, noside);
   else
@@ -1391,8 +1362,6 @@ eval_op_equal (struct type *expect_type, struct expression *exp,
               enum noside noside, enum exp_opcode op,
               struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (op, arg1, arg2))
     {
       return value_x_binop (arg1, arg2, op, OP_NULL, noside);
@@ -1414,8 +1383,6 @@ eval_op_notequal (struct type *expect_type, struct expression *exp,
                  enum noside noside, enum exp_opcode op,
                  struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (op, arg1, arg2))
     {
       return value_x_binop (arg1, arg2, op, OP_NULL, noside);
@@ -1437,8 +1404,6 @@ eval_op_less (struct type *expect_type, struct expression *exp,
              enum noside noside, enum exp_opcode op,
              struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (op, arg1, arg2))
     {
       return value_x_binop (arg1, arg2, op, OP_NULL, noside);
@@ -1460,8 +1425,6 @@ eval_op_gtr (struct type *expect_type, struct expression *exp,
             enum noside noside, enum exp_opcode op,
             struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (op, arg1, arg2))
     {
       return value_x_binop (arg1, arg2, op, OP_NULL, noside);
@@ -1483,8 +1446,6 @@ eval_op_geq (struct type *expect_type, struct expression *exp,
             enum noside noside, enum exp_opcode op,
             struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (op, arg1, arg2))
     {
       return value_x_binop (arg1, arg2, op, OP_NULL, noside);
@@ -1506,8 +1467,6 @@ eval_op_leq (struct type *expect_type, struct expression *exp,
             enum noside noside, enum exp_opcode op,
             struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (binop_user_defined_p (op, arg1, arg2))
     {
       return value_x_binop (arg1, arg2, op, OP_NULL, noside);
@@ -1529,8 +1488,6 @@ eval_op_repeat (struct type *expect_type, struct expression *exp,
                enum noside noside, enum exp_opcode op,
                struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   struct type *type = check_typedef (value_type (arg2));
   if (type->code () != TYPE_CODE_INT
       && type->code () != TYPE_CODE_ENUM)
@@ -1551,8 +1508,6 @@ eval_op_plus (struct type *expect_type, struct expression *exp,
              enum noside noside, enum exp_opcode op,
              struct value *arg1)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (unop_user_defined_p (op, arg1))
     return value_x_unop (arg1, op, noside);
   else
@@ -1569,8 +1524,6 @@ eval_op_neg (struct type *expect_type, struct expression *exp,
             enum noside noside, enum exp_opcode op,
             struct value *arg1)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (unop_user_defined_p (op, arg1))
     return value_x_unop (arg1, op, noside);
   else
@@ -1587,8 +1540,6 @@ eval_op_complement (struct type *expect_type, struct expression *exp,
                    enum noside noside, enum exp_opcode op,
                    struct value *arg1)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (unop_user_defined_p (UNOP_COMPLEMENT, arg1))
     return value_x_unop (arg1, UNOP_COMPLEMENT, noside);
   else
@@ -1605,8 +1556,6 @@ eval_op_lognot (struct type *expect_type, struct expression *exp,
                enum noside noside, enum exp_opcode op,
                struct value *arg1)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (unop_user_defined_p (op, arg1))
     return value_x_unop (arg1, op, noside);
   else
@@ -1629,8 +1578,6 @@ eval_op_ind (struct type *expect_type, struct expression *exp,
       || type->code () == TYPE_CODE_MEMBERPTR)
     error (_("Attempt to dereference pointer "
             "to member without an object"));
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   if (unop_user_defined_p (UNOP_IND, arg1))
     return value_x_unop (arg1, UNOP_IND, noside);
   else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -1642,12 +1589,10 @@ eval_op_ind (struct type *expect_type, struct expression *exp,
         There is a risk that this dereference will have side-effects
         in the inferior, but being able to print accurate type
         information seems worth the risk. */
-      if ((type->code () != TYPE_CODE_PTR
-          && !TYPE_IS_REFERENCE (type))
+      if (!type->is_pointer_or_reference ()
          || !is_dynamic_type (TYPE_TARGET_TYPE (type)))
        {
-         if (type->code () == TYPE_CODE_PTR
-             || TYPE_IS_REFERENCE (type)
+         if (type->is_pointer_or_reference ()
              /* In C you can dereference an array to get the 1st elt.  */
              || type->code () == TYPE_CODE_ARRAY)
            return value_zero (TYPE_TARGET_TYPE (type),
@@ -1694,8 +1639,6 @@ 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
@@ -1709,7 +1652,7 @@ eval_op_preinc (struct type *expect_type, struct expression *exp,
                enum noside noside, enum exp_opcode op,
                struct value *arg1)
 {
-  if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
     return arg1;
   else if (unop_user_defined_p (op, arg1))
     {
@@ -1740,7 +1683,7 @@ eval_op_predec (struct type *expect_type, struct expression *exp,
                enum noside noside, enum exp_opcode op,
                struct value *arg1)
 {
-  if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
     return arg1;
   else if (unop_user_defined_p (op, arg1))
     {
@@ -1771,7 +1714,7 @@ eval_op_postinc (struct type *expect_type, struct expression *exp,
                 enum noside noside, enum exp_opcode op,
                 struct value *arg1)
 {
-  if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
     return arg1;
   else if (unop_user_defined_p (op, arg1))
     {
@@ -1805,7 +1748,7 @@ eval_op_postdec (struct type *expect_type, struct expression *exp,
                 enum noside noside, enum exp_opcode op,
                 struct value *arg1)
 {
-  if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
     return arg1;
   else if (unop_user_defined_p (op, arg1))
     {
@@ -1838,9 +1781,7 @@ struct value *
 eval_op_type (struct type *expect_type, struct expression *exp,
              enum noside noside, struct type *type)
 {
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
-  else if (noside == EVAL_AVOID_SIDE_EFFECTS)
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
     return allocate_value (type);
   else
     error (_("Attempt to use a type name as an expression"));
@@ -1853,7 +1794,7 @@ eval_binop_assign_modify (struct type *expect_type, struct expression *exp,
                          enum noside noside, enum exp_opcode op,
                          struct value *arg1, struct value *arg2)
 {
-  if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
     return arg1;
   if (binop_user_defined_p (op, arg1, arg2))
     return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside);
@@ -2022,8 +1963,8 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp,
 
       /* The address might point to a function descriptor;
         resolve it to the actual code address instead.  */
-      addr = gdbarch_convert_from_func_ptr_addr (exp->gdbarch, addr,
-                                                current_top_target ());
+      addr = gdbarch_convert_from_func_ptr_addr
+       (exp->gdbarch, addr, current_inferior ()->top_target ());
 
       /* Is it a high_level symbol?  */
       sym = find_pc_function (addr);
@@ -2103,8 +2044,6 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp,
        called_method = msg_send;
     }
 
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
 
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     {
@@ -2160,8 +2099,6 @@ eval_multi_subscript (struct type *expect_type, struct expression *exp,
                      enum noside noside, value *arg1,
                      gdb::array_view<value *> args)
 {
-  if (noside == EVAL_SKIP)
-    return arg1;
   for (value *arg2 : args)
     {
       if (binop_user_defined_p (MULTI_SUBSCRIPT, arg1, arg2))
@@ -2249,8 +2186,6 @@ logical_and_operation::evaluate (struct type *expect_type,
                                 enum noside noside)
 {
   value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
 
   value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp,
                                                   EVAL_AVOID_SIDE_EFFECTS);
@@ -2262,7 +2197,7 @@ logical_and_operation::evaluate (struct type *expect_type,
     }
   else
     {
-      int tem = value_logical_not (arg1);
+      bool tem = value_logical_not (arg1);
       if (!tem)
        {
          arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
@@ -2280,8 +2215,6 @@ logical_or_operation::evaluate (struct type *expect_type,
                                enum noside noside)
 {
   value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
 
   value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp,
                                                   EVAL_AVOID_SIDE_EFFECTS);
@@ -2293,7 +2226,7 @@ logical_or_operation::evaluate (struct type *expect_type,
     }
   else
     {
-      int tem = value_logical_not (arg1);
+      bool tem = value_logical_not (arg1);
       if (tem)
        {
          arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
@@ -2321,7 +2254,7 @@ adl_func_operation::evaluate (struct type *expect_type,
                       NON_METHOD,
                       nullptr, nullptr,
                       nullptr, &symp, nullptr, 0, noside);
-  if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR)
+  if (symp->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (symp->print_name ());
   value *callee = evaluate_var_value (noside, std::get<1> (m_storage), symp);
   return evaluate_subexp_do_call (exp, noside, callee, args,
@@ -2358,7 +2291,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val,
        error (_("too many initializers"));
       field_type = struct_type->field (fieldno).type ();
       if (field_type->code () == TYPE_CODE_UNION
-         && TYPE_FIELD_NAME (struct_type, fieldno)[0] == '0')
+         && struct_type->field (fieldno).name ()[0] == '0')
        error (_("don't know which variant you want to set"));
 
       /* Here, struct_type is the type of the inner struct,
@@ -2381,13 +2314,13 @@ array_operation::evaluate_struct_tuple (struct value *struct_val,
        val = value_cast (field_type, val);
 
       bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno);
-      bitpos = TYPE_FIELD_BITPOS (struct_type, fieldno);
-      addr = value_contents_writeable (struct_val) + bitpos / 8;
+      bitpos = struct_type->field (fieldno).loc_bitpos ();
+      addr = value_contents_writeable (struct_val).data () + bitpos / 8;
       if (bitsize)
        modify_field (struct_type, addr,
                      value_as_long (val), bitpos % 8, bitsize);
       else
-       memcpy (addr, value_contents (val),
+       memcpy (addr, value_contents (val).data (),
                TYPE_LENGTH (value_type (val)));
 
     }
@@ -2406,16 +2339,16 @@ array_operation::evaluate (struct type *expect_type,
   int nargs = tem3 - tem2 + 1;
   struct type *type = expect_type ? check_typedef (expect_type) : nullptr;
 
-  if (expect_type != nullptr && noside != EVAL_SKIP
+  if (expect_type != nullptr
       && type->code () == TYPE_CODE_STRUCT)
     {
       struct value *rec = allocate_value (expect_type);
 
-      memset (value_contents_raw (rec), '\0', TYPE_LENGTH (type));
+      memset (value_contents_raw (rec).data (), '\0', TYPE_LENGTH (type));
       return evaluate_struct_tuple (rec, exp, noside, nargs);
     }
 
-  if (expect_type != nullptr && noside != EVAL_SKIP
+  if (expect_type != nullptr
       && type->code () == TYPE_CODE_ARRAY)
     {
       struct type *range_type = type->index_type ();
@@ -2430,7 +2363,7 @@ array_operation::evaluate (struct type *expect_type,
          high_bound = (TYPE_LENGTH (type) / element_size) - 1;
        }
       index = low_bound;
-      memset (value_contents_raw (array), 0, TYPE_LENGTH (expect_type));
+      memset (value_contents_raw (array).data (), 0, TYPE_LENGTH (expect_type));
       for (tem = nargs; --nargs >= 0;)
        {
          struct value *element;
@@ -2442,20 +2375,20 @@ array_operation::evaluate (struct type *expect_type,
          if (index > high_bound)
            /* To avoid memory corruption.  */
            error (_("Too many array elements"));
-         memcpy (value_contents_raw (array)
+         memcpy (value_contents_raw (array).data ()
                  + (index - low_bound) * element_size,
-                 value_contents (element),
+                 value_contents (element).data (),
                  element_size);
          index++;
        }
       return array;
     }
 
-  if (expect_type != nullptr && noside != EVAL_SKIP
+  if (expect_type != nullptr
       && type->code () == TYPE_CODE_SET)
     {
       struct value *set = allocate_value (expect_type);
-      gdb_byte *valaddr = value_contents_raw (set);
+      gdb_byte *valaddr = value_contents_raw (set).data ();
       struct type *element_type = type->index_type ();
       struct type *check_type = element_type;
       LONGEST low_bound, high_bound;
@@ -2524,11 +2457,25 @@ array_operation::evaluate (struct type *expect_type,
         objects.  */
       argvec[tem] = in_args[tem]->evaluate_with_coercion (exp, noside);
     }
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   return value_array (tem2, tem3, argvec);
 }
 
+value *
+unop_extract_operation::evaluate (struct type *expect_type,
+                                 struct expression *exp,
+                                 enum noside noside)
+{
+  value *old_value = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+  struct type *type = get_type ();
+
+  if (TYPE_LENGTH (type) > TYPE_LENGTH (value_type (old_value)))
+    error (_("length type is larger than the value type"));
+
+  struct value *result = allocate_value (type);
+  value_contents_copy (result, 0, old_value, 0, TYPE_LENGTH (type));
+  return result;
+}
+
 }
 
 \f
@@ -2564,8 +2511,6 @@ operation::evaluate_for_cast (struct type *expect_type,
                              enum noside noside)
 {
   value *val = evaluate (expect_type, exp, noside);
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
   return value_cast (expect_type, val);
 }
 
@@ -2608,9 +2553,8 @@ value *
 var_msym_value_operation::evaluate_for_address (struct expression *exp,
                                                enum noside noside)
 {
-  value *val = evaluate_var_msym_value (noside,
-                                       std::get<1> (m_storage),
-                                       std::get<0> (m_storage));
+  const bound_minimal_symbol &b = std::get<0> (m_storage);
+  value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym);
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     {
       struct type *type = lookup_pointer_type (value_type (val));
@@ -2643,17 +2587,17 @@ value *
 var_value_operation::evaluate_for_address (struct expression *exp,
                                           enum noside noside)
 {
-  symbol *var = std::get<0> (m_storage);
+  symbol *var = std::get<0> (m_storage).symbol;
 
   /* C++: The "address" of a reference should yield the address
    * of the object pointed to.  Let value_addr() deal with it.  */
-  if (TYPE_IS_REFERENCE (SYMBOL_TYPE (var)))
+  if (TYPE_IS_REFERENCE (var->type ()))
     return operation::evaluate_for_address (exp, noside);
 
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     {
-      struct type *type = lookup_pointer_type (SYMBOL_TYPE (var));
-      enum address_class sym_class = SYMBOL_CLASS (var);
+      struct type *type = lookup_pointer_type (var->type ());
+      enum address_class sym_class = var->aclass ();
 
       if (sym_class == LOC_CONST
          || sym_class == LOC_CONST_BYTES
@@ -2663,20 +2607,21 @@ var_value_operation::evaluate_for_address (struct expression *exp,
       return value_zero (type, not_lval);
     }
   else
-    return address_of_variable (var, std::get<1> (m_storage));
+    return address_of_variable (var, std::get<0> (m_storage).block);
 }
 
 value *
 var_value_operation::evaluate_with_coercion (struct expression *exp,
                                             enum noside noside)
 {
-  struct symbol *var = std::get<0> (m_storage);
-  struct type *type = check_typedef (SYMBOL_TYPE (var));
+  struct symbol *var = std::get<0> (m_storage).symbol;
+  struct type *type = check_typedef (var->type ());
   if (type->code () == TYPE_CODE_ARRAY
       && !type->is_vector ()
       && CAST_IS_CONVERSION (exp->language_defn))
     {
-      struct value *val = address_of_variable (var, std::get<1> (m_storage));
+      struct value *val = address_of_variable (var,
+                                              std::get<0> (m_storage).block);
       return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), val);
     }
   return evaluate (nullptr, exp, noside);
@@ -2716,14 +2661,12 @@ var_msym_value_operation::evaluate_for_sizeof (struct expression *exp,
                                               enum noside noside)
 
 {
-  minimal_symbol *msymbol = std::get<0> (m_storage);
-  value *mval = evaluate_var_msym_value (noside,
-                                        std::get<1> (m_storage),
-                                        msymbol);
+  const bound_minimal_symbol &b = std::get<0> (m_storage);
+  value *mval = evaluate_var_msym_value (noside, b.objfile, b.minsym);
 
   struct type *type = value_type (mval);
   if (type->code () == TYPE_CODE_ERROR)
-    error_unknown_type (msymbol->print_name ());
+    error_unknown_type (b.minsym->print_name ());
 
   /* FIXME: This should be size_t.  */
   struct type *size_type = builtin_type (exp->gdbarch)->builtin_int;
@@ -2770,8 +2713,7 @@ unop_ind_base_operation::evaluate_for_sizeof (struct expression *exp,
   value *val = std::get<0> (m_storage)->evaluate (nullptr, exp,
                                                  EVAL_AVOID_SIDE_EFFECTS);
   struct type *type = check_typedef (value_type (val));
-  if (type->code () != TYPE_CODE_PTR
-      && !TYPE_IS_REFERENCE (type)
+  if (!type->is_pointer_or_reference ()
       && type->code () != TYPE_CODE_ARRAY)
     error (_("Attempt to take contents of a non-pointer value."));
   type = TYPE_TARGET_TYPE (type);
@@ -2802,7 +2744,7 @@ value *
 var_value_operation::evaluate_for_sizeof (struct expression *exp,
                                          enum noside noside)
 {
-  struct type *type = SYMBOL_TYPE (std::get<0> (m_storage));
+  struct type *type = std::get<0> (m_storage).symbol->type ();
   if (is_dynamic_type (type))
     {
       value *val = evaluate (nullptr, exp, EVAL_NORMAL);
@@ -2829,12 +2771,8 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type,
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     return value_zero (to_type, not_lval);
 
-  value *val = evaluate_var_msym_value (noside,
-                                       std::get<1> (m_storage),
-                                       std::get<0> (m_storage));
-
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
+  const bound_minimal_symbol &b = std::get<0> (m_storage);
+  value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym);
 
   val = value_cast (to_type, val);
 
@@ -2854,11 +2792,8 @@ var_value_operation::evaluate_for_cast (struct type *to_type,
                                        enum noside noside)
 {
   value *val = evaluate_var_value (noside,
-                                  std::get<1> (m_storage),
-                                  std::get<0> (m_storage));
-
-  if (noside == EVAL_SKIP)
-    return eval_skip_value (exp);
+                                  std::get<0> (m_storage).block,
+                                  std::get<0> (m_storage).symbol);
 
   val = value_cast (to_type, val);