summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-01-31 14:11:21 +0000
committerKostya Serebryany <kcc@google.com>2013-01-31 14:11:21 +0000
commitbda64b4d405a4f4628d0cde75a2bb8d60d61dc2c (patch)
treeca2bc4093fc88f26a3f794ac453d2c1f43cb954e
parenta0c0da8f51fc1e54584329830b3ed82006b0dcec (diff)
downloadbcm5719-llvm-bda64b4d405a4f4628d0cde75a2bb8d60d61dc2c.tar.gz
bcm5719-llvm-bda64b4d405a4f4628d0cde75a2bb8d60d61dc2c.zip
[sanitizer] make the error messages from sanitizer_common contain the actual tool name
llvm-svn: 174059
-rw-r--r--compiler-rt/lib/asan/asan_rtl.cc1
-rw-r--r--compiler-rt/lib/msan/msan.cc1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.cc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_posix.cc20
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.cc1
6 files changed, 18 insertions, 9 deletions
diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc
index ef0fcd268ff..3d0b9b4aa2a 100644
--- a/compiler-rt/lib/asan/asan_rtl.cc
+++ b/compiler-rt/lib/asan/asan_rtl.cc
@@ -319,6 +319,7 @@ void NOINLINE __asan_set_death_callback(void (*callback)(void)) {
void __asan_init() {
if (asan_inited) return;
+ SanitizerToolName = "AddressSanitizer";
CHECK(!asan_init_is_running && "ASan init calls itself!");
asan_init_is_running = true;
InitializeHighMemEnd();
diff --git a/compiler-rt/lib/msan/msan.cc b/compiler-rt/lib/msan/msan.cc
index f2cde3f928d..b4c6f52f5e1 100644
--- a/compiler-rt/lib/msan/msan.cc
+++ b/compiler-rt/lib/msan/msan.cc
@@ -204,6 +204,7 @@ void __msan_warning_noreturn() {
void __msan_init() {
if (msan_inited) return;
msan_init_is_running = 1;
+ SanitizerToolName = "MemorySanitizer";
InstallAtExitHandler();
SetDieCallback(MsanDie);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
index 07223b282f0..163e9427207 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.cc
@@ -16,6 +16,8 @@
namespace __sanitizer {
+const char *SanitizerToolName = "SanitizerTool";
+
uptr GetPageSizeCached() {
static uptr PageSize;
if (!PageSize)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 1d002398c78..0ff21eedc46 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -30,6 +30,8 @@ const uptr kCacheLineSize = 128;
const uptr kCacheLineSize = 64;
#endif
+extern const char *SanitizerToolName; // Can be changed by the tool.
+
uptr GetPageSize();
uptr GetPageSizeCached();
uptr GetMmapGranularity();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
index 859be5a7d60..08560f04e2a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
@@ -62,8 +62,8 @@ void *MmapOrDie(uptr size, const char *mem_type) {
Die();
}
recursion_count++;
- Report("ERROR: Failed to allocate 0x%zx (%zd) bytes of %s: %s\n",
- size, size, mem_type, strerror(errno));
+ Report("ERROR: %s failed to allocate 0x%zx (%zd) bytes of %s: %s\n",
+ SanitizerToolName, size, size, mem_type, strerror(errno));
DumpProcessMap();
CHECK("unable to mmap" && 0);
}
@@ -74,8 +74,8 @@ void UnmapOrDie(void *addr, uptr size) {
if (!addr || !size) return;
int res = internal_munmap(addr, size);
if (res != 0) {
- Report("ERROR: Failed to deallocate 0x%zx (%zd) bytes at address %p\n",
- size, size, addr);
+ Report("ERROR: %s failed to deallocate 0x%zx (%zd) bytes at address %p\n",
+ SanitizerToolName, size, size, addr);
CHECK("unable to unmap" && 0);
}
}
@@ -88,8 +88,9 @@ void *MmapFixedNoReserve(uptr fixed_addr, uptr size) {
MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
-1, 0);
if (p == (void*)-1)
- Report("ERROR: Failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n",
- size, size, fixed_addr, errno);
+ Report("ERROR: "
+ "%s failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n",
+ SanitizerToolName, size, size, fixed_addr, errno);
return p;
}
@@ -101,8 +102,9 @@ void *MmapFixedOrDie(uptr fixed_addr, uptr size) {
MAP_PRIVATE | MAP_ANON | MAP_FIXED,
-1, 0);
if (p == (void*)-1) {
- Report("ERROR: Failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n",
- size, size, fixed_addr, errno);
+ Report("ERROR:"
+ " %s failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n",
+ SanitizerToolName, size, size, fixed_addr, errno);
CHECK("unable to mmap" && 0);
}
return p;
@@ -189,7 +191,7 @@ void SetStackSizeLimitInBytes(uptr limit) {
rlim.rlim_cur = limit;
rlim.rlim_max = limit;
if (setrlimit(RLIMIT_STACK, &rlim)) {
- Report("setrlimit() failed %d\n", errno);
+ Report("ERROR: %s setrlimit() failed %d\n", SanitizerToolName, errno);
Die();
}
CHECK(!StackSizeIsUnlimited());
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index d81f44254d3..b28b0d01078 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -187,6 +187,7 @@ void Initialize(ThreadState *thr) {
if (is_initialized)
return;
is_initialized = true;
+ SanitizerToolName = "ThreadSanitizer";
// Install tool-specific callbacks in sanitizer_common.
SetCheckFailedCallback(TsanCheckFailed);
OpenPOWER on IntegriCloud