forked from OSchip/llvm-project
[sanitizer] make the error messages from sanitizer_common contain the actual tool name
llvm-svn: 174059
This commit is contained in:
parent
a0c0da8f51
commit
bda64b4d40
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
namespace __sanitizer {
|
||||
|
||||
const char *SanitizerToolName = "SanitizerTool";
|
||||
|
||||
uptr GetPageSizeCached() {
|
||||
static uptr PageSize;
|
||||
if (!PageSize)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue