[asan] add a flag poison_heap to allow better allocator benchmarking, implemenet malloc_stats() on Linux
llvm-svn: 170685
diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cc b/compiler-rt/lib/asan/asan_malloc_linux.cc
index 1bf9051..df94513 100644
--- a/compiler-rt/lib/asan/asan_malloc_linux.cc
+++ b/compiler-rt/lib/asan/asan_malloc_linux.cc
@@ -19,6 +19,7 @@
#include "asan_interceptors.h"
#include "asan_internal.h"
#include "asan_stack.h"
+#include "asan_thread_registry.h"
#if ASAN_ANDROID
DECLARE_REAL_AND_INTERCEPTOR(void*, malloc, uptr size)
@@ -141,4 +142,10 @@
return asan_pvalloc(size, &stack);
}
+INTERCEPTOR(void, malloc_stats, void) {
+ Printf("AddressSanitizer malloc_stats()\n");
+ Printf(" total mmapped: %zdM\n",
+ asanThreadRegistry().GetHeapSize() >> 20);
+}
+
#endif // __linux__