]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Turn allocate_optimized_out_value into static "constructor"
authorTom Tromey <tom@tromey.com>
Tue, 31 Jan 2023 20:30:54 +0000 (13:30 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 13 Feb 2023 22:21:08 +0000 (15:21 -0700)
This turns allocate_optimized_out_value into a static "constructor" of
value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ada-lang.c
gdb/dwarf2/expr.c
gdb/dwarf2/loc.c
gdb/eval.c
gdb/findvar.c
gdb/frame-unwind.c
gdb/python/py-type.c
gdb/s390-tdep.c
gdb/stack.c
gdb/value.c
gdb/value.h

index 3d2c9f4f2ab77552850c245f636a87d3a3cfb7e9..727f816b5197a879af498af4b30ece079ebe538c 100644 (file)
@@ -556,7 +556,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
       struct value *result;
 
       if (value_optimized_out (val))
-       result = allocate_optimized_out_value (type);
+       result = value::allocate_optimized_out (type);
       else if (val->lazy ()
               /* Be careful not to make a lazy not_lval value.  */
               || (VALUE_LVAL (val) != not_lval
index ad6cf563562d8b6a7cb6175db833a42935bb2064..db88dc368fd5e5a6f71b3d6956a0d076679d275c 100644 (file)
@@ -1044,7 +1044,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
          break;
 
        case DWARF_VALUE_OPTIMIZED_OUT:
-         retval = allocate_optimized_out_value (subobj_type);
+         retval = value::allocate_optimized_out (subobj_type);
          break;
 
          /* DWARF_VALUE_IMPLICIT_POINTER was converted to a pieced
index 743a0cefd6dc3b931803f8ee077cd5c49236f3ee..96686d9a110de3f37bdf0bf62bac51b445961485 100644 (file)
@@ -1429,7 +1429,7 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
        invalid_synthetic_pointer ();
     }
   else
-    result = allocate_optimized_out_value (type->target_type ());
+    result = value::allocate_optimized_out (type->target_type ());
 
   return result;
 }
@@ -1497,7 +1497,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
     invalid_synthetic_pointer ();
 
   if (size == 0)
-    return allocate_optimized_out_value (subobj_type);
+    return value::allocate_optimized_out (subobj_type);
 
   dwarf_expr_context ctx (per_objfile, per_cu->addr_size ());
 
@@ -1524,7 +1524,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
          if (entry_values_debug)
            exception_print (gdb_stdout, ex);
          free_values.free_to_mark ();
-         return allocate_optimized_out_value (subobj_type);
+         return value::allocate_optimized_out (subobj_type);
        }
       else
        throw;
@@ -3906,11 +3906,11 @@ loclist_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame)
   CORE_ADDR pc;
 
   if (frame == NULL || !get_frame_func_if_available (frame, &pc))
-    return allocate_optimized_out_value (symbol->type ());
+    return value::allocate_optimized_out (symbol->type ());
 
   data = dwarf2_find_location_expression (dlbaton, &size, pc);
   if (data == NULL)
-    return allocate_optimized_out_value (symbol->type ());
+    return value::allocate_optimized_out (symbol->type ());
 
   return value_of_dwarf_block_entry (symbol->type (), frame, data, size);
 }
index 5f8d294322b9c214775fbd274c7d539cba40acf8..bb72043a28a4ba8802e297552d997d652ee0d2d5 100644 (file)
@@ -2855,7 +2855,7 @@ var_value_operation::evaluate_for_sizeof (struct expression *exp,
            return value_zero (size_type, not_lval);
          else if (is_dynamic_type (type->index_type ())
                   && type->bounds ()->high.kind () == PROP_UNDEFINED)
-           return allocate_optimized_out_value (size_type);
+           return value::allocate_optimized_out (size_type);
        }
     }
   return evaluate_subexp_for_sizeof_base (exp, type);
index b59962c65ba38903e6a3d6ffed62b5fa1fdd8547..048e439ac33b4e8f8b8d20f09f711fe42c13143c 100644 (file)
@@ -769,7 +769,7 @@ language_defn::read_var_value (struct symbol *var,
     case LOC_OPTIMIZED_OUT:
       if (is_dynamic_type (type))
        type = resolve_dynamic_type (type, {}, /* Unused address.  */ 0);
-      return allocate_optimized_out_value (type);
+      return value::allocate_optimized_out (type);
 
     default:
       error (_("Cannot look up value of a botched symbol `%s'."),
index d3baedb8a6f2b23711be511de92984b31b97c6e5..ab6c33fc59cf7ea3405e1ee78163569873236ae9 100644 (file)
@@ -267,7 +267,7 @@ frame_unwind_got_optimized (frame_info_ptr frame, int regnum)
   struct gdbarch *gdbarch = frame_unwind_arch (frame);
   struct type *type = register_type (gdbarch, regnum);
 
-  return allocate_optimized_out_value (type);
+  return value::allocate_optimized_out (type);
 }
 
 /* Return a value which indicates that FRAME copied REGNUM into
index 81b595140af4f2fd63f31efb176441d7c2e56efa..0a3787815ec10852998832853ff1ba8808f4d8dc 100644 (file)
@@ -1189,7 +1189,7 @@ typy_optimized_out (PyObject *self, PyObject *args)
 {
   struct type *type = ((type_object *) self)->type;
 
-  return value_to_value_object (allocate_optimized_out_value (type));
+  return value_to_value_object (value::allocate_optimized_out (type));
 }
 
 /* Return a gdb.Field object for the field named by the argument.  */
index 9aa2c06cec18f972eb42745c515f644b96045d5a..822f66dfc3c51018562b3d2eb1e60028a283b087 100644 (file)
@@ -2239,7 +2239,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum)
        return value_cast (type, val);
     }
 
-  return allocate_optimized_out_value (type);
+  return value::allocate_optimized_out (type);
 }
 
 /* Translate a .eh_frame register to DWARF register, or adjust a
index 9952c3a73dfab489b292885ab6824998be23496a..ca6087f3414cabbbaa91afe95f415a8b4649ffee 100644 (file)
@@ -674,7 +674,7 @@ read_frame_arg (const frame_print_options &fp_opts,
          || (fp_opts.print_entry_values == print_entry_values_preferred
              && (!val || value_optimized_out (val))))
        {
-         entryval = allocate_optimized_out_value (sym->type ());
+         entryval = value::allocate_optimized_out (sym->type ());
          entryval_error = NULL;
        }
     }
index 7fb12d8e9a6e4588eaa1a4c5ffba61d4bdaa46c6..a95737238e970d120cc3f12e41f09e4747641878 100644 (file)
@@ -1008,10 +1008,10 @@ value::allocate_computed (struct type *type,
   return v;
 }
 
-/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT.  */
+/* See value.h.  */
 
 struct value *
-allocate_optimized_out_value (struct type *type)
+value::allocate_optimized_out (struct type *type)
 {
   struct value *retval = value::allocate_lazy (type);
 
@@ -2875,7 +2875,7 @@ value_static_field (struct type *type, int fieldno)
          struct type *field_type = type->field (fieldno).type ();
 
          if (!msym.minsym)
-           retval = allocate_optimized_out_value (field_type);
+           retval = value::allocate_optimized_out (field_type);
          else
            retval = value_at_lazy (field_type, msym.value_address ());
        }
@@ -3224,7 +3224,7 @@ unpack_value_bitfield (struct value *dest_val,
      valid.  Optimized out/unavailable bits are read as zero, but
      that's OK, as they'll end up marked below.  If the VAL is
      wholly-invalid we may have skipped allocating its contents,
-     though.  See allocate_optimized_out_value.  */
+     though.  See value::allocate_optimized_out.  */
   if (valaddr != NULL)
     {
       LONGEST num;
@@ -4196,7 +4196,7 @@ test_value_copy ()
 
   /* Verify that we can copy an entirely optimized out value, that may not have
      its contents allocated.  */
-  value_ref_ptr val = release_value (allocate_optimized_out_value (type));
+  value_ref_ptr val = release_value (value::allocate_optimized_out (type));
   value_ref_ptr copy = release_value (value_copy (val.get ()));
 
   SELF_CHECK (value_entirely_optimized_out (val.get ()));
index dbbb61932b8fbd4acd866826b79eec99984f827c..4d5ef01279f86c52eb2387109f4764b459fa2023 100644 (file)
@@ -175,6 +175,9 @@ public:
                                          const struct lval_funcs *funcs,
                                          void *closure);
 
+  /* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT.  */
+  static struct value *allocate_optimized_out (struct type *type);
+
   ~value ();
 
   DISABLE_COPY_AND_ASSIGN (value);
@@ -625,8 +628,6 @@ struct lval_funcs
   void (*free_closure) (struct value *v);
 };
 
-extern struct value *allocate_optimized_out_value (struct type *type);
-
 /* Throw an error complaining that the value has been optimized
    out.  */