Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/libsanitizer/tsan Sync chunks of tsan...



details:   https://anonhg.NetBSD.org/src/rev/8fb94b07b40c
branches:  trunk
changeset: 954881:8fb94b07b40c
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Sep 12 22:23:57 2020 +0000

description:
Sync chunks of tsan_interceptors.cc with LLVM rev. 74760bb00fb9b78a2fe122

Sync tsan_interceptors.cc with upstream file tsan_interceptors_posix.cpp.

Changes:
 - define fileno_unlocked() for NetBSD
 - use defined __sanitizer_FILE for NetBSD
 - handle symbol indirection for vfork and nanosleep
 - delete sem_* API, currently moved to common code with sanitizers
 - undef SANITIZER_INTERCEPT_PTHREAD_SIGMASK to fix build
 - remove locally introduced SANITIZER_NETBSD

With these changes, TSan for GCC builds.

diffstat:

 external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc |  77 +---------
 1 files changed, 10 insertions(+), 67 deletions(-)

diffs (125 lines):

diff -r 1bb671256ace -r 8fb94b07b40c external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc
--- a/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc     Sat Sep 12 22:12:17 2020 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc     Sat Sep 12 22:23:57 2020 +0000
@@ -40,17 +40,16 @@
 
 #if SANITIZER_NETBSD
 #define dirfd(dirp) (*(int *)(dirp))
-#define fileno_unlocked fileno
+#define fileno_unlocked(fp)              \
+  (((__sanitizer_FILE *)fp)->_file == -1 \
+       ? -1                              \
+       : (int)(unsigned short)(((__sanitizer_FILE *)fp)->_file))
 
-#if _LP64
-#define __sF_size 152
-#else
-#define __sF_size 88
-#endif
+#define stdout ((__sanitizer_FILE*)&__sF[1])
+#define stderr ((__sanitizer_FILE*)&__sF[2])
 
-#define stdout ((char*)&__sF + (__sF_size * 1))
-#define stderr ((char*)&__sF + (__sF_size * 2))
-
+#define nanosleep __nanosleep50
+#define vfork __vfork14
 #endif
 
 #if SANITIZER_ANDROID
@@ -92,8 +91,8 @@
 DECLARE_REAL_AND_INTERCEPTOR(void, free, void *ptr)
 extern "C" void *pthread_self();
 extern "C" void _exit(int status);
+#if !SANITIZER_NETBSD
 extern "C" int fileno_unlocked(void *stream);
-#if !SANITIZER_NETBSD
 extern "C" int dirfd(void *dirp);
 #endif
 #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_NETBSD
@@ -1417,61 +1416,6 @@
   return 0;
 }
 
-TSAN_INTERCEPTOR(int, sem_init, void *s, int pshared, unsigned value) {
-  SCOPED_TSAN_INTERCEPTOR(sem_init, s, pshared, value);
-  int res = REAL(sem_init)(s, pshared, value);
-  return res;
-}
-
-TSAN_INTERCEPTOR(int, sem_destroy, void *s) {
-  SCOPED_TSAN_INTERCEPTOR(sem_destroy, s);
-  int res = REAL(sem_destroy)(s);
-  return res;
-}
-
-TSAN_INTERCEPTOR(int, sem_wait, void *s) {
-  SCOPED_TSAN_INTERCEPTOR(sem_wait, s);
-  int res = BLOCK_REAL(sem_wait)(s);
-  if (res == 0) {
-    Acquire(thr, pc, (uptr)s);
-  }
-  return res;
-}
-
-TSAN_INTERCEPTOR(int, sem_trywait, void *s) {
-  SCOPED_TSAN_INTERCEPTOR(sem_trywait, s);
-  int res = BLOCK_REAL(sem_trywait)(s);
-  if (res == 0) {
-    Acquire(thr, pc, (uptr)s);
-  }
-  return res;
-}
-
-TSAN_INTERCEPTOR(int, sem_timedwait, void *s, void *abstime) {
-  SCOPED_TSAN_INTERCEPTOR(sem_timedwait, s, abstime);
-  int res = BLOCK_REAL(sem_timedwait)(s, abstime);
-  if (res == 0) {
-    Acquire(thr, pc, (uptr)s);
-  }
-  return res;
-}
-
-TSAN_INTERCEPTOR(int, sem_post, void *s) {
-  SCOPED_TSAN_INTERCEPTOR(sem_post, s);
-  Release(thr, pc, (uptr)s);
-  int res = REAL(sem_post)(s);
-  return res;
-}
-
-TSAN_INTERCEPTOR(int, sem_getvalue, void *s, int *sval) {
-  SCOPED_TSAN_INTERCEPTOR(sem_getvalue, s, sval);
-  int res = REAL(sem_getvalue)(s, sval);
-  if (res == 0) {
-    Acquire(thr, pc, (uptr)s);
-  }
-  return res;
-}
-
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
 TSAN_INTERCEPTOR(int, __fxstat, int version, int fd, void *buf) {
   SCOPED_TSAN_INTERCEPTOR(__fxstat, version, fd, buf);
@@ -2236,6 +2180,7 @@
 #define NEED_TLS_GET_ADDR
 #endif
 #undef SANITIZER_INTERCEPT_TLS_GET_ADDR
+#undef SANITIZER_INTERCEPT_PTHREAD_SIGMASK
 
 #define COMMON_INTERCEPT_FUNCTION(name) INTERCEPT_FUNCTION(name)
 #define COMMON_INTERCEPT_FUNCTION_VER(name, ver)                          \
@@ -2476,7 +2421,6 @@
   TSAN_SYSCALL();
   FdClose(thr, pc, fd);
 }
-#endif
 
 static USED void syscall_fd_acquire(uptr pc, int fd) {
   TSAN_SYSCALL();
@@ -2490,7 +2434,6 @@
   FdRelease(thr, pc, fd);
 }
 
-#if !SANITIZER_NETBSD
 static void syscall_pre_fork(uptr pc) {
   TSAN_SYSCALL();
   ForkBefore(thr, pc);



Home | Main Index | Thread Index | Old Index