[sanitizer] make the error messages from sanitizer_common contain the actual tool name

llvm-svn: 174059
This commit is contained in:
Kostya Serebryany 2013-01-31 14:11:21 +00:00
parent a0c0da8f51
commit bda64b4d40
6 changed files with 18 additions and 9 deletions

View File

@ -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();

View File

@ -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);

View File

@ -16,6 +16,8 @@
namespace __sanitizer {
const char *SanitizerToolName = "SanitizerTool";
uptr GetPageSizeCached() {
static uptr PageSize;
if (!PageSize)

View File

@ -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();

View File

@ -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());

View File

@ -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);