From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/5] Change finalize_values into a final cleanup
Date: Fri, 23 Feb 2024 14:11:39 -0700 [thread overview]
Message-ID: <20240223-final-cleanups-v1-3-84d5271e9979@adacore.com> (raw)
In-Reply-To: <20240223-final-cleanups-v1-0-84d5271e9979@adacore.com>
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 | 6 ------
gdb/value.c | 15 ++++++++-------
gdb/value.h | 4 ----
3 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/gdb/top.c b/gdb/top.c
index 67d6670cd9c..cf7d3a913ba 100644
--- 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
{
diff --git a/gdb/value.c b/gdb/value.c
index c7e940badb9..a2b2721d183 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -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 ();
+ });
}
diff --git a/gdb/value.h b/gdb/value.h
index e8d3c9fd907..9d7e88d9433 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -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);
--
2.43.0
next prev parent reply other threads:[~2024-02-23 21:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 21:11 [PATCH 0/5] Restore DAP 'quit' request Tom Tromey
2024-02-23 21:11 ` [PATCH 1/5] Rewrite final cleanups Tom Tromey
2024-02-25 22:30 ` Lancelot SIX
2024-02-26 18:53 ` Tom Tromey
2024-02-27 14:03 ` Lancelot SIX
2024-02-27 17:27 ` Tom Tromey
2024-02-27 17:36 ` Tom Tromey
2024-03-03 16:50 ` Lancelot SIX
2024-02-23 21:11 ` [PATCH 2/5] Add extension_language_ops::shutdown Tom Tromey
2024-02-23 21:11 ` Tom Tromey [this message]
2024-02-23 21:11 ` [PATCH 4/5] Add final cleanup for runnables Tom Tromey
2024-02-23 21:11 ` [PATCH 5/5] Explicitly quit gdb from DAP server thread Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240223-final-cleanups-v1-3-84d5271e9979@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).