[llvm-commits] [compiler-rt] r159294 - in /compiler-rt/trunk/lib: sanitizer_common/sanitizer_internal_defs.h tsan/rtl/tsan_defs.h tsan/rtl/tsan_flags.cc tsan/rtl/tsan_interceptors.cc tsan/rtl/tsan_md5.cc tsan/rtl/tsan_rtl_report.cc tsan/rtl/tsan_
Alexey Samsonov
samsonov at google.com
Thu Jun 28 00:23:53 PDT 2012
Looks like this breaks our buildbot (attaching logs from running "make -f
Makefile.old presubmit" locally):
clang++ unit_tests/tsan_clock_test.o unit_tests/tsan_flags_test.o
unit_tests/tsan_mman_test.o unit_tests/tsan_mutex_test.o
unit_tests/tsan_platform_test.o unit_tests/tsan_printf_test.o
unit_tests/tsan_shadow_test.o unit_tests/tsan_suppressions_test.o
unit_tests/tsan_sync_test.o unit_tests/tsan_vector_test.o
rtl_tests/tsan_bench.o rtl_tests/tsan_mop.o rtl_tests/tsan_mutex.o
rtl_tests/tsan_posix.o rtl_tests/tsan_string.o rtl_tests/tsan_test.o
rtl_tests/tsan_test_util_linux.o rtl_tests/tsan_thread.o
../sanitizer_common/tests/sanitizer_allocator64_test.o
../sanitizer_common/tests/sanitizer_allocator_test.o rtl/libtsan.a
third_party/googletest/build/gtest-all.o -o tsan_test -ldl -lpthread -pie
rtl_tests/tsan_test_util_linux.o: In function
`ScopedThread::Impl::HandleEvent(Event*)':
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/rtl_tests/tsan_test_util_linux.cc:304:
undefined reference to `__interceptor_memcpy'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/rtl_tests/tsan_test_util_linux.cc:307:
undefined reference to `__interceptor_memset'
rtl/libtsan.a(tsan_interceptors.o): In function
`__tsan::intercept_memset(unsigned long, void*, int, unsigned long)':
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:384:
undefined reference to `__interception::real_memset'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:385:
undefined reference to `__interception::real_memset'
rtl/libtsan.a(tsan_interceptors.o): In function
`__tsan::intercept_memcpy(unsigned long, void*, void const*, unsigned
long)':
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:390:
undefined reference to `__interception::real_memcpy'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:392:
undefined reference to `__interception::real_memcpy'
rtl/libtsan.a(tsan_interceptors.o): In function
`__tsan::intercept_memcmp(unsigned long, void const*, void const*, unsigned
long)':
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:397:
undefined reference to `__interception::real_memcmp'
rtl/libtsan.a(tsan_interceptors.o): In function `__interceptor_signal':
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1345:
undefined reference to `__interception::real_memset'
rtl/libtsan.a(tsan_interceptors.o): In function
`__tsan::InitializeInterceptors()':
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1457:
undefined reference to `__interception::real_memcpy'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1457:
undefined reference to `__interception::real_memset'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1488:
undefined reference to `__interception::real_memset'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1488:
undefined reference to `__interceptor_memset'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1489:
undefined reference to `__interception::real_memcpy'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1489:
undefined reference to `__interceptor_memcpy'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1494:
undefined reference to `__interception::real_memcmp'
/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1494:
undefined reference to `__interceptor_memcmp'
On Thu, Jun 28, 2012 at 1:00 AM, Dmitry Vyukov <dvyukov at google.com> wrote:
> Author: dvyukov
> Date: Wed Jun 27 16:00:23 2012
> New Revision: 159294
>
> URL: http://llvm.org/viewvc/llvm-project?rev=159294&view=rev
> Log:
> tsan: prevent insertion of unwanted memset/memcpy/memcmp into runtime
>
> Modified:
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
> compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
> compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
> compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
> compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc
> compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
> compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
> compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
> compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
> compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h
> compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc
> compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
> (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h Wed
> Jun 27 16:00:23 2012
> @@ -26,6 +26,7 @@
> // Platform-specific defs.
> #if defined(_WIN32)
> typedef unsigned long DWORD; // NOLINT
> +# define ALWAYS_INLINE __declspec(forceinline)
> // FIXME(timurrrr): do we need this on Windows?
> # define ALIAS(x)
> # define ALIGNED(x) __declspec(align(x))
> @@ -33,18 +34,24 @@
> # define NOINLINE __declspec(noinline)
> # define NORETURN __declspec(noreturn)
> # define THREADLOCAL __declspec(thread)
> +# define NOTHROW
> #else // _WIN32
> +# define ALWAYS_INLINE __attribute__((always_inline))
> # define ALIAS(x) __attribute__((alias(x)))
> # define ALIGNED(x) __attribute__((aligned(x)))
> # define FORMAT(f, a) __attribute__((format(printf, f, a)))
> # define NOINLINE __attribute__((noinline))
> # define NORETURN __attribute__((noreturn))
> # define THREADLOCAL __thread
> +# ifdef __cplusplus
> +# define NOTHROW throw()
> +# else
> +# define NOTHROW __attribute__((__nothrow__))
> +#endif
> #endif // _WIN32
>
> // We have no equivalent of these on Windows.
> #ifndef _WIN32
> -# define ALWAYS_INLINE __attribute__((always_inline))
> # define LIKELY(x) __builtin_expect(!!(x), 1)
> # define UNLIKELY(x) __builtin_expect(!!(x), 0)
> # define UNUSED __attribute__((unused))
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h Wed Jun 27 16:00:23 2012
> @@ -14,7 +14,6 @@
> #ifndef TSAN_DEFS_H
> #define TSAN_DEFS_H
>
> -#include "interception/interception.h"
> #include "sanitizer_common/sanitizer_internal_defs.h"
> #include "sanitizer_common/sanitizer_libc.h"
> #include "tsan_stat.h"
> @@ -155,9 +154,29 @@
>
> } // namespace __tsan
>
> -DECLARE_REAL(void*, memset, void *ptr, int v, uptr size);
> -DECLARE_REAL(void*, memcpy, void *dst, const void *src, uptr size);
> -DECLARE_REAL(int, strncmp, const char *s1, const char *s2, uptr n);
> -DECLARE_REAL(const char*, strstr, const char *s1, const char *s2);
> +extern "C" inline void *ALWAYS_INLINE
> +memset(void *ptr, int v, uptr size) NOTHROW {
> + for (uptr i = 0; i < size; i++)
> + ((char*)ptr)[i] = (char)v;
> + return ptr;
> +}
> +
> +extern "C" inline void *ALWAYS_INLINE
> +memcpy(void *dst, const void *src, uptr size) NOTHROW {
> + for (uptr i = 0; i < size; i++)
> + ((char*)dst)[i] = ((char*)src)[i];
> + return dst;
> +}
> +
> +extern "C" inline int ALWAYS_INLINE
> +memcmp(const void *p1, const void *p2, uptr size) NOTHROW {
> + for (uptr i = 0; i < size; i++) {
> + if (((unsigned char*)p1)[i] < ((unsigned char*)p2)[i])
> + return -1;
> + if (((unsigned char*)p1)[i] > ((unsigned char*)p2)[i])
> + return 1;
> + }
> + return 0;
> +}
>
> #endif // TSAN_DEFS_H
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc Wed Jun 27 16:00:23 2012
> @@ -32,7 +32,7 @@
> }
>
> void InitializeFlags(Flags *f, const char *env) {
> - REAL(memset)(f, 0, sizeof(*f));
> + internal_memset(f, 0, sizeof(*f));
>
> // Default values.
> f->enable_annotations = true;
> @@ -78,7 +78,7 @@
> const char **end) {
> if (env == 0)
> return *end = 0;
> - const char *pos = REAL(strstr)(env, name);
> + const char *pos = internal_strstr(env, name);
> if (pos == 0)
> return *end = 0;
> pos += internal_strlen(name);
> @@ -139,7 +139,7 @@
> return;
> int len = end - val;
> char *f = (char*)internal_alloc(MBlockFlag, len + 1);
> - REAL(memcpy)(f, val, len);
> + internal_memcpy(f, val, len);
> f[len] = 0;
> *flag = f;
> }
>
> 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=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Wed Jun 27
> 16:00:23 2012
> @@ -172,6 +172,17 @@
> return REAL(func)(__VA_ARGS__); \
> /**/
>
> +#define SCOPED_INTERCEPTOR_LIBC(func, ...) \
> + ThreadState *thr = cur_thread(); \
> + StatInc(thr, StatInterceptor); \
> + StatInc(thr, StatInt_##func); \
> + ScopedInterceptor si(thr, #func, callpc); \
> + const uptr pc = (uptr)&func; \
> + (void)pc; \
> + if (thr->in_rtl > 1) \
> + return REAL(func)(__VA_ARGS__); \
> +/**/
> +
> #define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func,
> __VA_ARGS__)
> #define TSAN_INTERCEPT(func) INTERCEPT_FUNCTION(func)
>
> @@ -321,7 +332,7 @@
> {
> SCOPED_INTERCEPTOR_RAW(calloc, size, n);
> p = user_alloc(thr, pc, n * size);
> - REAL(memset)(p, 0, n * size);
> + internal_memset(p, 0, n * size);
> }
> invoke_malloc_hook(p, n * size);
> return p;
> @@ -354,26 +365,48 @@
> user_free(thr, pc, p);
> }
>
> -TSAN_INTERCEPTOR(uptr, strlen, const void *s) {
> +TSAN_INTERCEPTOR(uptr, strlen, const char *s) {
> SCOPED_TSAN_INTERCEPTOR(strlen, s);
> - uptr len = REAL(strlen)(s);
> + uptr len = internal_strlen(s);
> MemoryAccessRange(thr, pc, (uptr)s, len + 1, false);
> return len;
> }
>
> -TSAN_INTERCEPTOR(void*, memset, void *dst, int v, uptr size) {
> - SCOPED_TSAN_INTERCEPTOR(memset, dst, v, size);
> +DECLARE_REAL(void*, memset, void *dst, int v, uptr size);
> +DECLARE_REAL(void*, memcpy, void *dst, const void *src, uptr size);
> +DECLARE_REAL(int, memcmp, const void *s1, const void *s2, uptr n);
> +extern "C" void *__interceptor_memset(void *dst, int v, uptr size);
> +extern "C" void *__interceptor_memcpy(void *dst, const void *src, uptr
> size);
> +extern "C" int __interceptor_memcmp(const void *s1, const void *s2, uptr
> n);
> +
> +namespace __tsan {
> +void *intercept_memset(uptr callpc, void *dst, int v, uptr size) {
> + SCOPED_INTERCEPTOR_LIBC(memset, dst, v, size);
> MemoryAccessRange(thr, pc, (uptr)dst, size, true);
> return REAL(memset)(dst, v, size);
> }
>
> -TSAN_INTERCEPTOR(void*, memcpy, void *dst, const void *src, uptr size) {
> - SCOPED_TSAN_INTERCEPTOR(memcpy, dst, src, size);
> +void *intercept_memcpy(uptr callpc, void *dst, const void *src, uptr
> size) {
> + SCOPED_INTERCEPTOR_LIBC(memcpy, dst, src, size);
> MemoryAccessRange(thr, pc, (uptr)dst, size, true);
> MemoryAccessRange(thr, pc, (uptr)src, size, false);
> return REAL(memcpy)(dst, src, size);
> }
>
> +int intercept_memcmp(uptr callpc, const void *s1, const void *s2, uptr n)
> {
> + SCOPED_INTERCEPTOR_LIBC(memcmp, s1, s2, n);
> + int res = 0;
> + uptr len = 0;
> + for (; len < n; len++) {
> + if ((res = ((unsigned char*)s1)[len] - ((unsigned char*)s2)[len]))
> + break;
> + }
> + MemoryAccessRange(thr, pc, (uptr)s1, len < n ? len + 1 : n, false);
> + MemoryAccessRange(thr, pc, (uptr)s2, len < n ? len + 1 : n, false);
> + return res;
> +}
> +}
> +
> TSAN_INTERCEPTOR(int, strcmp, const char *s1, const char *s2) {
> SCOPED_TSAN_INTERCEPTOR(strcmp, s1, s2);
> uptr len = 0;
> @@ -419,52 +452,39 @@
> return REAL(memmove)(dst, src, n);
> }
>
> -TSAN_INTERCEPTOR(int, memcmp, const void *s1, const void *s2, uptr n) {
> - SCOPED_TSAN_INTERCEPTOR(memcmp, s1, s2, n);
> - int res = 0;
> - uptr len = 0;
> - for (; len < n; len++) {
> - if ((res = ((unsigned char*)s1)[len] - ((unsigned char*)s2)[len]))
> - break;
> - }
> - MemoryAccessRange(thr, pc, (uptr)s1, len < n ? len + 1 : n, false);
> - MemoryAccessRange(thr, pc, (uptr)s2, len < n ? len + 1 : n, false);
> - return res;
> -}
> -
> -TSAN_INTERCEPTOR(void*, strchr, void *s, int c) {
> +TSAN_INTERCEPTOR(char*, strchr, char *s, int c) {
> SCOPED_TSAN_INTERCEPTOR(strchr, s, c);
> - void *res = REAL(strchr)(s, c);
> - uptr len = res ? (char*)res - (char*)s + 1 : REAL(strlen)(s) + 1;
> + char *res = REAL(strchr)(s, c);
> + uptr len = res ? (char*)res - (char*)s + 1 : internal_strlen(s) + 1;
> MemoryAccessRange(thr, pc, (uptr)s, len, false);
> return res;
> }
>
> -TSAN_INTERCEPTOR(void*, strchrnul, void *s, int c) {
> +TSAN_INTERCEPTOR(char*, strchrnul, char *s, int c) {
> SCOPED_TSAN_INTERCEPTOR(strchrnul, s, c);
> - void *res = REAL(strchrnul)(s, c);
> + char *res = REAL(strchrnul)(s, c);
> uptr len = (char*)res - (char*)s + 1;
> MemoryAccessRange(thr, pc, (uptr)s, len, false);
> return res;
> }
>
> -TSAN_INTERCEPTOR(void*, strrchr, void *s, int c) {
> +TSAN_INTERCEPTOR(char*, strrchr, char *s, int c) {
> SCOPED_TSAN_INTERCEPTOR(strrchr, s, c);
> - MemoryAccessRange(thr, pc, (uptr)s, REAL(strlen)(s) + 1, false);
> + MemoryAccessRange(thr, pc, (uptr)s, internal_strlen(s) + 1, false);
> return REAL(strrchr)(s, c);
> }
>
> -TSAN_INTERCEPTOR(void*, strcpy, void *dst, const void *src) { // NOLINT
> +TSAN_INTERCEPTOR(char*, strcpy, char *dst, const char *src) { // NOLINT
> SCOPED_TSAN_INTERCEPTOR(strcpy, dst, src); // NOLINT
> - uptr srclen = REAL(strlen)(src);
> + uptr srclen = internal_strlen(src);
> MemoryAccessRange(thr, pc, (uptr)dst, srclen + 1, true);
> MemoryAccessRange(thr, pc, (uptr)src, srclen + 1, false);
> return REAL(strcpy)(dst, src); // NOLINT
> }
>
> -TSAN_INTERCEPTOR(void*, strncpy, void *dst, void *src, uptr n) {
> +TSAN_INTERCEPTOR(char*, strncpy, char *dst, char *src, uptr n) {
> SCOPED_TSAN_INTERCEPTOR(strncpy, dst, src, n);
> - uptr srclen = REAL(strlen)(src);
> + uptr srclen = internal_strlen(src);
> MemoryAccessRange(thr, pc, (uptr)dst, n, true);
> MemoryAccessRange(thr, pc, (uptr)src, min(srclen + 1, n), false);
> return REAL(strncpy)(dst, src, n);
> @@ -473,8 +493,8 @@
> TSAN_INTERCEPTOR(const char*, strstr, const char *s1, const char *s2) {
> SCOPED_TSAN_INTERCEPTOR(strstr, s1, s2);
> const char *res = REAL(strstr)(s1, s2);
> - uptr len1 = REAL(strlen)(s1);
> - uptr len2 = REAL(strlen)(s2);
> + uptr len1 = internal_strlen(s1);
> + uptr len2 = internal_strlen(s2);
> MemoryAccessRange(thr, pc, (uptr)s1, len1 + 1, false);
> MemoryAccessRange(thr, pc, (uptr)s2, len2 + 1, false);
> return res;
> @@ -1224,7 +1244,7 @@
>
> TSAN_INTERCEPTOR(int, puts, const char *s) {
> SCOPED_TSAN_INTERCEPTOR(puts, s);
> - MemoryAccessRange(thr, pc, (uptr)s, REAL(strlen)(s), false);
> + MemoryAccessRange(thr, pc, (uptr)s, internal_strlen(s), false);
> return REAL(puts)(s);
> }
>
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc Wed Jun 27 16:00:23 2012
> @@ -166,11 +166,11 @@
> free = 64 - used;
>
> if (size < free) {
> - REAL(memcpy)(&ctx->buffer[used], data, size);
> + internal_memcpy(&ctx->buffer[used], data, size);
> return;
> }
>
> - REAL(memcpy)(&ctx->buffer[used], data, free);
> + internal_memcpy(&ctx->buffer[used], data, free);
> data = (unsigned char *)data + free;
> size -= free;
> body(ctx, ctx->buffer, 64);
> @@ -181,7 +181,7 @@
> size &= 0x3f;
> }
>
> - REAL(memcpy)(ctx->buffer, data, size);
> + internal_memcpy(ctx->buffer, data, size);
> }
>
> void MD5_Final(unsigned char *result, MD5_CTX *ctx) {
> @@ -194,13 +194,13 @@
> free = 64 - used;
>
> if (free < 8) {
> - REAL(memset)(&ctx->buffer[used], 0, free);
> + internal_memset(&ctx->buffer[used], 0, free);
> body(ctx, ctx->buffer, 64);
> used = 0;
> free = 64;
> }
>
> - REAL(memset)(&ctx->buffer[used], 0, free - 8);
> + internal_memset(&ctx->buffer[used], 0, free - 8);
>
> ctx->lo <<= 3;
> ctx->buffer[56] = ctx->lo;
> @@ -231,7 +231,7 @@
> result[14] = ctx->d >> 16;
> result[15] = ctx->d >> 24;
>
> - REAL(memset)(ctx, 0, sizeof(*ctx));
> + internal_memset(ctx, 0, sizeof(*ctx));
> }
>
> MD5Hash md5_hash(const void *data, uptr size) {
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Wed Jun 27 16:00:23
> 2012
> @@ -50,9 +50,9 @@
> const char *path_prefix = flags()->strip_path_prefix;
> uptr path_prefix_len = internal_strlen(path_prefix);
> for (ReportStack *ent = stack; ent; ent = ent->next) {
> - if (ent->func && 0 == REAL(strncmp)(ent->func, prefix, prefix_len))
> + if (ent->func && 0 == internal_strncmp(ent->func, prefix, prefix_len))
> ent->func += prefix_len;
> - if (ent->file && 0 == REAL(strncmp)(ent->file, path_prefix,
> + if (ent->file && 0 == internal_strncmp(ent->file, path_prefix,
> path_prefix_len))
> ent->file += path_prefix_len;
> if (ent->file && ent->file[0] == '.' && ent->file[1] == '/')
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Wed Jun 27 16:00:23
> 2012
> @@ -212,7 +212,7 @@
> // Save from info about the thread.
> tctx->dead_info = new(internal_alloc(MBlockDeadInfo,
> sizeof(ThreadDeadInfo)))
> ThreadDeadInfo();
> - REAL(memcpy)(&tctx->dead_info->trace.events[0],
> + internal_memcpy(&tctx->dead_info->trace.events[0],
> &thr->trace.events[0], sizeof(thr->trace.events));
> for (int i = 0; i < kTraceParts; i++) {
> tctx->dead_info->trace.headers[i].stack0.CopyFrom(
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc Wed Jun 27
> 16:00:23 2012
> @@ -69,7 +69,7 @@
> tpos = (char*)internal_strchr(templ, '*');
> if (tpos != 0)
> tpos[0] = 0;
> - spos = REAL(strstr)(str, templ);
> + spos = internal_strstr(str, templ);
> str = spos + internal_strlen(templ);
> templ = tpos;
> if (tpos)
> @@ -94,18 +94,18 @@
> while (line != end2 && (end2[-1] == ' ' || end2[-1] == '\t'))
> end2--;
> SuppressionType stype;
> - if (0 == REAL(strncmp)(line, "race:", sizeof("race:") - 1)) {
> + if (0 == internal_strncmp(line, "race:", sizeof("race:") - 1)) {
> stype = SuppressionRace;
> line += sizeof("race:") - 1;
> - } else if (0 == REAL(strncmp)(line, "thread:",
> + } else if (0 == internal_strncmp(line, "thread:",
> sizeof("thread:") - 1)) {
> stype = SuppressionThread;
> line += sizeof("thread:") - 1;
> - } else if (0 == REAL(strncmp)(line, "mutex:",
> + } else if (0 == internal_strncmp(line, "mutex:",
> sizeof("mutex:") - 1)) {
> stype = SuppressionMutex;
> line += sizeof("mutex:") - 1;
> - } else if (0 == REAL(strncmp)(line, "signal:",
> + } else if (0 == internal_strncmp(line, "signal:",
> sizeof("signal:") - 1)) {
> stype = SuppressionSignal;
> line += sizeof("signal:") - 1;
> @@ -119,7 +119,7 @@
> head = s;
> s->type = stype;
> s->templ = (char*)internal_alloc(MBlockSuppression, end2 - line + 1);
> - REAL(memcpy)(s->templ, line, end2 - line);
> + internal_memcpy(s->templ, line, end2 - line);
> s->templ[end2 - line] = 0;
> }
> if (end[0] == 0)
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
> (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc Wed
> Jun 27 16:00:23 2012
> @@ -149,7 +149,7 @@
> static ReportStack *NewFrame(uptr addr) {
> ReportStack *ent = (ReportStack*)internal_alloc(MBlockReportStack,
> sizeof(ReportStack));
> - REAL(memset)(ent, 0, sizeof(*ent));
> + internal_memset(ent, 0, sizeof(*ent));
> ent->pc = addr;
> return ent;
> }
> @@ -181,12 +181,12 @@
> char *pos = (char*)internal_strchr(func, '\n');
> if (pos && func[0] != '?') {
> res->func = (char*)internal_alloc(MBlockReportStack, pos - func + 1);
> - REAL(memcpy)(res->func, func, pos - func);
> + internal_memcpy(res->func, func, pos - func);
> res->func[pos - func] = 0;
> char *pos2 = (char*)internal_strchr(pos, ':');
> if (pos2) {
> res->file = (char*)internal_alloc(MBlockReportStack, pos2 - pos - 1
> + 1);
> - REAL(memcpy)(res->file, pos + 1, pos2 - pos - 1);
> + internal_memcpy(res->file, pos + 1, pos2 - pos - 1);
> res->file[pos2 - pos - 1] = 0;
> res->line = atoi(pos2 + 1);
> }
> @@ -196,43 +196,6 @@
>
> ReportStack *SymbolizeData(uptr addr) {
> return 0;
> - /*
> - if (base == 0)
> - base = GetImageBase();
> - int res = 0;
> - InternalScopedBuf<char> cmd(1024);
> - internal_snprintf(cmd, cmd.Size(),
> - "nm -alC %s|grep \"%zx\"|awk '{printf(\"%%s\\n%%s\", $3, $4)}' >
> tsan.tmp2",
> - exe, (addr - base));
> - if (system(cmd))
> - return 0;
> - FILE* f3 = fopen("tsan.tmp2", "rb");
> - if (f3) {
> - InternalScopedBuf<char> tmp(1024);
> - if (fread(tmp, 1, tmp.Size(), f3) <= 0)
> - return 0;
> - char *pos = strchr(tmp, '\n');
> - if (pos && tmp[0] != '?') {
> - res = 1;
> - symb[0].module = 0;
> - symb[0].offset = addr;
> - symb[0].name = alloc->Alloc<char>(pos - tmp + 1);
> - REAL(memcpy)(symb[0].name, tmp, pos - tmp);
> - symb[0].name[pos - tmp] = 0;
> - symb[0].file = 0;
> - symb[0].line = 0;
> - char *pos2 = strchr(pos, ':');
> - if (pos2) {
> - symb[0].file = alloc->Alloc<char>(pos2 - pos - 1 + 1);
> - REAL(memcpy)(symb[0].file, pos + 1, pos2 - pos - 1);
> - symb[0].file[pos2 - pos - 1] = 0;
> - symb[0].line = atoi(pos2 + 1);
> - }
> - }
> - fclose(f3);
> - }
> - return res;
> - */
> }
>
> } // namespace __tsan
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h Wed Jun 27 16:00:23 2012
> @@ -94,7 +94,7 @@
> cap = size;
> T *p = (T*)internal_alloc(typ_, cap * sizeof(T));
> if (cap0) {
> - REAL(memcpy)(p, begin_, cap0 * sizeof(T));
> + internal_memcpy(p, begin_, cap0 * sizeof(T));
> internal_free(begin_);
> }
> begin_ = p;
>
> Modified: compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc Wed Jun
> 27 16:00:23 2012
> @@ -33,6 +33,9 @@
> static __thread bool expect_report_reported;
> static __thread ReportType expect_report_type;
>
> +extern "C" void *__interceptor_memcpy(void*, const void*, uptr);
> +extern "C" void *__interceptor_memset(void*, int, uptr);
> +
> static void *BeforeInitThread(void *param) {
> (void)param;
> return 0;
> @@ -298,10 +301,10 @@
> static_cast<Mutex*>(ev->ptr)->ReadUnlock();
> break;
> case Event::MEMCPY:
> - memcpy(ev->ptr, (void*)ev->arg, ev->arg2);
> + __interceptor_memcpy(ev->ptr, (void*)ev->arg, ev->arg2);
> break;
> case Event::MEMSET:
> - memset(ev->ptr, ev->arg, ev->arg2);
> + __interceptor_memset(ev->ptr, ev->arg, ev->arg2);
> break;
> default: CHECK(0);
> }
>
> Modified: compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc?rev=159294&r1=159293&r2=159294&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc (original)
> +++ compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc Wed Jun 27
> 16:00:23 2012
> @@ -79,7 +79,7 @@
> EXPECT_EQ(len1, internal_read(fd, buf, len1));
> EXPECT_EQ(0, internal_memcmp(buf, str1, len1));
> EXPECT_EQ((char)0, buf[len1 + 1]);
> - REAL(memset)(buf, 0, len1);
> + internal_memset(buf, 0, len1);
> EXPECT_EQ(len2, internal_read(fd, buf, len2));
> EXPECT_EQ(0, internal_memcmp(buf, str2, len2));
> internal_close(fd);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120628/6ab6d1a5/attachment.html>
More information about the llvm-commits
mailing list