public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Turn preserve_one_value into method
@ 2023-02-13 22:30 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-02-13 22:30 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e3fb3c4772d81a7deb26a3c1af253e9f01b07716

commit e3fb3c4772d81a7deb26a3c1af253e9f01b07716
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Jan 31 21:11:38 2023 -0700

    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>

Diff:
---
 gdb/guile/scm-value.c |  2 +-
 gdb/python/py-value.c |  2 +-
 gdb/value.c           | 21 ++++++++-------------
 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 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<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 36e7a89359d..ccba2208e88 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 *);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-13 22:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13 22:30 [binutils-gdb] Turn preserve_one_value into method Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).