[llvm-commits] [compiler-rt] r158075 - in /compiler-rt/trunk/lib: asan/asan_internal.h asan/asan_rtl.cc sanitizer_common/sanitizer_common.h sanitizer_common/sanitizer_internal_defs.h tsan/rtl/tsan_defs.h tsan/rtl/tsan_rtl_report.cc
Alexey Samsonov
samsonov at google.com
Wed Jun 6 08:22:20 PDT 2012
Author: samsonov
Date: Wed Jun 6 10:22:20 2012
New Revision: 158075
URL: http://llvm.org/viewvc/llvm-project?rev=158075&view=rev
Log:
[Sanitizer] Use common CHECK machinery. Currently each tool has to define its own CheckFailed function.
Modified:
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
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_rtl_report.cc
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=158075&r1=158074&r2=158075&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Jun 6 10:22:20 2012
@@ -110,7 +110,6 @@
struct AsanStackTrace;
// asan_rtl.cc
-void NORETURN CheckFailed(const char *cond, const char *file, int line);
void NORETURN ShowStatsAndAbort();
// asan_globals.cc
@@ -224,19 +223,6 @@
void NORETURN Abort();
int Atexit(void (*function)(void));
-#define CHECK(cond) do { if (!(cond)) { \
- CheckFailed(#cond, __FILE__, __LINE__); \
-}}while(0)
-
-#define RAW_CHECK_MSG(expr, msg) do { \
- if (!(expr)) { \
- RawWrite(msg); \
- Die(); \
- } \
-} while (0)
-
-#define RAW_CHECK(expr) RAW_CHECK_MSG(expr, #expr)
-
#define UNIMPLEMENTED() CHECK("unimplemented" && 0)
#define ASAN_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=158075&r1=158074&r2=158075&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Jun 6 10:22:20 2012
@@ -45,6 +45,13 @@
Exit(FLAG_exitcode);
}
+void CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2) {
+ AsanReport("AddressSanitizer CHECK failed: %s:%d \"%s\" (%zx, %zx)\n",
+ file, line, cond, (uptr)v1, (uptr)v2);
+ PRINT_CURRENT_STACK();
+ ShowStatsAndAbort();
+}
+
} // namespace __sanitizer
namespace __asan {
@@ -336,12 +343,6 @@
__asan_print_accumulated_stats();
}
-void CheckFailed(const char *cond, const char *file, int line) {
- Report("CHECK failed: %s at %s:%d\n", cond, file, line);
- PRINT_CURRENT_STACK();
- ShowStatsAndAbort();
-}
-
} // namespace __asan
// ---------------------- Interface ---------------- {{{1
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=158075&r1=158074&r2=158075&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Wed Jun 6 10:22:20 2012
@@ -20,10 +20,6 @@
namespace __sanitizer {
-// NOTE: Functions below must be defined in each run-time. {{{
-void NORETURN Die();
-// }}}
-
// Constants.
const uptr kWordSize = __WORDSIZE / 8;
const uptr kWordSizeInBits = 8 * kWordSize;
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=158075&r1=158074&r2=158075&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 6 10:22:20 2012
@@ -60,7 +60,14 @@
# endif
#endif // __WORDSIZE
-// Raw check.
+// NOTE: Functions below must be defined in each run-time.
+namespace __sanitizer {
+void NORETURN Die();
+void NORETURN CheckFailed(const char *file, int line, const char *cond,
+ u64 v1, u64 v2);
+} // namespace __sanitizer
+
+// Check macro
#define RAW_CHECK_MSG(expr, msg) do { \
if (!(expr)) { \
RawWrite(msg); \
@@ -70,4 +77,22 @@
#define RAW_CHECK(expr) RAW_CHECK_MSG(expr, #expr)
+#define CHECK_IMPL(c1, op, c2) \
+ do { \
+ __sanitizer::u64 v1 = (u64)(c1); \
+ __sanitizer::u64 v2 = (u64)(c2); \
+ if (!(v1 op v2)) \
+ __sanitizer::CheckFailed(__FILE__, __LINE__, \
+ "(" #c1 ") " #op " (" #c2 ")", v1, v2); \
+ } while (false) \
+/**/
+
+#define CHECK(a) CHECK_IMPL((a), !=, 0)
+#define CHECK_EQ(a, b) CHECK_IMPL((a), ==, (b))
+#define CHECK_NE(a, b) CHECK_IMPL((a), !=, (b))
+#define CHECK_LT(a, b) CHECK_IMPL((a), <, (b))
+#define CHECK_LE(a, b) CHECK_IMPL((a), <=, (b))
+#define CHECK_GT(a, b) CHECK_IMPL((a), >, (b))
+#define CHECK_GE(a, b) CHECK_IMPL((a), >=, (b))
+
#endif // SANITIZER_DEFS_H
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=158075&r1=158074&r2=158075&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h Wed Jun 6 10:22:20 2012
@@ -52,24 +52,6 @@
const bool kCollectStats = false;
#endif
-#define CHECK_IMPL(c1, op, c2) \
- do { \
- __sanitizer::u64 v1 = (u64)(c1); \
- __sanitizer::u64 v2 = (u64)(c2); \
- if (!(v1 op v2)) \
- __tsan::CheckFailed(__FILE__, __LINE__, \
- "(" #c1 ") " #op " (" #c2 ")", v1, v2); \
- } while (false) \
-/**/
-
-#define CHECK(a) CHECK_IMPL((a), !=, 0)
-#define CHECK_EQ(a, b) CHECK_IMPL((a), ==, (b))
-#define CHECK_NE(a, b) CHECK_IMPL((a), !=, (b))
-#define CHECK_LT(a, b) CHECK_IMPL((a), <, (b))
-#define CHECK_LE(a, b) CHECK_IMPL((a), <=, (b))
-#define CHECK_GT(a, b) CHECK_IMPL((a), >, (b))
-#define CHECK_GE(a, b) CHECK_IMPL((a), >=, (b))
-
#if TSAN_DEBUG
#define DCHECK(a) CHECK(a)
#define DCHECK_EQ(a, b) CHECK_EQ(a, b)
@@ -88,8 +70,6 @@
#define DCHECK_GE(a, b)
#endif
-void CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2);
-
// The following "build consistency" machinery ensures that all source files
// are built in the same configuration. Inconsistent builds lead to
// hard to debug crashes.
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=158075&r1=158074&r2=158075&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 6 10:22:20 2012
@@ -22,6 +22,18 @@
#include "tsan_flags.h"
#include "tsan_placement_new.h"
+namespace __sanitizer {
+using namespace __tsan;
+
+void CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2) {
+ ScopedInRtl in_rtl;
+ TsanPrintf("FATAL: ThreadSanitizer CHECK failed: %s:%d \"%s\" (%zx, %zx)\n",
+ file, line, cond, (uptr)v1, (uptr)v2);
+ Die();
+}
+
+} // namespace __sanitizer
+
namespace __tsan {
// Can be overriden by an application/test to intercept reports.
@@ -347,11 +359,4 @@
AddRacyStacks(thr, traces, addr_min, addr_max);
}
-void CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2) {
- ScopedInRtl in_rtl;
- TsanPrintf("FATAL: ThreadSanitizer CHECK failed: %s:%d \"%s\" (%zx, %zx)\n",
- file, line, cond, (uptr)v1, (uptr)v2);
- Die();
-}
-
} // namespace __tsan
More information about the llvm-commits
mailing list