]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change finalize_values into a final cleanup
authorTom Tromey <tromey@adacore.com>
Fri, 23 Feb 2024 20:24:03 +0000 (13:24 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 27 Feb 2024 17:30:29 +0000 (10:30 -0700)
This removes finalize_values in favor of adding a new final cleanup.
This is safe now that extension languages are explicitly shut down.

gdb/top.c
gdb/value.c
gdb/value.h

index 67d6670cd9c931a844badffd6524b41ed51dfa49..cf7d3a913bacc7ffe1d8679835b70ff320730166 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1803,12 +1803,6 @@ quit_force (int *exit_arg, int from_tty)
       exception_print (gdb_stderr, ex);
     }
 
-  /* Destroy any values currently allocated now instead of leaving it
-     to global destructors, because that may be too late.  For
-     example, the destructors of xmethod values call into the Python
-     runtime, which is finalized via a final cleanup.  */
-  finalize_values ();
-
   /* Do any final cleanups before exiting.  */
   try
     {
index c7e940badb97bafbe06561838cc003a39ff272ec..a2b2721d183a181712a5690f5f873d7b68cc00f5 100644 (file)
@@ -4499,12 +4499,13 @@ and exceeds this limit will cause an error."),
                            selftests::test_insert_into_bit_range_vector);
   selftests::register_test ("value_copy", selftests::test_value_copy);
 #endif
-}
-
-/* See value.h.  */
 
-void
-finalize_values ()
-{
-  all_values.clear ();
+  /* Destroy any values currently allocated in a final cleanup instead
+     of leaving it to global destructors, because that may be too
+     late.  For example, the destructors of xmethod values call into
+     the Python runtime.  */
+  add_final_cleanup ([] ()
+    {
+      all_values.clear ();
+    });
 }
index e8d3c9fd907a56f43a58c876edb323d6bb17bf93..9d7e88d94334dd74b374430d6d8d721a5f35651f 100644 (file)
@@ -1630,10 +1630,6 @@ struct value *call_internal_function (struct gdbarch *gdbarch,
 
 const char *value_internal_function_name (struct value *);
 
-/* Destroy the values currently allocated.  This is called when GDB is
-   exiting (e.g., on quit_force).  */
-extern void finalize_values ();
-
 /* Convert VALUE to a gdb_mpq.  The caller must ensure that VALUE is
    of floating-point, fixed-point, or integer type.  */
 extern gdb_mpq value_to_gdb_mpq (struct value *value);