Skip to content

Commit 181dd79

Browse files
authored
Merge pull request #8617 from apple/jdevlieghere/cherrypick-2f343fc1574f36b3b5ff1acf63407c53dcdac331
[lldb] Print a message when background tasks take a while to complete…
2 parents 09f63ab + bafa348 commit 181dd79

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lldb/tools/driver/Driver.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <bitset>
3333
#include <clocale>
3434
#include <csignal>
35+
#include <future>
3536
#include <string>
3637
#include <thread>
3738
#include <utility>
@@ -821,6 +822,18 @@ int main(int argc, char const *argv[]) {
821822
}
822823
}
823824

824-
SBDebugger::Terminate();
825+
// When terminating the debugger we have to wait on all the background tasks
826+
// to complete, which can take a while. Print a message when this takes longer
827+
// than 1 second.
828+
{
829+
std::future<void> future =
830+
std::async(std::launch::async, []() { SBDebugger::Terminate(); });
831+
832+
if (future.wait_for(std::chrono::seconds(1)) == std::future_status::timeout)
833+
fprintf(stderr, "Waiting for background tasks to complete...\n");
834+
835+
future.wait();
836+
}
837+
825838
return exit_code;
826839
}

0 commit comments

Comments
 (0)