Turn allocate_optimized_out_value into static "constructor"

This turns allocate_optimized_out_value into a static "constructor" of
value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey
2023-01-31 13:30:54 -07:00
parent b64e260290
commit b27556e3c1
11 changed files with 21 additions and 20 deletions

View File

@ -556,7 +556,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
struct value *result; struct value *result;
if (value_optimized_out (val)) if (value_optimized_out (val))
result = allocate_optimized_out_value (type); result = value::allocate_optimized_out (type);
else if (val->lazy () else if (val->lazy ()
/* Be careful not to make a lazy not_lval value. */ /* Be careful not to make a lazy not_lval value. */
|| (VALUE_LVAL (val) != not_lval || (VALUE_LVAL (val) != not_lval

View File

@ -1044,7 +1044,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
break; break;
case DWARF_VALUE_OPTIMIZED_OUT: case DWARF_VALUE_OPTIMIZED_OUT:
retval = allocate_optimized_out_value (subobj_type); retval = value::allocate_optimized_out (subobj_type);
break; break;
/* DWARF_VALUE_IMPLICIT_POINTER was converted to a pieced /* DWARF_VALUE_IMPLICIT_POINTER was converted to a pieced

View File

@ -1429,7 +1429,7 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
invalid_synthetic_pointer (); invalid_synthetic_pointer ();
} }
else else
result = allocate_optimized_out_value (type->target_type ()); result = value::allocate_optimized_out (type->target_type ());
return result; return result;
} }
@ -1497,7 +1497,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
invalid_synthetic_pointer (); invalid_synthetic_pointer ();
if (size == 0) 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 ()); 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) if (entry_values_debug)
exception_print (gdb_stdout, ex); exception_print (gdb_stdout, ex);
free_values.free_to_mark (); free_values.free_to_mark ();
return allocate_optimized_out_value (subobj_type); return value::allocate_optimized_out (subobj_type);
} }
else else
throw; throw;
@ -3906,11 +3906,11 @@ loclist_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame)
CORE_ADDR pc; CORE_ADDR pc;
if (frame == NULL || !get_frame_func_if_available (frame, &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); data = dwarf2_find_location_expression (dlbaton, &size, pc);
if (data == NULL) 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); return value_of_dwarf_block_entry (symbol->type (), frame, data, size);
} }

View File

@ -2855,7 +2855,7 @@ var_value_operation::evaluate_for_sizeof (struct expression *exp,
return value_zero (size_type, not_lval); return value_zero (size_type, not_lval);
else if (is_dynamic_type (type->index_type ()) else if (is_dynamic_type (type->index_type ())
&& type->bounds ()->high.kind () == PROP_UNDEFINED) && 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); return evaluate_subexp_for_sizeof_base (exp, type);

View File

@ -769,7 +769,7 @@ language_defn::read_var_value (struct symbol *var,
case LOC_OPTIMIZED_OUT: case LOC_OPTIMIZED_OUT:
if (is_dynamic_type (type)) if (is_dynamic_type (type))
type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); type = resolve_dynamic_type (type, {}, /* Unused address. */ 0);
return allocate_optimized_out_value (type); return value::allocate_optimized_out (type);
default: default:
error (_("Cannot look up value of a botched symbol `%s'."), error (_("Cannot look up value of a botched symbol `%s'."),

View File

@ -267,7 +267,7 @@ frame_unwind_got_optimized (frame_info_ptr frame, int regnum)
struct gdbarch *gdbarch = frame_unwind_arch (frame); struct gdbarch *gdbarch = frame_unwind_arch (frame);
struct type *type = register_type (gdbarch, regnum); 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 /* Return a value which indicates that FRAME copied REGNUM into

View File

@ -1189,7 +1189,7 @@ typy_optimized_out (PyObject *self, PyObject *args)
{ {
struct type *type = ((type_object *) self)->type; 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. */ /* Return a gdb.Field object for the field named by the argument. */

View File

@ -2239,7 +2239,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum)
return value_cast (type, val); 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 /* Translate a .eh_frame register to DWARF register, or adjust a

View File

@ -674,7 +674,7 @@ read_frame_arg (const frame_print_options &fp_opts,
|| (fp_opts.print_entry_values == print_entry_values_preferred || (fp_opts.print_entry_values == print_entry_values_preferred
&& (!val || value_optimized_out (val)))) && (!val || value_optimized_out (val))))
{ {
entryval = allocate_optimized_out_value (sym->type ()); entryval = value::allocate_optimized_out (sym->type ());
entryval_error = NULL; entryval_error = NULL;
} }
} }

View File

@ -1008,10 +1008,10 @@ value::allocate_computed (struct type *type,
return v; return v;
} }
/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */ /* See value.h. */
struct value * struct value *
allocate_optimized_out_value (struct type *type) value::allocate_optimized_out (struct type *type)
{ {
struct value *retval = value::allocate_lazy (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 (); struct type *field_type = type->field (fieldno).type ();
if (!msym.minsym) if (!msym.minsym)
retval = allocate_optimized_out_value (field_type); retval = value::allocate_optimized_out (field_type);
else else
retval = value_at_lazy (field_type, msym.value_address ()); 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 valid. Optimized out/unavailable bits are read as zero, but
that's OK, as they'll end up marked below. If the VAL is that's OK, as they'll end up marked below. If the VAL is
wholly-invalid we may have skipped allocating its contents, wholly-invalid we may have skipped allocating its contents,
though. See allocate_optimized_out_value. */ though. See value::allocate_optimized_out. */
if (valaddr != NULL) if (valaddr != NULL)
{ {
LONGEST num; LONGEST num;
@ -4196,7 +4196,7 @@ test_value_copy ()
/* Verify that we can copy an entirely optimized out value, that may not have /* Verify that we can copy an entirely optimized out value, that may not have
its contents allocated. */ 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 ())); value_ref_ptr copy = release_value (value_copy (val.get ()));
SELF_CHECK (value_entirely_optimized_out (val.get ())); SELF_CHECK (value_entirely_optimized_out (val.get ()));

View File

@ -175,6 +175,9 @@ public:
const struct lval_funcs *funcs, const struct lval_funcs *funcs,
void *closure); void *closure);
/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */
static struct value *allocate_optimized_out (struct type *type);
~value (); ~value ();
DISABLE_COPY_AND_ASSIGN (value); DISABLE_COPY_AND_ASSIGN (value);
@ -625,8 +628,6 @@ struct lval_funcs
void (*free_closure) (struct value *v); 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 /* Throw an error complaining that the value has been optimized
out. */ out. */