[llvm-commits] [compiler-rt] r172719 - in /compiler-rt/trunk/lib: asan/asan_intercepted_functions.h asan/asan_interceptors.cc sanitizer_common/sanitizer_common_interceptors.h sanitizer_common/sanitizer_platform_interceptors.h tsan/lit_tests/thread_name.cc tsan/rtl/tsan_interceptors.cc tsan/rtl/tsan_stat.cc tsan/rtl/tsan_stat.h

Anna Zaks ganna at apple.com
Thu Jan 17 11:30:52 PST 2013


Kostya,

I am getting a makefile build failure (looks like it's caused by this commit):

  COMPILE:   clang_darwin/asan_osx_dynamic/x86_64: /Volumes/Data/ws/llvmgit/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc
/Volumes/Data/ws/llvmgit/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:78:13: error: unused
      function 'SetThreadName' [-Werror,-Wunused-function]
/Volumes/Data/ws/llvmgit/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:78:13: static void SetThreadName(const char *name) {
error:             ^
unused
      function 'SetThreadName' [-Werror,-Wunused-function]
static void SetThreadName(const char *name) {
            ^
1 error generated.

On Jan 17, 2013, at 5:38 AM, Kostya Serebryany <kcc at google.com> wrote:

> Author: kcc
> Date: Thu Jan 17 07:38:16 2013
> New Revision: 172719
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=172719&view=rev
> Log:
> [tsan] move prctl interceptor from asan to common_interceptors thus enabling it for tsan too
> 
> Modified:
>    compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
>    compiler-rt/trunk/lib/asan/asan_interceptors.cc
>    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h
>    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
>    compiler-rt/trunk/lib/tsan/lit_tests/thread_name.cc
>    compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
>    compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
>    compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h
> 
> Modified: compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_intercepted_functions.h?rev=172719&r1=172718&r2=172719&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_intercepted_functions.h (original)
> +++ compiler-rt/trunk/lib/asan/asan_intercepted_functions.h Thu Jan 17 07:38:16 2013
> @@ -42,10 +42,8 @@
> 
> #if defined(__linux__)
> # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1
> -# define ASAN_INTERCEPT_PRCTL 1
> #else
> # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0
> -# define ASAN_INTERCEPT_PRCTL 0
> #endif
> 
> #if !defined(__APPLE__)
> 
> 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=172719&r1=172718&r2=172719&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Thu Jan 17 07:38:16 2013
> @@ -75,6 +75,12 @@
>   return internal_strnlen(s, maxlen);
> }
> 
> +static void SetThreadName(const char *name) {
> +  AsanThread *t = asanThreadRegistry().GetCurrent();
> +  if (t)
> +    t->summary()->set_name(name);
> +}
> +
> }  // namespace __asan
> 
> // ---------------------- Wrappers ---------------- {{{1
> @@ -83,8 +89,9 @@
> #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)
> +#define COMMON_INTERCEPTOR_FD_ACQUIRE(fd) do { } while (false)
> +#define COMMON_INTERCEPTOR_FD_RELEASE(fd) do { } while (false)
> +#define COMMON_INTERCEPTOR_SET_THREAD_NAME(name) SetThreadName(name)
> #include "sanitizer_common/sanitizer_common_interceptors.h"
> 
> static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
> @@ -166,25 +173,6 @@
> }
> #endif
> 
> -#if ASAN_INTERCEPT_PRCTL
> -#define PR_SET_NAME 15
> -INTERCEPTOR(int, prctl, int option,
> -            unsigned long arg2, unsigned long arg3,  // NOLINT
> -            unsigned long arg4, unsigned long arg5) {  // NOLINT
> -  int res = REAL(prctl(option, arg2, arg3, arg4, arg5));
> -  if (option == PR_SET_NAME) {
> -    AsanThread *t = asanThreadRegistry().GetCurrent();
> -    if (t) {
> -      char buff[17];
> -      internal_strncpy(buff, (char*)arg2, 16);
> -      buff[16] = 0;
> -      t->summary()->set_name(buff);
> -    }
> -  }
> -  return res;
> -}
> -#endif
> -
> #if ASAN_INTERCEPT___CXA_THROW
> INTERCEPTOR(void, __cxa_throw, void *a, void *b, void *c) {
>   CHECK(REAL(__cxa_throw));
> @@ -731,9 +719,6 @@
> #if ASAN_INTERCEPT_SIGLONGJMP
>   ASAN_INTERCEPT_FUNC(siglongjmp);
> #endif
> -#if ASAN_INTERCEPT_PRCTL
> -  ASAN_INTERCEPT_FUNC(prctl);
> -#endif
> 
>   // Intercept exception handling functions.
> #if ASAN_INTERCEPT___CXA_THROW
> 
> 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=172719&r1=172718&r2=172719&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:38:16 2013
> @@ -17,6 +17,7 @@
> //   COMMON_INTERCEPTOR_WRITE_RANGE
> //   COMMON_INTERCEPTOR_FD_ACQUIRE
> //   COMMON_INTERCEPTOR_FD_RELEASE
> +//   COMMON_INTERCEPTOR_SET_THREAD_NAME
> //===----------------------------------------------------------------------===//
> #ifndef SANITIZER_COMMON_INTERCEPTORS_H
> #define SANITIZER_COMMON_INTERCEPTORS_H
> @@ -34,6 +35,9 @@
>     COMMON_INTERCEPTOR_FD_ACQUIRE(fd);
>   return res;
> }
> +# define INIT_READ INTERCEPT_FUNCTION(read)
> +#else
> +# define INIT_READ
> #endif
> 
> #if SANITIZER_INTERCEPT_PREAD
> @@ -46,6 +50,9 @@
>     COMMON_INTERCEPTOR_FD_ACQUIRE(fd);
>   return res;
> }
> +# define INIT_PREAD INTERCEPT_FUNCTION(pread)
> +#else
> +# define INIT_PREAD
> #endif
> 
> #if SANITIZER_INTERCEPT_PREAD64
> @@ -58,29 +65,35 @@
>     COMMON_INTERCEPTOR_FD_ACQUIRE(fd);
>   return res;
> }
> -#endif
> -
> -#if SANITIZER_INTERCEPT_READ
> -# define INIT_READ INTERCEPT_FUNCTION(read)
> -#else
> -# define INIT_READ
> -#endif
> -
> -#if SANITIZER_INTERCEPT_PREAD
> -# define INIT_PREAD INTERCEPT_FUNCTION(pread)
> -#else
> -# define INIT_PREAD
> -#endif
> -
> -#if SANITIZER_INTERCEPT_PREAD64
> # define INIT_PREAD64 INTERCEPT_FUNCTION(pread64)
> #else
> # define INIT_PREAD64
> #endif
> 
> +#if SANITIZER_INTERCEPT_PRCTL
> +INTERCEPTOR(int, prctl, int option,
> +            unsigned long arg2, unsigned long arg3,  // NOLINT
> +            unsigned long arg4, unsigned long arg5) {  // NOLINT
> +  COMMON_INTERCEPTOR_ENTER(prctl, option, arg2, arg3, arg4, arg5);
> +  static const int PR_SET_NAME = 15;
> +  int res = REAL(prctl(option, arg2, arg3, arg4, arg5));
> +  if (option == PR_SET_NAME) {
> +    char buff[16];
> +    internal_strncpy(buff, (char*)arg2, 15);
> +    buff[15] = 0;
> +    COMMON_INTERCEPTOR_SET_THREAD_NAME(buff);
> +  }
> +  return res;
> +}
> +# define INIT_PRCTL INTERCEPT_FUNCTION(prctl)
> +#else
> +# define INIT_PRCTL
> +#endif  // SANITIZER_INTERCEPT_PRCTL
> +
> #define SANITIZER_COMMON_INTERCEPTORS_INIT \
>   INIT_READ;                               \
>   INIT_PREAD;                              \
>   INIT_PREAD64;                            \
> +  INIT_PRCTL;                              \
> 
> #endif  // SANITIZER_COMMON_INTERCEPTORS_H
> 
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=172719&r1=172718&r2=172719&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Thu Jan 17 07:38:16 2013
> @@ -24,7 +24,9 @@
> 
> #if defined(__linux__) && !defined(ANDROID)
> # define SANITIZER_INTERCEPT_PREAD64 1
> +# define SANITIZER_INTERCEPT_PRCTL 1
> #else
> +# define SANITIZER_INTERCEPT_PRCTL 0
> # define SANITIZER_INTERCEPT_PREAD64 0
> #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=172719&r1=172718&r2=172719&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:38:16 2013
> @@ -15,8 +15,7 @@
> }
> 
> void *Thread2(void *x) {
> -  AnnotateThreadName(__FILE__, __LINE__, "Thread2");
> -  // TODO: pthread_setname_np(pthread_self(), "Thread2");
> +  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=172719&r1=172718&r2=172719&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:38:16 2013
> @@ -1623,9 +1623,10 @@
> #define COMMON_INTERCEPTOR_READ_RANGE(ptr, size)  \
>     MemoryAccessRange(thr, pc, (uptr)ptr, size, false)
> #define COMMON_INTERCEPTOR_ENTER(func, ...) \
> - SCOPED_TSAN_INTERCEPTOR(func, __VA_ARGS__)
> +  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)
> +#define COMMON_INTERCEPTOR_SET_THREAD_NAME(name) ThreadSetName(thr, name)
> #include "sanitizer_common/sanitizer_common_interceptors.h"
> 
> namespace __tsan {
> 
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc?rev=172719&r1=172718&r2=172719&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc Thu Jan 17 07:38:16 2013
> @@ -204,6 +204,7 @@
>   name[StatInt_pipe]                     = "  pipe                            ";
>   name[StatInt_pipe2]                    = "  pipe2                           ";
>   name[StatInt_read]                     = "  read                            ";
> +  name[StatInt_prctl]                    = "  prctl                           ";
>   name[StatInt_pread]                    = "  pread                           ";
>   name[StatInt_pread64]                  = "  pread64                         ";
>   name[StatInt_readv]                    = "  readv                           ";
> 
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h?rev=172719&r1=172718&r2=172719&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h Thu Jan 17 07:38:16 2013
> @@ -199,6 +199,7 @@
>   StatInt_pipe,
>   StatInt_pipe2,
>   StatInt_read,
> +  StatInt_prctl,
>   StatInt_pread,
>   StatInt_pread64,
>   StatInt_readv,
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list