From: Tom Tromey Date: Wed, 1 Feb 2023 04:11:38 +0000 (-0700) Subject: Turn preserve_one_value into method X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3fb3c4772d81a7deb26a3c1af253e9f01b07716;p=binutils-gdb.git Turn preserve_one_value into method This changes preserve_one_value to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi --- diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 3e18bd1fdc3..a0b7e6661b5 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -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. */ diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 6c33e3529c8..658a9a3f18c 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -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. */ diff --git a/gdb/value.c b/gdb/value.c index 730ca7c73e9..3aac084a864 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2380,19 +2380,14 @@ add_internal_function (gdb::unique_xmalloc_ptr &&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. */ @@ -2411,7 +2406,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; } } @@ -2432,7 +2427,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 @@ -2451,7 +2446,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 ()); diff --git a/gdb/value.h b/gdb/value.h index 36e7a89359d..ccba2208e88 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -554,6 +554,10 @@ public: METHOD. */ struct value *call_xmethod (gdb::array_view 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. */ @@ -1465,8 +1469,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 *);