[Lldb-commits] [PATCH] D131407: [lldb] Flush the global thread pool in Debugger::Terminate
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 15 17:57:44 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d36a82d0a3d: [lldb] Flush the global thread pool in Debugger::Terminate (authored by JDevlieghere).
Herald added a project: LLDB.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131407/new/
https://reviews.llvm.org/D131407
Files:
lldb/source/Core/Debugger.cpp
Index: lldb/source/Core/Debugger.cpp
===================================================================
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -104,6 +104,7 @@
nullptr; // NOTE: intentional leak to avoid issues with C++ destructor chain
static DebuggerList *g_debugger_list_ptr =
nullptr; // NOTE: intentional leak to avoid issues with C++ destructor chain
+static llvm::ThreadPool *g_thread_pool = nullptr;
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = {
{
@@ -538,6 +539,7 @@
"Debugger::Initialize called more than once!");
g_debugger_list_mutex_ptr = new std::recursive_mutex();
g_debugger_list_ptr = new DebuggerList();
+ g_thread_pool = new llvm::ThreadPool(llvm::optimal_concurrency());
g_load_plugin_callback = load_plugin_callback;
}
@@ -545,6 +547,11 @@
assert(g_debugger_list_ptr &&
"Debugger::Terminate called without a matching Debugger::Initialize!");
+ if (g_thread_pool) {
+ // The destructor will wait for all the threads to complete.
+ delete g_thread_pool;
+ }
+
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
// Clear our global list of debugger objects
{
@@ -2005,11 +2012,7 @@
}
llvm::ThreadPool &Debugger::GetThreadPool() {
- // NOTE: intentional leak to avoid issues with C++ destructor chain
- static llvm::ThreadPool *g_thread_pool = nullptr;
- static llvm::once_flag g_once_flag;
- llvm::call_once(g_once_flag, []() {
- g_thread_pool = new llvm::ThreadPool(llvm::optimal_concurrency());
- });
+ assert(g_thread_pool &&
+ "Debugger::GetThreadPool called before Debugger::Initialize");
return *g_thread_pool;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131407.452860.patch
Type: text/x-patch
Size: 1709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220816/c9dd97f9/attachment.bin>
More information about the lldb-commits
mailing list