forked from OSchip/llvm-project
				
			[asan] get rid of AsanPrintf in favor of Printf from sanitizer_common
llvm-svn: 162746
This commit is contained in:
		
							parent
							
								
									4bfe954d14
								
							
						
					
					
						commit
						bb6f165952
					
				| 
						 | 
					@ -12,7 +12,6 @@ set(ASAN_SOURCES
 | 
				
			||||||
  asan_new_delete.cc
 | 
					  asan_new_delete.cc
 | 
				
			||||||
  asan_poisoning.cc
 | 
					  asan_poisoning.cc
 | 
				
			||||||
  asan_posix.cc
 | 
					  asan_posix.cc
 | 
				
			||||||
  asan_printf.cc
 | 
					 | 
				
			||||||
  asan_report.cc
 | 
					  asan_report.cc
 | 
				
			||||||
  asan_rtl.cc
 | 
					  asan_rtl.cc
 | 
				
			||||||
  asan_stack.cc
 | 
					  asan_stack.cc
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -229,17 +229,17 @@ struct AsanChunk: public ChunkBase {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void DescribeAddress(uptr addr, uptr access_size) {
 | 
					  void DescribeAddress(uptr addr, uptr access_size) {
 | 
				
			||||||
    uptr offset;
 | 
					    uptr offset;
 | 
				
			||||||
    AsanPrintf("%p is located ", (void*)addr);
 | 
					    Printf("%p is located ", (void*)addr);
 | 
				
			||||||
    if (AddrIsInside(addr, access_size, &offset)) {
 | 
					    if (AddrIsInside(addr, access_size, &offset)) {
 | 
				
			||||||
      AsanPrintf("%zu bytes inside of", offset);
 | 
					      Printf("%zu bytes inside of", offset);
 | 
				
			||||||
    } else if (AddrIsAtLeft(addr, access_size, &offset)) {
 | 
					    } else if (AddrIsAtLeft(addr, access_size, &offset)) {
 | 
				
			||||||
      AsanPrintf("%zu bytes to the left of", offset);
 | 
					      Printf("%zu bytes to the left of", offset);
 | 
				
			||||||
    } else if (AddrIsAtRight(addr, access_size, &offset)) {
 | 
					    } else if (AddrIsAtRight(addr, access_size, &offset)) {
 | 
				
			||||||
      AsanPrintf("%zu bytes to the right of", offset);
 | 
					      Printf("%zu bytes to the right of", offset);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      AsanPrintf(" somewhere around (this is AddressSanitizer bug!)");
 | 
					      Printf(" somewhere around (this is AddressSanitizer bug!)");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    AsanPrintf(" %zu-byte region [%p,%p)\n",
 | 
					    Printf(" %zu-byte region [%p,%p)\n",
 | 
				
			||||||
               used_size, (void*)Beg(), (void*)(Beg() + used_size));
 | 
					               used_size, (void*)Beg(), (void*)(Beg() + used_size));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -601,12 +601,12 @@ void DescribeHeapAddress(uptr addr, uptr access_size) {
 | 
				
			||||||
  if (m->free_tid != kInvalidTid) {
 | 
					  if (m->free_tid != kInvalidTid) {
 | 
				
			||||||
    AsanThreadSummary *free_thread =
 | 
					    AsanThreadSummary *free_thread =
 | 
				
			||||||
        asanThreadRegistry().FindByTid(m->free_tid);
 | 
					        asanThreadRegistry().FindByTid(m->free_tid);
 | 
				
			||||||
    AsanPrintf("freed by thread T%d here:\n", free_thread->tid());
 | 
					    Printf("freed by thread T%d here:\n", free_thread->tid());
 | 
				
			||||||
    AsanStackTrace free_stack;
 | 
					    AsanStackTrace free_stack;
 | 
				
			||||||
    AsanStackTrace::UncompressStack(&free_stack, m->compressed_free_stack(),
 | 
					    AsanStackTrace::UncompressStack(&free_stack, m->compressed_free_stack(),
 | 
				
			||||||
                                    m->compressed_free_stack_size());
 | 
					                                    m->compressed_free_stack_size());
 | 
				
			||||||
    free_stack.PrintStack();
 | 
					    free_stack.PrintStack();
 | 
				
			||||||
    AsanPrintf("previously allocated by thread T%d here:\n",
 | 
					    Printf("previously allocated by thread T%d here:\n",
 | 
				
			||||||
               alloc_thread->tid());
 | 
					               alloc_thread->tid());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    alloc_stack.PrintStack();
 | 
					    alloc_stack.PrintStack();
 | 
				
			||||||
| 
						 | 
					@ -614,7 +614,7 @@ void DescribeHeapAddress(uptr addr, uptr access_size) {
 | 
				
			||||||
    free_thread->Announce();
 | 
					    free_thread->Announce();
 | 
				
			||||||
    alloc_thread->Announce();
 | 
					    alloc_thread->Announce();
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    AsanPrintf("allocated by thread T%d here:\n", alloc_thread->tid());
 | 
					    Printf("allocated by thread T%d here:\n", alloc_thread->tid());
 | 
				
			||||||
    alloc_stack.PrintStack();
 | 
					    alloc_stack.PrintStack();
 | 
				
			||||||
    t->summary()->Announce();
 | 
					    t->summary()->Announce();
 | 
				
			||||||
    alloc_thread->Announce();
 | 
					    alloc_thread->Announce();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -120,9 +120,6 @@ void *AsanTSDGet();
 | 
				
			||||||
void AsanTSDSet(void *tsd);
 | 
					void AsanTSDSet(void *tsd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AppendToErrorMessageBuffer(const char *buffer);
 | 
					void AppendToErrorMessageBuffer(const char *buffer);
 | 
				
			||||||
// asan_printf.cc
 | 
					 | 
				
			||||||
void AsanPrintf(const char *format, ...);
 | 
					 | 
				
			||||||
void AsanReport(const char *format, ...);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// asan_poisoning.cc
 | 
					// asan_poisoning.cc
 | 
				
			||||||
// Poisons the shadow memory for "size" bytes starting from "addr".
 | 
					// Poisons the shadow memory for "size" bytes starting from "addr".
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -231,7 +231,7 @@ void *cf_realloc(void *ptr, CFIndex size, CFOptionFlags hint, void *info) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void mz_destroy(malloc_zone_t* zone) {
 | 
					void mz_destroy(malloc_zone_t* zone) {
 | 
				
			||||||
  // A no-op -- we will not be destroyed!
 | 
					  // A no-op -- we will not be destroyed!
 | 
				
			||||||
  AsanPrintf("mz_destroy() called -- ignoring\n");
 | 
					  Printf("mz_destroy() called -- ignoring\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
  // from AvailabilityMacros.h
 | 
					  // from AvailabilityMacros.h
 | 
				
			||||||
#if defined(MAC_OS_X_VERSION_10_6) && \
 | 
					#if defined(MAC_OS_X_VERSION_10_6) && \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,59 +0,0 @@
 | 
				
			||||||
//===-- asan_printf.cc ----------------------------------------------------===//
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//                     The LLVM Compiler Infrastructure
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// This file is distributed under the University of Illinois Open Source
 | 
					 | 
				
			||||||
// License. See LICENSE.TXT for details.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//===----------------------------------------------------------------------===//
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// This file is a part of AddressSanitizer, an address sanity checker.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Internal printf function, used inside ASan run-time library.
 | 
					 | 
				
			||||||
// We can't use libc printf because we intercept some of the functions used
 | 
					 | 
				
			||||||
// inside it.
 | 
					 | 
				
			||||||
//===----------------------------------------------------------------------===//
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "asan_internal.h"
 | 
					 | 
				
			||||||
#include "asan_interceptors.h"
 | 
					 | 
				
			||||||
#include "sanitizer_common/sanitizer_libc.h"
 | 
					 | 
				
			||||||
#include "sanitizer_common/sanitizer_common.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stdarg.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace __sanitizer {
 | 
					 | 
				
			||||||
int VSNPrintf(char *buff, int buff_length, const char *format, va_list args);
 | 
					 | 
				
			||||||
}  // namespace __sanitizer
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace __asan {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void AsanPrintf(const char *format, ...) {
 | 
					 | 
				
			||||||
  const int kLen = 1024 * 4;
 | 
					 | 
				
			||||||
  char buffer[kLen];
 | 
					 | 
				
			||||||
  va_list args;
 | 
					 | 
				
			||||||
  va_start(args, format);
 | 
					 | 
				
			||||||
  int needed_length = VSNPrintf(buffer, kLen, format, args);
 | 
					 | 
				
			||||||
  va_end(args);
 | 
					 | 
				
			||||||
  RAW_CHECK_MSG(needed_length < kLen, "Buffer in Printf is too short!\n");
 | 
					 | 
				
			||||||
  RawWrite(buffer);
 | 
					 | 
				
			||||||
  AppendToErrorMessageBuffer(buffer);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Like AsanPrintf, but prints the current PID before the output string.
 | 
					 | 
				
			||||||
void AsanReport(const char *format, ...) {
 | 
					 | 
				
			||||||
  const int kLen = 1024 * 4;
 | 
					 | 
				
			||||||
  char buffer[kLen];
 | 
					 | 
				
			||||||
  int needed_length = internal_snprintf(buffer, kLen, "==%d== ", GetPid());
 | 
					 | 
				
			||||||
  RAW_CHECK_MSG(needed_length < kLen, "Buffer in Report is too short!\n");
 | 
					 | 
				
			||||||
  va_list args;
 | 
					 | 
				
			||||||
  va_start(args, format);
 | 
					 | 
				
			||||||
  needed_length += VSNPrintf(buffer + needed_length, kLen - needed_length,
 | 
					 | 
				
			||||||
                             format, args);
 | 
					 | 
				
			||||||
  va_end(args);
 | 
					 | 
				
			||||||
  RAW_CHECK_MSG(needed_length < kLen, "Buffer in Report is too short!\n");
 | 
					 | 
				
			||||||
  RawWrite(buffer);
 | 
					 | 
				
			||||||
  AppendToErrorMessageBuffer(buffer);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}  // namespace __asan
 | 
					 | 
				
			||||||
| 
						 | 
					@ -47,22 +47,22 @@ static void (*on_error_callback)(void);
 | 
				
			||||||
static void PrintBytes(const char *before, uptr *a) {
 | 
					static void PrintBytes(const char *before, uptr *a) {
 | 
				
			||||||
  u8 *bytes = (u8*)a;
 | 
					  u8 *bytes = (u8*)a;
 | 
				
			||||||
  uptr byte_num = (__WORDSIZE) / 8;
 | 
					  uptr byte_num = (__WORDSIZE) / 8;
 | 
				
			||||||
  AsanPrintf("%s%p:", before, (void*)a);
 | 
					  Printf("%s%p:", before, (void*)a);
 | 
				
			||||||
  for (uptr i = 0; i < byte_num; i++) {
 | 
					  for (uptr i = 0; i < byte_num; i++) {
 | 
				
			||||||
    AsanPrintf(" %x%x", bytes[i] >> 4, bytes[i] & 15);
 | 
					    Printf(" %x%x", bytes[i] >> 4, bytes[i] & 15);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  AsanPrintf("\n");
 | 
					  Printf("\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void PrintShadowMemoryForAddress(uptr addr) {
 | 
					static void PrintShadowMemoryForAddress(uptr addr) {
 | 
				
			||||||
  if (!AddrIsInMem(addr))
 | 
					  if (!AddrIsInMem(addr))
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  uptr shadow_addr = MemToShadow(addr);
 | 
					  uptr shadow_addr = MemToShadow(addr);
 | 
				
			||||||
  AsanPrintf("Shadow byte and word:\n");
 | 
					  Printf("Shadow byte and word:\n");
 | 
				
			||||||
  AsanPrintf("  %p: %x\n", (void*)shadow_addr, *(unsigned char*)shadow_addr);
 | 
					  Printf("  %p: %x\n", (void*)shadow_addr, *(unsigned char*)shadow_addr);
 | 
				
			||||||
  uptr aligned_shadow = shadow_addr & ~(kWordSize - 1);
 | 
					  uptr aligned_shadow = shadow_addr & ~(kWordSize - 1);
 | 
				
			||||||
  PrintBytes("  ", (uptr*)(aligned_shadow));
 | 
					  PrintBytes("  ", (uptr*)(aligned_shadow));
 | 
				
			||||||
  AsanPrintf("More shadow bytes:\n");
 | 
					  Printf("More shadow bytes:\n");
 | 
				
			||||||
  for (int i = -4; i <= 4; i++) {
 | 
					  for (int i = -4; i <= 4; i++) {
 | 
				
			||||||
    const char *prefix = (i == 0) ? "=>" : "  ";
 | 
					    const char *prefix = (i == 0) ? "=>" : "  ";
 | 
				
			||||||
    PrintBytes(prefix, (uptr*)(aligned_shadow + i * kWordSize));
 | 
					    PrintBytes(prefix, (uptr*)(aligned_shadow + i * kWordSize));
 | 
				
			||||||
| 
						 | 
					@ -73,14 +73,14 @@ static void PrintZoneForPointer(uptr ptr, uptr zone_ptr,
 | 
				
			||||||
                                const char *zone_name) {
 | 
					                                const char *zone_name) {
 | 
				
			||||||
  if (zone_ptr) {
 | 
					  if (zone_ptr) {
 | 
				
			||||||
    if (zone_name) {
 | 
					    if (zone_name) {
 | 
				
			||||||
      AsanPrintf("malloc_zone_from_ptr(%p) = %p, which is %s\n",
 | 
					      Printf("malloc_zone_from_ptr(%p) = %p, which is %s\n",
 | 
				
			||||||
                 ptr, zone_ptr, zone_name);
 | 
					                 ptr, zone_ptr, zone_name);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      AsanPrintf("malloc_zone_from_ptr(%p) = %p, which doesn't have a name\n",
 | 
					      Printf("malloc_zone_from_ptr(%p) = %p, which doesn't have a name\n",
 | 
				
			||||||
                 ptr, zone_ptr);
 | 
					                 ptr, zone_ptr);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    AsanPrintf("malloc_zone_from_ptr(%p) = 0\n", ptr);
 | 
					    Printf("malloc_zone_from_ptr(%p) = 0\n", ptr);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -96,21 +96,21 @@ static void PrintGlobalNameIfASCII(const __asan_global &g) {
 | 
				
			||||||
    if (!IsASCII(*(unsigned char*)p)) return;
 | 
					    if (!IsASCII(*(unsigned char*)p)) return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (*(char*)(g.beg + g.size - 1) != 0) return;
 | 
					  if (*(char*)(g.beg + g.size - 1) != 0) return;
 | 
				
			||||||
  AsanPrintf("  '%s' is ascii string '%s'\n", g.name, (char*)g.beg);
 | 
					  Printf("  '%s' is ascii string '%s'\n", g.name, (char*)g.beg);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool DescribeAddressRelativeToGlobal(uptr addr, const __asan_global &g) {
 | 
					bool DescribeAddressRelativeToGlobal(uptr addr, const __asan_global &g) {
 | 
				
			||||||
  if (addr < g.beg - kGlobalAndStackRedzone) return false;
 | 
					  if (addr < g.beg - kGlobalAndStackRedzone) return false;
 | 
				
			||||||
  if (addr >= g.beg + g.size_with_redzone) return false;
 | 
					  if (addr >= g.beg + g.size_with_redzone) return false;
 | 
				
			||||||
  AsanPrintf("%p is located ", (void*)addr);
 | 
					  Printf("%p is located ", (void*)addr);
 | 
				
			||||||
  if (addr < g.beg) {
 | 
					  if (addr < g.beg) {
 | 
				
			||||||
    AsanPrintf("%zd bytes to the left", g.beg - addr);
 | 
					    Printf("%zd bytes to the left", g.beg - addr);
 | 
				
			||||||
  } else if (addr >= g.beg + g.size) {
 | 
					  } else if (addr >= g.beg + g.size) {
 | 
				
			||||||
    AsanPrintf("%zd bytes to the right", addr - (g.beg + g.size));
 | 
					    Printf("%zd bytes to the right", addr - (g.beg + g.size));
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    AsanPrintf("%zd bytes inside", addr - g.beg);  // Can it happen?
 | 
					    Printf("%zd bytes inside", addr - g.beg);  // Can it happen?
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  AsanPrintf(" of global variable '%s' (0x%zx) of size %zu\n",
 | 
					  Printf(" of global variable '%s' (0x%zx) of size %zu\n",
 | 
				
			||||||
             g.name, g.beg, g.size);
 | 
					             g.name, g.beg, g.size);
 | 
				
			||||||
  PrintGlobalNameIfASCII(g);
 | 
					  PrintGlobalNameIfASCII(g);
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
| 
						 | 
					@ -122,15 +122,15 @@ bool DescribeAddressIfShadow(uptr addr) {
 | 
				
			||||||
  static const char kAddrInShadowReport[] =
 | 
					  static const char kAddrInShadowReport[] =
 | 
				
			||||||
      "Address %p is located in the %s.\n";
 | 
					      "Address %p is located in the %s.\n";
 | 
				
			||||||
  if (AddrIsInShadowGap(addr)) {
 | 
					  if (AddrIsInShadowGap(addr)) {
 | 
				
			||||||
    AsanPrintf(kAddrInShadowReport, addr, "shadow gap area");
 | 
					    Printf(kAddrInShadowReport, addr, "shadow gap area");
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (AddrIsInHighShadow(addr)) {
 | 
					  if (AddrIsInHighShadow(addr)) {
 | 
				
			||||||
    AsanPrintf(kAddrInShadowReport, addr, "high shadow area");
 | 
					    Printf(kAddrInShadowReport, addr, "high shadow area");
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (AddrIsInLowShadow(addr)) {
 | 
					  if (AddrIsInLowShadow(addr)) {
 | 
				
			||||||
    AsanPrintf(kAddrInShadowReport, addr, "low shadow area");
 | 
					    Printf(kAddrInShadowReport, addr, "low shadow area");
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  CHECK(0 && "Address is not in memory and not in shadow?");
 | 
					  CHECK(0 && "Address is not in memory and not in shadow?");
 | 
				
			||||||
| 
						 | 
					@ -155,14 +155,14 @@ bool DescribeAddressIfStack(uptr addr, uptr access_size) {
 | 
				
			||||||
  internal_strncat(buf, frame_descr,
 | 
					  internal_strncat(buf, frame_descr,
 | 
				
			||||||
                   Min(kBufSize,
 | 
					                   Min(kBufSize,
 | 
				
			||||||
                       static_cast<sptr>(name_end - frame_descr)));
 | 
					                       static_cast<sptr>(name_end - frame_descr)));
 | 
				
			||||||
  AsanPrintf("Address %p is located at offset %zu "
 | 
					  Printf("Address %p is located at offset %zu "
 | 
				
			||||||
             "in frame <%s> of T%d's stack:\n",
 | 
					             "in frame <%s> of T%d's stack:\n",
 | 
				
			||||||
             (void*)addr, offset, buf, t->tid());
 | 
					             (void*)addr, offset, buf, t->tid());
 | 
				
			||||||
  // Report the number of stack objects.
 | 
					  // Report the number of stack objects.
 | 
				
			||||||
  char *p;
 | 
					  char *p;
 | 
				
			||||||
  uptr n_objects = internal_simple_strtoll(name_end, &p, 10);
 | 
					  uptr n_objects = internal_simple_strtoll(name_end, &p, 10);
 | 
				
			||||||
  CHECK(n_objects > 0);
 | 
					  CHECK(n_objects > 0);
 | 
				
			||||||
  AsanPrintf("  This frame has %zu object(s):\n", n_objects);
 | 
					  Printf("  This frame has %zu object(s):\n", n_objects);
 | 
				
			||||||
  // Report all objects in this frame.
 | 
					  // Report all objects in this frame.
 | 
				
			||||||
  for (uptr i = 0; i < n_objects; i++) {
 | 
					  for (uptr i = 0; i < n_objects; i++) {
 | 
				
			||||||
    uptr beg, size;
 | 
					    uptr beg, size;
 | 
				
			||||||
| 
						 | 
					@ -171,7 +171,7 @@ bool DescribeAddressIfStack(uptr addr, uptr access_size) {
 | 
				
			||||||
    size = internal_simple_strtoll(p, &p, 10);
 | 
					    size = internal_simple_strtoll(p, &p, 10);
 | 
				
			||||||
    len  = internal_simple_strtoll(p, &p, 10);
 | 
					    len  = internal_simple_strtoll(p, &p, 10);
 | 
				
			||||||
    if (beg <= 0 || size <= 0 || len < 0 || *p != ' ') {
 | 
					    if (beg <= 0 || size <= 0 || len < 0 || *p != ' ') {
 | 
				
			||||||
      AsanPrintf("AddressSanitizer can't parse the stack frame "
 | 
					      Printf("AddressSanitizer can't parse the stack frame "
 | 
				
			||||||
                 "descriptor: |%s|\n", frame_descr);
 | 
					                 "descriptor: |%s|\n", frame_descr);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -179,9 +179,9 @@ bool DescribeAddressIfStack(uptr addr, uptr access_size) {
 | 
				
			||||||
    buf[0] = 0;
 | 
					    buf[0] = 0;
 | 
				
			||||||
    internal_strncat(buf, p, Min(kBufSize, len));
 | 
					    internal_strncat(buf, p, Min(kBufSize, len));
 | 
				
			||||||
    p += len;
 | 
					    p += len;
 | 
				
			||||||
    AsanPrintf("    [%zu, %zu) '%s'\n", beg, beg + size, buf);
 | 
					    Printf("    [%zu, %zu) '%s'\n", beg, beg + size, buf);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  AsanPrintf("HINT: this may be a false positive if your program uses "
 | 
					  Printf("HINT: this may be a false positive if your program uses "
 | 
				
			||||||
             "some custom stack unwind mechanism\n"
 | 
					             "some custom stack unwind mechanism\n"
 | 
				
			||||||
             "      (longjmp and C++ exceptions *are* supported)\n");
 | 
					             "      (longjmp and C++ exceptions *are* supported)\n");
 | 
				
			||||||
  t->summary()->Announce();
 | 
					  t->summary()->Announce();
 | 
				
			||||||
| 
						 | 
					@ -213,7 +213,7 @@ class ScopedInErrorReport {
 | 
				
			||||||
      // Do not print more than one report, otherwise they will mix up.
 | 
					      // Do not print more than one report, otherwise they will mix up.
 | 
				
			||||||
      // Error reporting functions shouldn't return at this situation, as
 | 
					      // Error reporting functions shouldn't return at this situation, as
 | 
				
			||||||
      // they are defined as no-return.
 | 
					      // they are defined as no-return.
 | 
				
			||||||
      AsanReport("AddressSanitizer: while reporting a bug found another one."
 | 
					      Report("AddressSanitizer: while reporting a bug found another one."
 | 
				
			||||||
                 "Ignoring.\n");
 | 
					                 "Ignoring.\n");
 | 
				
			||||||
      // We can't use infinite busy loop here, as ASan may try to report an
 | 
					      // We can't use infinite busy loop here, as ASan may try to report an
 | 
				
			||||||
      // error while another error report is being printed (e.g. if the code
 | 
					      // error while another error report is being printed (e.g. if the code
 | 
				
			||||||
| 
						 | 
					@ -224,7 +224,7 @@ class ScopedInErrorReport {
 | 
				
			||||||
    if (on_error_callback) {
 | 
					    if (on_error_callback) {
 | 
				
			||||||
      on_error_callback();
 | 
					      on_error_callback();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    AsanPrintf("===================================================="
 | 
					    Printf("===================================================="
 | 
				
			||||||
               "=============\n");
 | 
					               "=============\n");
 | 
				
			||||||
    AsanThread *curr_thread = asanThreadRegistry().GetCurrent();
 | 
					    AsanThread *curr_thread = asanThreadRegistry().GetCurrent();
 | 
				
			||||||
    if (curr_thread) {
 | 
					    if (curr_thread) {
 | 
				
			||||||
| 
						 | 
					@ -245,32 +245,32 @@ class ScopedInErrorReport {
 | 
				
			||||||
    if (error_report_callback) {
 | 
					    if (error_report_callback) {
 | 
				
			||||||
      error_report_callback(error_message_buffer);
 | 
					      error_report_callback(error_message_buffer);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    AsanReport("ABORTING\n");
 | 
					    Report("ABORTING\n");
 | 
				
			||||||
    Die();
 | 
					    Die();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr) {
 | 
					void ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr) {
 | 
				
			||||||
  ScopedInErrorReport in_report;
 | 
					  ScopedInErrorReport in_report;
 | 
				
			||||||
  AsanReport("ERROR: AddressSanitizer crashed on unknown address %p"
 | 
					  Report("ERROR: AddressSanitizer crashed on unknown address %p"
 | 
				
			||||||
             " (pc %p sp %p bp %p T%d)\n",
 | 
					             " (pc %p sp %p bp %p T%d)\n",
 | 
				
			||||||
             (void*)addr, (void*)pc, (void*)sp, (void*)bp,
 | 
					             (void*)addr, (void*)pc, (void*)sp, (void*)bp,
 | 
				
			||||||
             asanThreadRegistry().GetCurrentTidOrInvalid());
 | 
					             asanThreadRegistry().GetCurrentTidOrInvalid());
 | 
				
			||||||
  AsanPrintf("AddressSanitizer can not provide additional info.\n");
 | 
					  Printf("AddressSanitizer can not provide additional info.\n");
 | 
				
			||||||
  GET_STACK_TRACE_WITH_PC_AND_BP(kStackTraceMax, pc, bp);
 | 
					  GET_STACK_TRACE_WITH_PC_AND_BP(kStackTraceMax, pc, bp);
 | 
				
			||||||
  stack.PrintStack();
 | 
					  stack.PrintStack();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ReportDoubleFree(uptr addr, AsanStackTrace *stack) {
 | 
					void ReportDoubleFree(uptr addr, AsanStackTrace *stack) {
 | 
				
			||||||
  ScopedInErrorReport in_report;
 | 
					  ScopedInErrorReport in_report;
 | 
				
			||||||
  AsanReport("ERROR: AddressSanitizer attempting double-free on %p:\n", addr);
 | 
					  Report("ERROR: AddressSanitizer attempting double-free on %p:\n", addr);
 | 
				
			||||||
  stack->PrintStack();
 | 
					  stack->PrintStack();
 | 
				
			||||||
  DescribeHeapAddress(addr, 1);
 | 
					  DescribeHeapAddress(addr, 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ReportFreeNotMalloced(uptr addr, AsanStackTrace *stack) {
 | 
					void ReportFreeNotMalloced(uptr addr, AsanStackTrace *stack) {
 | 
				
			||||||
  ScopedInErrorReport in_report;
 | 
					  ScopedInErrorReport in_report;
 | 
				
			||||||
  AsanReport("ERROR: AddressSanitizer attempting free on address "
 | 
					  Report("ERROR: AddressSanitizer attempting free on address "
 | 
				
			||||||
             "which was not malloc()-ed: %p\n", addr);
 | 
					             "which was not malloc()-ed: %p\n", addr);
 | 
				
			||||||
  stack->PrintStack();
 | 
					  stack->PrintStack();
 | 
				
			||||||
  DescribeHeapAddress(addr, 1);
 | 
					  DescribeHeapAddress(addr, 1);
 | 
				
			||||||
| 
						 | 
					@ -278,7 +278,7 @@ void ReportFreeNotMalloced(uptr addr, AsanStackTrace *stack) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ReportMallocUsableSizeNotOwned(uptr addr, AsanStackTrace *stack) {
 | 
					void ReportMallocUsableSizeNotOwned(uptr addr, AsanStackTrace *stack) {
 | 
				
			||||||
  ScopedInErrorReport in_report;
 | 
					  ScopedInErrorReport in_report;
 | 
				
			||||||
  AsanReport("ERROR: AddressSanitizer attempting to call "
 | 
					  Report("ERROR: AddressSanitizer attempting to call "
 | 
				
			||||||
             "malloc_usable_size() for pointer which is "
 | 
					             "malloc_usable_size() for pointer which is "
 | 
				
			||||||
             "not owned: %p\n", addr);
 | 
					             "not owned: %p\n", addr);
 | 
				
			||||||
  stack->PrintStack();
 | 
					  stack->PrintStack();
 | 
				
			||||||
| 
						 | 
					@ -287,7 +287,7 @@ void ReportMallocUsableSizeNotOwned(uptr addr, AsanStackTrace *stack) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ReportAsanGetAllocatedSizeNotOwned(uptr addr, AsanStackTrace *stack) {
 | 
					void ReportAsanGetAllocatedSizeNotOwned(uptr addr, AsanStackTrace *stack) {
 | 
				
			||||||
  ScopedInErrorReport in_report;
 | 
					  ScopedInErrorReport in_report;
 | 
				
			||||||
  AsanReport("ERROR: AddressSanitizer attempting to call "
 | 
					  Report("ERROR: AddressSanitizer attempting to call "
 | 
				
			||||||
             "__asan_get_allocated_size() for pointer which is "
 | 
					             "__asan_get_allocated_size() for pointer which is "
 | 
				
			||||||
             "not owned: %p\n", addr);
 | 
					             "not owned: %p\n", addr);
 | 
				
			||||||
  stack->PrintStack();
 | 
					  stack->PrintStack();
 | 
				
			||||||
| 
						 | 
					@ -298,7 +298,7 @@ void ReportStringFunctionMemoryRangesOverlap(
 | 
				
			||||||
    const char *function, const char *offset1, uptr length1,
 | 
					    const char *function, const char *offset1, uptr length1,
 | 
				
			||||||
    const char *offset2, uptr length2, AsanStackTrace *stack) {
 | 
					    const char *offset2, uptr length2, AsanStackTrace *stack) {
 | 
				
			||||||
  ScopedInErrorReport in_report;
 | 
					  ScopedInErrorReport in_report;
 | 
				
			||||||
  AsanReport("ERROR: AddressSanitizer %s-param-overlap: "
 | 
					  Report("ERROR: AddressSanitizer %s-param-overlap: "
 | 
				
			||||||
             "memory ranges [%p,%p) and [%p, %p) overlap\n", \
 | 
					             "memory ranges [%p,%p) and [%p, %p) overlap\n", \
 | 
				
			||||||
             function, offset1, offset1 + length1, offset2, offset2 + length2);
 | 
					             function, offset1, offset1 + length1, offset2, offset2 + length2);
 | 
				
			||||||
  stack->PrintStack();
 | 
					  stack->PrintStack();
 | 
				
			||||||
| 
						 | 
					@ -311,7 +311,7 @@ void ReportStringFunctionMemoryRangesOverlap(
 | 
				
			||||||
void WarnMacFreeUnallocated(
 | 
					void WarnMacFreeUnallocated(
 | 
				
			||||||
    uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
 | 
					    uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
 | 
				
			||||||
  // Just print a warning here.
 | 
					  // Just print a warning here.
 | 
				
			||||||
  AsanPrintf("free_common(%p) -- attempting to free unallocated memory.\n"
 | 
					  Printf("free_common(%p) -- attempting to free unallocated memory.\n"
 | 
				
			||||||
             "AddressSanitizer is ignoring this error on Mac OS now.\n",
 | 
					             "AddressSanitizer is ignoring this error on Mac OS now.\n",
 | 
				
			||||||
             addr);
 | 
					             addr);
 | 
				
			||||||
  PrintZoneForPointer(addr, zone_ptr, zone_name);
 | 
					  PrintZoneForPointer(addr, zone_ptr, zone_name);
 | 
				
			||||||
| 
						 | 
					@ -322,7 +322,7 @@ void WarnMacFreeUnallocated(
 | 
				
			||||||
void ReportMacMzReallocUnknown(
 | 
					void ReportMacMzReallocUnknown(
 | 
				
			||||||
    uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
 | 
					    uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
 | 
				
			||||||
  ScopedInErrorReport in_report;
 | 
					  ScopedInErrorReport in_report;
 | 
				
			||||||
  AsanPrintf("mz_realloc(%p) -- attempting to realloc unallocated memory.\n"
 | 
					  Printf("mz_realloc(%p) -- attempting to realloc unallocated memory.\n"
 | 
				
			||||||
             "This is an unrecoverable problem, exiting now.\n",
 | 
					             "This is an unrecoverable problem, exiting now.\n",
 | 
				
			||||||
             addr);
 | 
					             addr);
 | 
				
			||||||
  PrintZoneForPointer(addr, zone_ptr, zone_name);
 | 
					  PrintZoneForPointer(addr, zone_ptr, zone_name);
 | 
				
			||||||
| 
						 | 
					@ -333,7 +333,7 @@ void ReportMacMzReallocUnknown(
 | 
				
			||||||
void ReportMacCfReallocUnknown(
 | 
					void ReportMacCfReallocUnknown(
 | 
				
			||||||
    uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
 | 
					    uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
 | 
				
			||||||
  ScopedInErrorReport in_report;
 | 
					  ScopedInErrorReport in_report;
 | 
				
			||||||
  AsanPrintf("cf_realloc(%p) -- attempting to realloc unallocated memory.\n"
 | 
					  Printf("cf_realloc(%p) -- attempting to realloc unallocated memory.\n"
 | 
				
			||||||
             "This is an unrecoverable problem, exiting now.\n",
 | 
					             "This is an unrecoverable problem, exiting now.\n",
 | 
				
			||||||
             addr);
 | 
					             addr);
 | 
				
			||||||
  PrintZoneForPointer(addr, zone_ptr, zone_name);
 | 
					  PrintZoneForPointer(addr, zone_ptr, zone_name);
 | 
				
			||||||
| 
						 | 
					@ -391,12 +391,12 @@ void __asan_report_error(uptr pc, uptr bp, uptr sp,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AsanReport("ERROR: AddressSanitizer %s on address "
 | 
					  Report("ERROR: AddressSanitizer %s on address "
 | 
				
			||||||
             "%p at pc 0x%zx bp 0x%zx sp 0x%zx\n",
 | 
					             "%p at pc 0x%zx bp 0x%zx sp 0x%zx\n",
 | 
				
			||||||
             bug_descr, (void*)addr, pc, bp, sp);
 | 
					             bug_descr, (void*)addr, pc, bp, sp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  u32 curr_tid = asanThreadRegistry().GetCurrentTidOrInvalid();
 | 
					  u32 curr_tid = asanThreadRegistry().GetCurrentTidOrInvalid();
 | 
				
			||||||
  AsanPrintf("%s of size %zu at %p thread T%d\n",
 | 
					  Printf("%s of size %zu at %p thread T%d\n",
 | 
				
			||||||
             access_size ? (is_write ? "WRITE" : "READ") : "ACCESS",
 | 
					             access_size ? (is_write ? "WRITE" : "READ") : "ACCESS",
 | 
				
			||||||
             access_size, (void*)addr, curr_tid);
 | 
					             access_size, (void*)addr, curr_tid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ void Die() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SANITIZER_INTERFACE_ATTRIBUTE
 | 
					SANITIZER_INTERFACE_ATTRIBUTE
 | 
				
			||||||
void CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2) {
 | 
					void CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2) {
 | 
				
			||||||
  AsanReport("AddressSanitizer CHECK failed: %s:%d \"%s\" (0x%zx, 0x%zx)\n",
 | 
					  Report("AddressSanitizer CHECK failed: %s:%d \"%s\" (0x%zx, 0x%zx)\n",
 | 
				
			||||||
             file, line, cond, (uptr)v1, (uptr)v2);
 | 
					             file, line, cond, (uptr)v1, (uptr)v2);
 | 
				
			||||||
  PRINT_CURRENT_STACK();
 | 
					  PRINT_CURRENT_STACK();
 | 
				
			||||||
  ShowStatsAndAbort();
 | 
					  ShowStatsAndAbort();
 | 
				
			||||||
| 
						 | 
					@ -248,7 +248,7 @@ static NOINLINE void force_interface_symbols() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void asan_atexit() {
 | 
					static void asan_atexit() {
 | 
				
			||||||
  AsanPrintf("AddressSanitizer exit stats:\n");
 | 
					  Printf("AddressSanitizer exit stats:\n");
 | 
				
			||||||
  __asan_print_accumulated_stats();
 | 
					  __asan_print_accumulated_stats();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -284,6 +284,8 @@ void __asan_init() {
 | 
				
			||||||
  // Make sure we are not statically linked.
 | 
					  // Make sure we are not statically linked.
 | 
				
			||||||
  AsanDoesNotSupportStaticLinkage();
 | 
					  AsanDoesNotSupportStaticLinkage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  SetPrintfAndReportCallback(AppendToErrorMessageBuffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Initialize flags. This must be done early, because most of the
 | 
					  // Initialize flags. This must be done early, because most of the
 | 
				
			||||||
  // initialization steps look at flags().
 | 
					  // initialization steps look at flags().
 | 
				
			||||||
  const char *options = GetEnv("ASAN_OPTIONS");
 | 
					  const char *options = GetEnv("ASAN_OPTIONS");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,7 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
 | 
				
			||||||
      // We can't know anything about the string returned by external
 | 
					      // We can't know anything about the string returned by external
 | 
				
			||||||
      // symbolizer, but if it starts with filename, try to strip path prefix
 | 
					      // symbolizer, but if it starts with filename, try to strip path prefix
 | 
				
			||||||
      // from it.
 | 
					      // from it.
 | 
				
			||||||
      AsanPrintf("  #%zu 0x%zx %s\n", frame_num, pc, StripPathPrefix(buff));
 | 
					      Printf("  #%zu 0x%zx %s\n", frame_num, pc, StripPathPrefix(buff));
 | 
				
			||||||
      frame_num++;
 | 
					      frame_num++;
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -67,18 +67,18 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
 | 
				
			||||||
    if (addr_frames_num > 0) {
 | 
					    if (addr_frames_num > 0) {
 | 
				
			||||||
      for (uptr j = 0; j < addr_frames_num; j++) {
 | 
					      for (uptr j = 0; j < addr_frames_num; j++) {
 | 
				
			||||||
        AddressInfo &info = addr_frames[j];
 | 
					        AddressInfo &info = addr_frames[j];
 | 
				
			||||||
        AsanPrintf("    #%zu 0x%zx", frame_num, pc);
 | 
					        Printf("    #%zu 0x%zx", frame_num, pc);
 | 
				
			||||||
        if (info.function) {
 | 
					        if (info.function) {
 | 
				
			||||||
          AsanPrintf(" in %s", info.function);
 | 
					          Printf(" in %s", info.function);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (info.file) {
 | 
					        if (info.file) {
 | 
				
			||||||
          AsanPrintf(" %s:%d:%d", StripPathPrefix(info.file), info.line,
 | 
					          Printf(" %s:%d:%d", StripPathPrefix(info.file), info.line,
 | 
				
			||||||
                                  info.column);
 | 
					                                  info.column);
 | 
				
			||||||
        } else if (info.module) {
 | 
					        } else if (info.module) {
 | 
				
			||||||
          AsanPrintf(" (%s+0x%zx)", StripPathPrefix(info.module),
 | 
					          Printf(" (%s+0x%zx)", StripPathPrefix(info.module),
 | 
				
			||||||
                                    info.module_offset);
 | 
					                                    info.module_offset);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        AsanPrintf("\n");
 | 
					        Printf("\n");
 | 
				
			||||||
        info.Clear();
 | 
					        info.Clear();
 | 
				
			||||||
        frame_num++;
 | 
					        frame_num++;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					@ -87,10 +87,10 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
 | 
				
			||||||
      char filename[4096];
 | 
					      char filename[4096];
 | 
				
			||||||
      if (proc_maps.GetObjectNameAndOffset(pc, &offset,
 | 
					      if (proc_maps.GetObjectNameAndOffset(pc, &offset,
 | 
				
			||||||
                                           filename, sizeof(filename))) {
 | 
					                                           filename, sizeof(filename))) {
 | 
				
			||||||
        AsanPrintf("    #%zu 0x%zx (%s+0x%zx)\n",
 | 
					        Printf("    #%zu 0x%zx (%s+0x%zx)\n",
 | 
				
			||||||
                   frame_num, pc, StripPathPrefix(filename), offset);
 | 
					                   frame_num, pc, StripPathPrefix(filename), offset);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        AsanPrintf("    #%zu 0x%zx\n", frame_num, pc);
 | 
					        Printf("    #%zu 0x%zx\n", frame_num, pc);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      frame_num++;
 | 
					      frame_num++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,29 +27,29 @@ AsanStats::AsanStats() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void PrintMallocStatsArray(const char *prefix,
 | 
					static void PrintMallocStatsArray(const char *prefix,
 | 
				
			||||||
                                  uptr (&array)[kNumberOfSizeClasses]) {
 | 
					                                  uptr (&array)[kNumberOfSizeClasses]) {
 | 
				
			||||||
  AsanPrintf("%s", prefix);
 | 
					  Printf("%s", prefix);
 | 
				
			||||||
  for (uptr i = 0; i < kNumberOfSizeClasses; i++) {
 | 
					  for (uptr i = 0; i < kNumberOfSizeClasses; i++) {
 | 
				
			||||||
    if (!array[i]) continue;
 | 
					    if (!array[i]) continue;
 | 
				
			||||||
    AsanPrintf("%zu:%zu; ", i, array[i]);
 | 
					    Printf("%zu:%zu; ", i, array[i]);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  AsanPrintf("\n");
 | 
					  Printf("\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AsanStats::Print() {
 | 
					void AsanStats::Print() {
 | 
				
			||||||
  AsanPrintf("Stats: %zuM malloced (%zuM for red zones) by %zu calls\n",
 | 
					  Printf("Stats: %zuM malloced (%zuM for red zones) by %zu calls\n",
 | 
				
			||||||
             malloced>>20, malloced_redzones>>20, mallocs);
 | 
					             malloced>>20, malloced_redzones>>20, mallocs);
 | 
				
			||||||
  AsanPrintf("Stats: %zuM realloced by %zu calls\n", realloced>>20, reallocs);
 | 
					  Printf("Stats: %zuM realloced by %zu calls\n", realloced>>20, reallocs);
 | 
				
			||||||
  AsanPrintf("Stats: %zuM freed by %zu calls\n", freed>>20, frees);
 | 
					  Printf("Stats: %zuM freed by %zu calls\n", freed>>20, frees);
 | 
				
			||||||
  AsanPrintf("Stats: %zuM really freed by %zu calls\n",
 | 
					  Printf("Stats: %zuM really freed by %zu calls\n",
 | 
				
			||||||
             really_freed>>20, real_frees);
 | 
					             really_freed>>20, real_frees);
 | 
				
			||||||
  AsanPrintf("Stats: %zuM (%zu full pages) mmaped in %zu calls\n",
 | 
					  Printf("Stats: %zuM (%zu full pages) mmaped in %zu calls\n",
 | 
				
			||||||
             mmaped>>20, mmaped / kPageSize, mmaps);
 | 
					             mmaped>>20, mmaped / kPageSize, mmaps);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  PrintMallocStatsArray("  mmaps   by size class: ", mmaped_by_size);
 | 
					  PrintMallocStatsArray("  mmaps   by size class: ", mmaped_by_size);
 | 
				
			||||||
  PrintMallocStatsArray("  mallocs by size class: ", malloced_by_size);
 | 
					  PrintMallocStatsArray("  mallocs by size class: ", malloced_by_size);
 | 
				
			||||||
  PrintMallocStatsArray("  frees   by size class: ", freed_by_size);
 | 
					  PrintMallocStatsArray("  frees   by size class: ", freed_by_size);
 | 
				
			||||||
  PrintMallocStatsArray("  rfrees  by size class: ", really_freed_by_size);
 | 
					  PrintMallocStatsArray("  rfrees  by size class: ", really_freed_by_size);
 | 
				
			||||||
  AsanPrintf("Stats: malloc large: %zu small slow: %zu\n",
 | 
					  Printf("Stats: malloc large: %zu small slow: %zu\n",
 | 
				
			||||||
             malloc_large, malloc_small_slow);
 | 
					             malloc_large, malloc_small_slow);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,7 +44,7 @@ class AsanThreadSummary {
 | 
				
			||||||
    if (tid_ == 0) return;  // no need to announce the main thread.
 | 
					    if (tid_ == 0) return;  // no need to announce the main thread.
 | 
				
			||||||
    if (!announced_) {
 | 
					    if (!announced_) {
 | 
				
			||||||
      announced_ = true;
 | 
					      announced_ = true;
 | 
				
			||||||
      AsanPrintf("Thread T%d created by T%d here:\n", tid_, parent_tid_);
 | 
					      Printf("Thread T%d created by T%d here:\n", tid_, parent_tid_);
 | 
				
			||||||
      stack_.PrintStack();
 | 
					      stack_.PrintStack();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,6 +98,7 @@ void SetLowLevelAllocateCallback(LowLevelAllocateCallback callback);
 | 
				
			||||||
void RawWrite(const char *buffer);
 | 
					void RawWrite(const char *buffer);
 | 
				
			||||||
void Printf(const char *format, ...);
 | 
					void Printf(const char *format, ...);
 | 
				
			||||||
void Report(const char *format, ...);
 | 
					void Report(const char *format, ...);
 | 
				
			||||||
 | 
					void SetPrintfAndReportCallback(void (*callback)(const char *));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Opens the file 'file_name" and reads up to 'max_len' bytes.
 | 
					// Opens the file 'file_name" and reads up to 'max_len' bytes.
 | 
				
			||||||
// The resulting buffer is mmaped and stored in '*buff'.
 | 
					// The resulting buffer is mmaped and stored in '*buff'.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,6 +142,11 @@ int VSNPrintf(char *buff, int buff_length,
 | 
				
			||||||
  return result;
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void (*PrintfAndReportCallback)(const char *);
 | 
				
			||||||
 | 
					void SetPrintfAndReportCallback(void (*callback)(const char *)) {
 | 
				
			||||||
 | 
					  PrintfAndReportCallback = callback;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Printf(const char *format, ...) {
 | 
					void Printf(const char *format, ...) {
 | 
				
			||||||
  const int kLen = 1024 * 4;
 | 
					  const int kLen = 1024 * 4;
 | 
				
			||||||
  char *buffer = (char*)MmapOrDie(kLen, __FUNCTION__);
 | 
					  char *buffer = (char*)MmapOrDie(kLen, __FUNCTION__);
 | 
				
			||||||
| 
						 | 
					@ -151,6 +156,8 @@ void Printf(const char *format, ...) {
 | 
				
			||||||
  va_end(args);
 | 
					  va_end(args);
 | 
				
			||||||
  RAW_CHECK_MSG(needed_length < kLen, "Buffer in Printf is too short!\n");
 | 
					  RAW_CHECK_MSG(needed_length < kLen, "Buffer in Printf is too short!\n");
 | 
				
			||||||
  RawWrite(buffer);
 | 
					  RawWrite(buffer);
 | 
				
			||||||
 | 
					  if (PrintfAndReportCallback)
 | 
				
			||||||
 | 
					    PrintfAndReportCallback(buffer);
 | 
				
			||||||
  UnmapOrDie(buffer, kLen);
 | 
					  UnmapOrDie(buffer, kLen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,6 +186,8 @@ void Report(const char *format, ...) {
 | 
				
			||||||
  va_end(args);
 | 
					  va_end(args);
 | 
				
			||||||
  RAW_CHECK_MSG(needed_length < kLen, "Buffer in Report is too short!\n");
 | 
					  RAW_CHECK_MSG(needed_length < kLen, "Buffer in Report is too short!\n");
 | 
				
			||||||
  RawWrite(buffer);
 | 
					  RawWrite(buffer);
 | 
				
			||||||
 | 
					  if (PrintfAndReportCallback)
 | 
				
			||||||
 | 
					    PrintfAndReportCallback(buffer);
 | 
				
			||||||
  UnmapOrDie(buffer, kLen);
 | 
					  UnmapOrDie(buffer, kLen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue