This revision was automatically updated to reflect the committed changes.
Closed by commit rL269025: Fix race in TestExitDuringStep and unify
pseudo_barrier handling (authored by labath).
Changed prior to commit:
http://reviews.llvm.org/D20065?vs=56567&id=56669#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20065
Files:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
+++ lldb/trunk/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;
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
@@ -23,22 +23,10 @@
#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;
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
+++ lldb/trunk/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;
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
+++ lldb/trunk/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 ()
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
+++ lldb/trunk/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;
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
+++ lldb/trunk/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 ()
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
+++ lldb/trunk/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 ()
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
+++ lldb/trunk/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;
Index: lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h
+++ lldb/trunk/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
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits