diff options
Diffstat (limited to 'lldb/packages/Python')
9 files changed, 36 insertions, 105 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp index a63079524ee..f9f33fda82b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp @@ -19,24 +19,12 @@ volatile int g_test = 0; -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - // A barrier to synchronize all the threads. -std::atomic_int g_barrier1; +pseudo_barrier_t g_barrier1; // A barrier to keep the threads from exiting until after the breakpoint has // been passed. -std::atomic_int g_barrier2; +pseudo_barrier_t g_barrier2; void * break_thread_func () diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp index ac2535cd2bf..10b55bff3ba 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp @@ -23,22 +23,10 @@ using namespace std; #include <sys/types.h> #include <unistd.h> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - typedef std::vector<std::pair<unsigned, void*(*)(void*)> > action_counts; typedef std::vector<pthread_t> thread_vector; -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier; int g_breakpoint = 0; int g_sigusr1_count = 0; std::atomic_int g_watchme; diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp index 3a00248c022..70681fd1160 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp @@ -13,19 +13,9 @@ #include <atomic> #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. #define do_nothing() -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier; volatile int g_thread_created = 0; volatile int g_test = 0; diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp index 3570637207d..a032da835ea 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp @@ -19,27 +19,15 @@ volatile int g_test = 0; -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - // A barrier to synchronize all the threads except the one that will exit. -std::atomic_int g_barrier1; +pseudo_barrier_t g_barrier1; // A barrier to synchronize all the threads including the one that will exit. -std::atomic_int g_barrier2; +pseudo_barrier_t g_barrier2; // A barrier to keep the first group of threads from exiting until after the // breakpoint has been passed. -std::atomic_int g_barrier3; +pseudo_barrier_t g_barrier3; void * break_thread_func () diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp index d1b364b8baa..45adf28ce81 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp @@ -12,20 +12,10 @@ #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. #define do_nothing() -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - // A barrier to synchronize thread start. -volatile int g_barrier; +pseudo_barrier_t g_barrier; volatile int g_thread_exited = 0; diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp index 01f4b8f98ea..c3d695dbc74 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp @@ -15,19 +15,7 @@ #include <atomic> #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier; volatile int g_test = 0; diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp index b4c6216d6bf..31f9a1576b9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp @@ -13,19 +13,7 @@ #include <atomic> #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier; volatile int g_test = 0; diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp index e498db7895d..c57db9f4852 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp @@ -12,21 +12,9 @@ #include <atomic> #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ - --bar; \ - while (bar > 0) \ - do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier1; -std::atomic_int g_barrier2; -std::atomic_int g_barrier3; +pseudo_barrier_t g_barrier1; +pseudo_barrier_t g_barrier2; +pseudo_barrier_t g_barrier3; void * thread1 () diff --git a/lldb/packages/Python/lldbsuite/test/make/test_common.h b/lldb/packages/Python/lldbsuite/test/make/test_common.h index a1ed364574e..a002f9fa9a4 100644 --- a/lldb/packages/Python/lldbsuite/test/make/test_common.h +++ b/lldb/packages/Python/lldbsuite/test/make/test_common.h @@ -42,3 +42,26 @@ #define lldb_enable_attach() #endif + +#ifdef __cplusplus +#include <atomic> + +// Note that although hogging the CPU while waiting for a variable to change +// would be terrible in production code, it's great for testing since it +// avoids a lot of messy context switching to get multiple threads synchronized. + +typedef std::atomic<int> pseudo_barrier_t; +#define pseudo_barrier_wait(barrier) \ + do \ + { \ + --(barrier); \ + while ((barrier).load() > 0) \ + ; \ + } while (0) + +#define pseudo_barrier_init(barrier, count) \ + do \ + { \ + (barrier) = (count); \ + } while (0) +#endif // __cplusplus |