From bc3a7e3fe2dcc1679672e37faeaca727f2634eec Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Wed, 6 Jun 2012 06:47:26 +0000 Subject: [PATCH] [Sanitizer] add sanitizer_common.h for routines shared between TSan and ASan runtimes. Use __sanitizer::Die() in TSan. llvm-svn: 158050 --- .../lib/sanitizer_common/sanitizer_common.h | 28 +++++++++++++++++++ .../lib/sanitizer_common/sanitizer_libc.h | 4 --- .../lib/tsan/rtl/tsan_platform_linux.cc | 12 +++++--- compiler-rt/lib/tsan/rtl/tsan_rtl.h | 2 +- 4 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 compiler-rt/lib/sanitizer_common/sanitizer_common.h diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h new file mode 100644 index 000000000000..8e18d3f8867c --- /dev/null +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -0,0 +1,28 @@ +//===-- sanitizer_common.h --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is shared between AddressSanitizer and ThreadSanitizer +// run-time libraries. +// It defines common functions and classes that are used in both runtimes. +// Implementation of some functions are provided in sanitizer_common, while +// others must be defined by run-time library itself. +//===----------------------------------------------------------------------===// +#ifndef SANITIZER_COMMON_H +#define SANITIZER_COMMON_H + +#include "sanitizer_internal_defs.h" + +namespace __sanitizer { + +// NOTE: Functions below must be defined in each run-time. +void NORETURN Die(); + +} // namespace __sanitizer + +#endif // SANITIZER_COMMON_H diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h index 5b42df997a32..c167079b4f6d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_libc.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_libc.h @@ -11,16 +11,12 @@ // run-time libraries. // These tools can not use some of the libc functions directly because those // functions are intercepted. Instead, we implement a tiny subset of libc here. -// -// We also define several basic types here to avoid using system headers -// as the latter complicate portability of this low-level code. //===----------------------------------------------------------------------===// #ifndef SANITIZER_LIBC_H #define SANITIZER_LIBC_H #include "sanitizer_internal_defs.h" -// No code here yet. Will move more code in the next changes. namespace __sanitizer { void MiniLibcStub(); diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc index 6d6290adfdb8..e60b821ec14f 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc @@ -39,6 +39,14 @@ extern "C" int arch_prctl(int code, __sanitizer::uptr *addr); +namespace __sanitizer { + +void Die() { + _exit(1); +} + +} // namespace __sanitizer + namespace __tsan { static uptr g_tls_size; @@ -56,10 +64,6 @@ ScopedInRtl::~ScopedInRtl() { CHECK_EQ(in_rtl_, thr_->in_rtl); } -void Die() { - _exit(1); -} - uptr GetShadowMemoryConsumption() { return 0; } diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h index fc5852434776..f89f2420b57a 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -26,6 +26,7 @@ #ifndef TSAN_RTL_H #define TSAN_RTL_H +#include "sanitizer_common/sanitizer_common.h" #include "tsan_clock.h" #include "tsan_defs.h" #include "tsan_flags.h" @@ -390,7 +391,6 @@ void ALWAYS_INLINE INLINE StatInc(ThreadState *thr, StatType typ, u64 n = 1) { void InitializeShadowMemory(); void InitializeInterceptors(); void InitializeDynamicAnnotations(); -void Die() NORETURN; void ReportRace(ThreadState *thr); bool OutputReport(const ScopedReport &srep,