@@ -91,7 +91,7 @@ gdbscm_preserve_values (const struct extension_language_defn *extlang,
value_smob *iter;
for (iter = values_in_scheme; iter; iter = iter->next)
- preserve_one_value (iter->value, objfile, copied_types);
+ iter->value->preserve (objfile, copied_types);
}
/* Helper to add a value_smob to the global list. */
@@ -228,7 +228,7 @@ gdbpy_preserve_values (const struct extension_language_defn *extlang,
value_object *iter;
for (iter = values_in_python; iter; iter = iter->next)
- preserve_one_value (iter->value, objfile, copied_types);
+ iter->value->preserve (objfile, copied_types);
}
/* Given a value of a pointer type, apply the C unary * operator to it. */
@@ -2219,19 +2219,14 @@ add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
cmd->name_allocated = 1;
}
-/* Update VALUE before discarding OBJFILE. COPIED_TYPES is used to
- prevent cycles / duplicates. */
-
void
-preserve_one_value (struct value *value, struct objfile *objfile,
- htab_t copied_types)
+value::preserve (struct objfile *objfile, htab_t copied_types)
{
- if (value->m_type->objfile_owner () == objfile)
- value->m_type = copy_type_recursive (value->m_type, copied_types);
+ if (m_type->objfile_owner () == objfile)
+ m_type = copy_type_recursive (m_type, copied_types);
- if (value->m_enclosing_type->objfile_owner () == objfile)
- value->m_enclosing_type = copy_type_recursive (value->m_enclosing_type,
- copied_types);
+ if (m_enclosing_type->objfile_owner () == objfile)
+ m_enclosing_type = copy_type_recursive (m_enclosing_type, copied_types);
}
/* Likewise for internal variable VAR. */
@@ -2250,7 +2245,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile,
break;
case INTERNALVAR_VALUE:
- preserve_one_value (var->u.value, objfile, copied_types);
+ var->u.value->preserve (objfile, copied_types);
break;
}
}
@@ -2271,7 +2266,7 @@ preserve_one_varobj (struct varobj *varobj, struct objfile *objfile,
}
if (varobj->value != nullptr)
- preserve_one_value (varobj->value.get (), objfile, copied_types);
+ varobj->value.get ()->preserve (objfile, copied_types);
}
/* Update the internal variables and value history when OBJFILE is
@@ -2290,7 +2285,7 @@ preserve_values (struct objfile *objfile)
htab_up copied_types = create_copied_types_hash ();
for (const value_ref_ptr &item : value_history)
- preserve_one_value (item.get (), objfile, copied_types.get ());
+ item.get ()->preserve (objfile, copied_types.get ());
for (var = internalvars; var; var = var->next)
preserve_one_internalvar (var, objfile, copied_types.get ());
@@ -555,6 +555,10 @@ struct value
METHOD. */
struct value *call_xmethod (gdb::array_view<value *> argv);
+ /* Update this value before discarding OBJFILE. COPIED_TYPES is
+ used to prevent cycles / duplicates. */
+ void preserve (struct objfile *objfile, htab_t copied_types);
+
/* Type of value; either not an lval, or one of the various
different possible kinds of lval. */
@@ -1431,8 +1435,6 @@ extern void preserve_values (struct objfile *);
extern struct value *make_cv_value (int, int, struct value *);
-extern void preserve_one_value (struct value *, struct objfile *, htab_t);
-
/* From valops.c */
extern struct value *varying_to_slice (struct value *);