Author: Pavel Labath Date: 2022-02-09T16:18:27+01:00 New Revision: 9611282c64f4cec1d6d0d997202762fa38e99663
URL: https://github.com/llvm/llvm-project/commit/9611282c64f4cec1d6d0d997202762fa38e99663 DIFF: https://github.com/llvm/llvm-project/commit/9611282c64f4cec1d6d0d997202762fa38e99663.diff LOG: [lldb] Stabilize threaded windows lldb-server tests The tests enabled in 9e699595 are not passing reliably -- sometimes they report seeing fewer threads than expected. Based on my (limited) research, this is not a lldb bug, but simply a consequence of the operating system reporting their presence asynchronously -- they're reported when they are scheduled to run (or something similar), and not at the time of the CreateThread call. To fix this, I add some additional synchronization to the test inferior, which makes sure that the created thread is alive before continuing to do other things. Added: Modified: lldb/test/API/tools/lldb-server/main.cpp Removed: ################################################################################ diff --git a/lldb/test/API/tools/lldb-server/main.cpp b/lldb/test/API/tools/lldb-server/main.cpp index 59e921f312f43..0383acc68fccf 100644 --- a/lldb/test/API/tools/lldb-server/main.cpp +++ b/lldb/test/API/tools/lldb-server/main.cpp @@ -3,6 +3,7 @@ #include <cstdlib> #include <cstring> #include <errno.h> +#include <future> #include <inttypes.h> #include <memory> #include <mutex> @@ -158,7 +159,8 @@ static void hello() { printf("hello, world\n"); } -static void *thread_func(void *arg) { +static void *thread_func(std::promise<void> ready) { + ready.set_value(); static std::atomic<int> s_thread_index(1); const int this_thread_index = s_thread_index++; if (g_print_thread_ids) { @@ -328,7 +330,10 @@ int main(int argc, char **argv) { _exit(0); #endif } else if (consume_front(arg, "thread:new")) { - threads.push_back(std::thread(thread_func, nullptr)); + std::promise<void> promise; + std::future<void> ready = promise.get_future(); + threads.push_back(std::thread(thread_func, std::move(promise))); + ready.wait(); } else if (consume_front(arg, "thread:print-ids")) { // Turn on thread id announcing. g_print_thread_ids = true; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits