[compiler-rt] r202813 - tsan: move all pthread_cond interceptors into sanitizer_common
Dmitry Vyukov
dvyukov at google.com
Tue Mar 4 02:17:41 PST 2014
Author: dvyukov
Date: Tue Mar 4 04:17:40 2014
New Revision: 202813
URL: http://llvm.org/viewvc/llvm-project?rev=202813&view=rev
Log:
tsan: move all pthread_cond interceptors into sanitizer_common
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=202813&r1=202812&r2=202813&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Tue Mar 4 04:17:40 2014
@@ -2431,50 +2431,63 @@ INTERCEPTOR(int, pthread_mutex_unlock, v
#endif
#if SANITIZER_INTERCEPT_PTHREAD_COND
+INTERCEPTOR(int, pthread_cond_init, void *c, void *a) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, pthread_cond_init, c, a);
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, c, 1);
+ return REAL(pthread_cond_init)(c, a);
+}
+
INTERCEPTOR(int, pthread_cond_wait, void *c, void *m) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, pthread_cond_wait, c, m);
COMMON_INTERCEPTOR_MUTEX_UNLOCK(ctx, m);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, c, pthread_cond_t_sz);
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, c, 1);
int res = REAL(pthread_cond_wait)(c, m);
COMMON_INTERCEPTOR_MUTEX_LOCK(ctx, m);
return res;
}
-INTERCEPTOR(int, pthread_cond_init, void *c, void *a) {
+INTERCEPTOR(int, pthread_cond_timedwait, void *c, void *m, void *abstime) {
void *ctx;
- COMMON_INTERCEPTOR_ENTER(ctx, pthread_cond_init, c, a);
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, c, pthread_cond_t_sz);
- return REAL(pthread_cond_init)(c, a);
+ COMMON_INTERCEPTOR_ENTER(ctx, pthread_cond_timedwait, c, m, abstime);
+ COMMON_INTERCEPTOR_MUTEX_UNLOCK(ctx, m);
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, c, 1);
+ int res = REAL(pthread_cond_timedwait)(c, m, abstime);
+ COMMON_INTERCEPTOR_MUTEX_LOCK(ctx, m);
+ return res;
}
INTERCEPTOR(int, pthread_cond_signal, void *c) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, pthread_cond_signal, c);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, c, pthread_cond_t_sz);
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, c, 1);
return REAL(pthread_cond_signal)(c);
}
INTERCEPTOR(int, pthread_cond_broadcast, void *c) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, pthread_cond_broadcast, c);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, c, pthread_cond_t_sz);
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, c, 1);
return REAL(pthread_cond_broadcast)(c);
}
-#define INIT_PTHREAD_COND_WAIT \
- INTERCEPT_FUNCTION_VER(pthread_cond_wait, "GLIBC_2.3.2")
-#define INIT_PTHREAD_COND_INIT \
- INTERCEPT_FUNCTION_VER(pthread_cond_init, "GLIBC_2.3.2")
-#define INIT_PTHREAD_COND_SIGNAL \
- INTERCEPT_FUNCTION_VER(pthread_cond_signal, "GLIBC_2.3.2")
-#define INIT_PTHREAD_COND_BROADCAST \
- INTERCEPT_FUNCTION_VER(pthread_cond_broadcast, "GLIBC_2.3.2")
-#else
-#define INIT_PTHREAD_COND_WAIT
-#define INIT_PTHREAD_COND_INIT
-#define INIT_PTHREAD_COND_SIGNAL
-#define INIT_PTHREAD_COND_BROADCAST
+INTERCEPTOR(int, pthread_cond_destroy, void *c) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, pthread_cond_destroy, c);
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, c, 1);
+ return REAL(pthread_cond_destroy)(c);
+}
+
+#define INIT_PTHREAD_COND \
+ INTERCEPT_FUNCTION_VER(pthread_cond_init, "GLIBC_2.3.2"); \
+ INTERCEPT_FUNCTION_VER(pthread_cond_signal, "GLIBC_2.3.2"); \
+ INTERCEPT_FUNCTION_VER(pthread_cond_broadcast, "GLIBC_2.3.2"); \
+ INTERCEPT_FUNCTION_VER(pthread_cond_wait, "GLIBC_2.3.2"); \
+ INTERCEPT_FUNCTION_VER(pthread_cond_timedwait, "GLIBC_2.3.2"); \
+ INTERCEPT_FUNCTION_VER(pthread_cond_destroy, "GLIBC_2.3.2")
+#else
+#define INIT_PTHREAD_COND
#endif
#if SANITIZER_INTERCEPT_GETMNTENT || SANITIZER_INTERCEPT_GETMNTENT_R
@@ -3385,10 +3398,7 @@ INTERCEPTOR(int, capset, void *hdrp, con
INIT__EXIT; \
INIT_PTHREAD_MUTEX_LOCK; \
INIT_PTHREAD_MUTEX_UNLOCK; \
- INIT_PTHREAD_COND_WAIT; \
- INIT_PTHREAD_COND_INIT; \
- INIT_PTHREAD_COND_SIGNAL; \
- INIT_PTHREAD_COND_BROADCAST; \
+ INIT_PTHREAD_COND; \
INIT_GETMNTENT; \
INIT_GETMNTENT_R; \
INIT_STATFS; \
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=202813&r1=202812&r2=202813&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Tue Mar 4 04:17:40 2014
@@ -1095,23 +1095,6 @@ TSAN_INTERCEPTOR(int, pthread_rwlock_unl
return res;
}
-TSAN_INTERCEPTOR(int, pthread_cond_destroy, void *c) {
- SCOPED_TSAN_INTERCEPTOR(pthread_cond_destroy, c);
- MemoryWrite(thr, pc, (uptr)c, kSizeLog1);
- int res = REAL(pthread_cond_destroy)(c);
- return res;
-}
-
-TSAN_INTERCEPTOR(int, pthread_cond_timedwait, void *c, void *m,
- void *abstime) {
- SCOPED_TSAN_INTERCEPTOR(pthread_cond_timedwait, c, m, abstime);
- MutexUnlock(thr, pc, (uptr)m);
- MemoryRead(thr, pc, (uptr)c, kSizeLog1);
- int res = REAL(pthread_cond_timedwait)(c, m, abstime);
- MutexLock(thr, pc, (uptr)m);
- return res;
-}
-
TSAN_INTERCEPTOR(int, pthread_barrier_init, void *b, void *a, unsigned count) {
SCOPED_TSAN_INTERCEPTOR(pthread_barrier_init, b, a, count);
MemoryWrite(thr, pc, (uptr)b, kSizeLog1);
@@ -2216,9 +2199,6 @@ void InitializeInterceptors() {
TSAN_INTERCEPT(pthread_rwlock_timedwrlock);
TSAN_INTERCEPT(pthread_rwlock_unlock);
- INTERCEPT_FUNCTION_VER(pthread_cond_destroy, "GLIBC_2.3.2");
- INTERCEPT_FUNCTION_VER(pthread_cond_timedwait, "GLIBC_2.3.2");
-
TSAN_INTERCEPT(pthread_barrier_init);
TSAN_INTERCEPT(pthread_barrier_destroy);
TSAN_INTERCEPT(pthread_barrier_wait);
More information about the llvm-commits
mailing list