summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChaoren Lin <chaorenl@google.com>2015-02-26 21:31:27 +0000
committerChaoren Lin <chaorenl@google.com>2015-02-26 21:31:27 +0000
commit3011680752a006d39335a9275813d38853f8bb46 (patch)
tree7077a22078c66a96be1797e515a3c0fc132e3e0e
parent7bd840d0586c75068e813149c2b7aa3605e63c67 (diff)
downloadbcm5719-llvm-3011680752a006d39335a9275813d38853f8bb46.tar.gz
bcm5719-llvm-3011680752a006d39335a9275813d38853f8bb46.zip
Add synchronization to TestWatchLocation.
Summary: There was no guarantee that the three threads haven't already exited by the time the watchpoint is set. Reviewers: ovyalov Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7916 llvm-svn: 230691
-rw-r--r--lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp b/lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp
index ef965715479..007f4c3b06e 100644
--- a/lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp
+++ b/lldb/test/functionalities/watchpoint/hello_watchlocation/main.cpp
@@ -18,6 +18,8 @@ pthread_t g_thread_1 = NULL;
pthread_t g_thread_2 = NULL;
pthread_t g_thread_3 = NULL;
+pthread_barrier_t g_barrier;
+
char *g_char_ptr = NULL;
void
@@ -52,6 +54,8 @@ thread_func (void *arg)
uint32_t thread_index = *((uint32_t *)arg);
printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index);
+ pthread_barrier_wait(&g_barrier);
+
uint32_t count = 0;
uint32_t val;
while (count++ < 15)
@@ -84,17 +88,23 @@ int main (int argc, char const *argv[])
g_char_ptr = (char *)malloc (1);
*g_char_ptr = 0;
+ pthread_barrier_init(&g_barrier, NULL, 4);
+
// Create 3 threads
err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1);
err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2);
err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3);
printf ("Before turning all three threads loose...\n"); // Set break point at this line.
+ pthread_barrier_wait(&g_barrier);
// Join all of our threads
err = ::pthread_join (g_thread_1, &thread_result);
err = ::pthread_join (g_thread_2, &thread_result);
err = ::pthread_join (g_thread_3, &thread_result);
+ pthread_barrier_destroy(&g_barrier);
+ free(g_char_ptr);
+
return 0;
}
OpenPOWER on IntegriCloud