[Lldb-commits] [lldb] 2f343fc - [lldb] Print a message when background tasks take a while to complete (#82799)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 5 12:04:37 PST 2024
Author: Jonas Devlieghere
Date: 2024-03-05T12:04:32-08:00
New Revision: 2f343fc1574f36b3b5ff1acf63407c53dcdac331
URL: https://github.com/llvm/llvm-project/commit/2f343fc1574f36b3b5ff1acf63407c53dcdac331
DIFF: https://github.com/llvm/llvm-project/commit/2f343fc1574f36b3b5ff1acf63407c53dcdac331.diff
LOG: [lldb] Print a message when background tasks take a while to complete (#82799)
When terminating the debugger, we wait for all background tasks to
complete. Given that there's no way to interrupt those treads, this can
take a while. When that happens, the debugger appears to hang at exit.
The above situation is unfortunately not uncommon when background
downloading of dSYMs is enabled (`symbols.auto-download background`).
Even when calling dsymForUUID with a reasonable timeout, it can take a
while to complete.
This patch improves the user experience by printing a message from the
driver when it takes more than one (1) second to terminate the debugger.
Added:
Modified:
lldb/tools/driver/Driver.cpp
Removed:
################################################################################
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 9286abb27e1332..a821699c5e2ec2 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -33,6 +33,7 @@
#include <bitset>
#include <clocale>
#include <csignal>
+#include <future>
#include <string>
#include <thread>
#include <utility>
@@ -801,6 +802,18 @@ int main(int argc, char const *argv[]) {
}
}
- SBDebugger::Terminate();
+ // When terminating the debugger we have to wait on all the background tasks
+ // to complete, which can take a while. Print a message when this takes longer
+ // than 1 second.
+ {
+ std::future<void> future =
+ std::async(std::launch::async, []() { SBDebugger::Terminate(); });
+
+ if (future.wait_for(std::chrono::seconds(1)) == std::future_status::timeout)
+ fprintf(stderr, "Waiting for background tasks to complete...\n");
+
+ future.wait();
+ }
+
return exit_code;
}
More information about the lldb-commits
mailing list