diff options
author | Tom Tromey <tom@tromey.com> | 2023-01-31 21:11:38 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-02-13 15:22:17 -0700 |
commit | e3fb3c4772d81a7deb26a3c1af253e9f01b07716 (patch) | |
tree | 929a9b816440664b716aa40c720a2636fd3a65e3 /gdb | |
parent | 6bd5c75435099f09bf1b2027e118f66a6fd94218 (diff) | |
download | gdb-e3fb3c4772d81a7deb26a3c1af253e9f01b07716.zip gdb-e3fb3c4772d81a7deb26a3c1af253e9f01b07716.tar.gz gdb-e3fb3c4772d81a7deb26a3c1af253e9f01b07716.tar.bz2 |
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 <simon.marchi@efficios.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/guile/scm-value.c | 2 | ||||
-rw-r--r-- | gdb/python/py-value.c | 2 | ||||
-rw-r--r-- | gdb/value.c | 21 | ||||
-rw-r--r-- | gdb/value.h | 6 |
4 files changed, 14 insertions, 17 deletions
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 3e18bd1..a0b7e66 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 6c33e35..658a9a3 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 730ca7c..3aac084 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2380,19 +2380,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. */ @@ -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 36e7a89..ccba220 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -554,6 +554,10 @@ public: 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. */ @@ -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 *); |