[llvm-commits] [compiler-rt] r172713 - in /compiler-rt/trunk/lib: asan/asan_interceptors.cc sanitizer_common/sanitizer_common_interceptors.h tsan/lit_tests/thread_name.cc tsan/rtl/tsan_interceptors.cc
Kostya Serebryany
kcc at google.com
Thu Jan 17 05:09:01 PST 2013
Author: kcc
Date: Thu Jan 17 07:09:00 2013
New Revision: 172713
URL: http://llvm.org/viewvc/llvm-project?rev=172713&view=rev
Log:
[sanitizer] a bit more unification for interceptors (merge read/pread/pread64 in asan and tsan)
Modified:
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h
compiler-rt/trunk/lib/tsan/lit_tests/thread_name.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=172713&r1=172712&r2=172713&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Thu Jan 17 07:09:00 2013
@@ -83,6 +83,8 @@
#define COMMON_INTERCEPTOR_WRITE_RANGE(ptr, size) ASAN_WRITE_RANGE(ptr, size)
#define COMMON_INTERCEPTOR_READ_RANGE(ptr, size) ASAN_READ_RANGE(ptr, size)
#define COMMON_INTERCEPTOR_ENTER(func, ...) ENSURE_ASAN_INITED()
+#define COMMON_INTERCEPTOR_FD_ACQUIRE(fd)
+#define COMMON_INTERCEPTOR_FD_RELEASE(fd)
#include "sanitizer_common/sanitizer_common_interceptors.h"
static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h?rev=172713&r1=172712&r2=172713&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h Thu Jan 17 07:09:00 2013
@@ -15,7 +15,8 @@
// COMMON_INTERCEPTOR_ENTER
// COMMON_INTERCEPTOR_READ_RANGE
// COMMON_INTERCEPTOR_WRITE_RANGE
-//
+// COMMON_INTERCEPTOR_FD_ACQUIRE
+// COMMON_INTERCEPTOR_FD_RELEASE
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_COMMON_INTERCEPTORS_H
#define SANITIZER_COMMON_INTERCEPTORS_H
@@ -29,6 +30,8 @@
SSIZE_T res = REAL(read)(fd, ptr, count);
if (res > 0)
COMMON_INTERCEPTOR_WRITE_RANGE(ptr, res);
+ if (res >= 0 && fd >= 0)
+ COMMON_INTERCEPTOR_FD_ACQUIRE(fd);
return res;
}
#endif
@@ -39,6 +42,8 @@
SSIZE_T res = REAL(pread)(fd, ptr, count, offset);
if (res > 0)
COMMON_INTERCEPTOR_WRITE_RANGE(ptr, res);
+ if (res >= 0 && fd >= 0)
+ COMMON_INTERCEPTOR_FD_ACQUIRE(fd);
return res;
}
#endif
@@ -49,6 +54,8 @@
SSIZE_T res = REAL(pread64)(fd, ptr, count, offset);
if (res > 0)
COMMON_INTERCEPTOR_WRITE_RANGE(ptr, res);
+ if (res >= 0 && fd >= 0)
+ COMMON_INTERCEPTOR_FD_ACQUIRE(fd);
return res;
}
#endif
Modified: compiler-rt/trunk/lib/tsan/lit_tests/thread_name.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/thread_name.cc?rev=172713&r1=172712&r2=172713&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/thread_name.cc (original)
+++ compiler-rt/trunk/lib/tsan/lit_tests/thread_name.cc Thu Jan 17 07:09:00 2013
@@ -16,6 +16,7 @@
void *Thread2(void *x) {
AnnotateThreadName(__FILE__, __LINE__, "Thread2");
+ // TODO: pthread_setname_np(pthread_self(), "Thread2");
Global--;
return NULL;
}
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=172713&r1=172712&r2=172713&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Thu Jan 17 07:09:00 2013
@@ -1241,33 +1241,6 @@
return res;
}
-TSAN_INTERCEPTOR(long_t, read, int fd, void *buf, long_t sz) {
- SCOPED_TSAN_INTERCEPTOR(read, fd, buf, sz);
- int res = REAL(read)(fd, buf, sz);
- if (res >= 0 && fd >= 0) {
- FdAcquire(thr, pc, fd);
- }
- return res;
-}
-
-TSAN_INTERCEPTOR(long_t, pread, int fd, void *buf, long_t sz, unsigned off) {
- SCOPED_TSAN_INTERCEPTOR(pread, fd, buf, sz, off);
- int res = REAL(pread)(fd, buf, sz, off);
- if (res >= 0 && fd >= 0) {
- FdAcquire(thr, pc, fd);
- }
- return res;
-}
-
-TSAN_INTERCEPTOR(long_t, pread64, int fd, void *buf, long_t sz, u64 off) {
- SCOPED_TSAN_INTERCEPTOR(pread64, fd, buf, sz, off);
- int res = REAL(pread64)(fd, buf, sz, off);
- if (res >= 0 && fd >= 0) {
- FdAcquire(thr, pc, fd);
- }
- return res;
-}
-
TSAN_INTERCEPTOR(long_t, readv, int fd, void *vec, int cnt) {
SCOPED_TSAN_INTERCEPTOR(readv, fd, vec, cnt);
int res = REAL(readv)(fd, vec, cnt);
@@ -1645,6 +1618,14 @@
return pid;
}
+#define COMMON_INTERCEPTOR_WRITE_RANGE(ptr, size) // FIXME
+#define COMMON_INTERCEPTOR_READ_RANGE(ptr, size) // FIXME
+#define COMMON_INTERCEPTOR_ENTER(func, ...) \
+ SCOPED_TSAN_INTERCEPTOR(func, __VA_ARGS__)
+#define COMMON_INTERCEPTOR_FD_ACQUIRE(fd) FdAcquire(thr, pc, fd)
+#define COMMON_INTERCEPTOR_FD_RELEASE(fd) FdRelease(thr, pc, fd)
+#include "sanitizer_common/sanitizer_common_interceptors.h"
+
namespace __tsan {
void ProcessPendingSignals(ThreadState *thr) {
@@ -1708,6 +1689,8 @@
REAL(memcpy) = internal_memcpy;
REAL(memcmp) = internal_memcmp;
+ SANITIZER_COMMON_INTERCEPTORS_INIT;
+
TSAN_INTERCEPT(longjmp);
TSAN_INTERCEPT(siglongjmp);
@@ -1811,9 +1794,6 @@
TSAN_INTERCEPT(pipe);
TSAN_INTERCEPT(pipe2);
- TSAN_INTERCEPT(read);
- TSAN_INTERCEPT(pread);
- TSAN_INTERCEPT(pread64);
TSAN_INTERCEPT(readv);
TSAN_INTERCEPT(preadv64);
TSAN_INTERCEPT(write);
More information about the llvm-commits
mailing list