[Lldb-commits] [PATCH] Fix hello_watchlocation test after r230691
Ilia K
ki.stfu at gmail.com
Thu Feb 26 23:03:49 PST 2015
Hi chaoren, clayborg, zturner, abidh,
pthread_barrier_t isn't supported on OS X therefore it causes a compilation failure
```
1: test_hello_watchlocation_with_dwarf (TestWatchLocation.HelloWatchLocationTestCase)
Test watching a location with '-x size' option. ...
os command: make clean EXE='test_hello_watchlocation_with_dwarf' CXX_SOURCES='main.cpp'; make MAKE_DSYM=NO ARCH=x86_64 CC="clang" EXE='test_hello_watchlocation_with_dwarf' CXX_SOURCES='main.cpp'
with pid: 90141
stdout: rm -f "test_hello_watchlocation_with_dwarf" main.o main.d main.d.tmp
rm -f -r "test_hello_watchlocation_with_dwarf.dSYM"
clang++ -std=c++11 -g -O0 -arch x86_64 -I/Users/IliaK/p/llvm/tools/lldb/test/make/../../include -c -o main.o main.cpp
stderr: main.cpp:21:1: error: unknown type name 'pthread_barrier_t'
pthread_barrier_t g_barrier;
^
1 error generated.
make: *** [main.o] Error 1
retcode: 2
ERROR
```
This patch uses pthread_mutex_t and pthread_cond_t which are standard.
This test works on OS X.
http://reviews.llvm.org/D7932
Files:
test/functionalities/watchpoint/hello_watchlocation/main.cpp
Index: test/functionalities/watchpoint/hello_watchlocation/main.cpp
===================================================================
--- test/functionalities/watchpoint/hello_watchlocation/main.cpp
+++ test/functionalities/watchpoint/hello_watchlocation/main.cpp
@@ -18,11 +18,24 @@
pthread_t g_thread_2 = NULL;
pthread_t g_thread_3 = NULL;
-pthread_barrier_t g_barrier;
+pthread_mutex_t g_mutex;
+pthread_cond_t g_cond;
+int g_count;
char *g_char_ptr = NULL;
void
+barrier_wait()
+{
+ pthread_mutex_lock(&g_mutex);
+ if (--g_count == 0)
+ pthread_cond_broadcast(&g_cond);
+ else
+ pthread_cond_wait(&g_cond, &g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+}
+
+void
do_bad_thing_with_location(char *char_ptr, char new_val)
{
unsigned what = new_val;
@@ -54,7 +67,7 @@
uint32_t thread_index = *((uint32_t *)arg);
printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index);
- pthread_barrier_wait(&g_barrier);
+ barrier_wait();
uint32_t count = 0;
uint32_t val;
@@ -88,22 +101,25 @@
g_char_ptr = (char *)malloc (1);
*g_char_ptr = 0;
- pthread_barrier_init(&g_barrier, NULL, 4);
+ pthread_mutex_init(&g_mutex, NULL);
+ pthread_cond_init(&g_cond, NULL);
+ g_count = 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);
+ barrier_wait();
// 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);
+ pthread_cond_destroy(&g_cond);
+ pthread_mutex_destroy(&g_mutex);
free(g_char_ptr);
return 0;
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7932.20828.patch
Type: text/x-patch
Size: 2060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150227/e2790463/attachment.bin>
More information about the lldb-commits
mailing list