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() {
 | 
					void __asan_init() {
 | 
				
			||||||
  if (asan_inited) return;
 | 
					  if (asan_inited) return;
 | 
				
			||||||
 | 
					  SanitizerToolName = "AddressSanitizer";
 | 
				
			||||||
  CHECK(!asan_init_is_running && "ASan init calls itself!");
 | 
					  CHECK(!asan_init_is_running && "ASan init calls itself!");
 | 
				
			||||||
  asan_init_is_running = true;
 | 
					  asan_init_is_running = true;
 | 
				
			||||||
  InitializeHighMemEnd();
 | 
					  InitializeHighMemEnd();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -204,6 +204,7 @@ void __msan_warning_noreturn() {
 | 
				
			||||||
void __msan_init() {
 | 
					void __msan_init() {
 | 
				
			||||||
  if (msan_inited) return;
 | 
					  if (msan_inited) return;
 | 
				
			||||||
  msan_init_is_running = 1;
 | 
					  msan_init_is_running = 1;
 | 
				
			||||||
 | 
					  SanitizerToolName = "MemorySanitizer";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  InstallAtExitHandler();
 | 
					  InstallAtExitHandler();
 | 
				
			||||||
  SetDieCallback(MsanDie);
 | 
					  SetDieCallback(MsanDie);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace __sanitizer {
 | 
					namespace __sanitizer {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char *SanitizerToolName = "SanitizerTool";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uptr GetPageSizeCached() {
 | 
					uptr GetPageSizeCached() {
 | 
				
			||||||
  static uptr PageSize;
 | 
					  static uptr PageSize;
 | 
				
			||||||
  if (!PageSize)
 | 
					  if (!PageSize)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,6 +30,8 @@ const uptr kCacheLineSize = 128;
 | 
				
			||||||
const uptr kCacheLineSize = 64;
 | 
					const uptr kCacheLineSize = 64;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern const char *SanitizerToolName;  // Can be changed by the tool.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uptr GetPageSize();
 | 
					uptr GetPageSize();
 | 
				
			||||||
uptr GetPageSizeCached();
 | 
					uptr GetPageSizeCached();
 | 
				
			||||||
uptr GetMmapGranularity();
 | 
					uptr GetMmapGranularity();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,8 +62,8 @@ void *MmapOrDie(uptr size, const char *mem_type) {
 | 
				
			||||||
      Die();
 | 
					      Die();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    recursion_count++;
 | 
					    recursion_count++;
 | 
				
			||||||
    Report("ERROR: Failed to allocate 0x%zx (%zd) bytes of %s: %s\n",
 | 
					    Report("ERROR: %s failed to allocate 0x%zx (%zd) bytes of %s: %s\n",
 | 
				
			||||||
           size, size, mem_type, strerror(errno));
 | 
					           SanitizerToolName, size, size, mem_type, strerror(errno));
 | 
				
			||||||
    DumpProcessMap();
 | 
					    DumpProcessMap();
 | 
				
			||||||
    CHECK("unable to mmap" && 0);
 | 
					    CHECK("unable to mmap" && 0);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -74,8 +74,8 @@ void UnmapOrDie(void *addr, uptr size) {
 | 
				
			||||||
  if (!addr || !size) return;
 | 
					  if (!addr || !size) return;
 | 
				
			||||||
  int res = internal_munmap(addr, size);
 | 
					  int res = internal_munmap(addr, size);
 | 
				
			||||||
  if (res != 0) {
 | 
					  if (res != 0) {
 | 
				
			||||||
    Report("ERROR: Failed to deallocate 0x%zx (%zd) bytes at address %p\n",
 | 
					    Report("ERROR: %s failed to deallocate 0x%zx (%zd) bytes at address %p\n",
 | 
				
			||||||
           size, size, addr);
 | 
					           SanitizerToolName, size, size, addr);
 | 
				
			||||||
    CHECK("unable to unmap" && 0);
 | 
					    CHECK("unable to unmap" && 0);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -88,8 +88,9 @@ void *MmapFixedNoReserve(uptr fixed_addr, uptr size) {
 | 
				
			||||||
      MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
 | 
					      MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE,
 | 
				
			||||||
      -1, 0);
 | 
					      -1, 0);
 | 
				
			||||||
  if (p == (void*)-1)
 | 
					  if (p == (void*)-1)
 | 
				
			||||||
    Report("ERROR: Failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n",
 | 
					    Report("ERROR: "
 | 
				
			||||||
           size, size, fixed_addr, errno);
 | 
					           "%s failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n",
 | 
				
			||||||
 | 
					           SanitizerToolName, size, size, fixed_addr, errno);
 | 
				
			||||||
  return p;
 | 
					  return p;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,8 +102,9 @@ void *MmapFixedOrDie(uptr fixed_addr, uptr size) {
 | 
				
			||||||
      MAP_PRIVATE | MAP_ANON | MAP_FIXED,
 | 
					      MAP_PRIVATE | MAP_ANON | MAP_FIXED,
 | 
				
			||||||
      -1, 0);
 | 
					      -1, 0);
 | 
				
			||||||
  if (p == (void*)-1) {
 | 
					  if (p == (void*)-1) {
 | 
				
			||||||
    Report("ERROR: Failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n",
 | 
					    Report("ERROR:"
 | 
				
			||||||
           size, size, fixed_addr, errno);
 | 
					           " %s failed to allocate 0x%zx (%zd) bytes at address %p (%d)\n",
 | 
				
			||||||
 | 
					           SanitizerToolName, size, size, fixed_addr, errno);
 | 
				
			||||||
    CHECK("unable to mmap" && 0);
 | 
					    CHECK("unable to mmap" && 0);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return p;
 | 
					  return p;
 | 
				
			||||||
| 
						 | 
					@ -189,7 +191,7 @@ void SetStackSizeLimitInBytes(uptr limit) {
 | 
				
			||||||
  rlim.rlim_cur = limit;
 | 
					  rlim.rlim_cur = limit;
 | 
				
			||||||
  rlim.rlim_max = limit;
 | 
					  rlim.rlim_max = limit;
 | 
				
			||||||
  if (setrlimit(RLIMIT_STACK, &rlim)) {
 | 
					  if (setrlimit(RLIMIT_STACK, &rlim)) {
 | 
				
			||||||
    Report("setrlimit() failed %d\n", errno);
 | 
					    Report("ERROR: %s setrlimit() failed %d\n", SanitizerToolName, errno);
 | 
				
			||||||
    Die();
 | 
					    Die();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  CHECK(!StackSizeIsUnlimited());
 | 
					  CHECK(!StackSizeIsUnlimited());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,6 +187,7 @@ void Initialize(ThreadState *thr) {
 | 
				
			||||||
  if (is_initialized)
 | 
					  if (is_initialized)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  is_initialized = true;
 | 
					  is_initialized = true;
 | 
				
			||||||
 | 
					  SanitizerToolName = "ThreadSanitizer";
 | 
				
			||||||
  // Install tool-specific callbacks in sanitizer_common.
 | 
					  // Install tool-specific callbacks in sanitizer_common.
 | 
				
			||||||
  SetCheckFailedCallback(TsanCheckFailed);
 | 
					  SetCheckFailedCallback(TsanCheckFailed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue