summaryrefslogtreecommitdiff
path: root/lib/asan/asan_report.cc
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-01-28 07:34:22 +0000
committerKostya Serebryany <kcc@google.com>2013-01-28 07:34:22 +0000
commit95f630ae40cef78fb03b18110eff43bcf8d1c040 (patch)
tree4d7c658d71e05240f8c937e689744586b15f0c21 /lib/asan/asan_report.cc
parentf6acafcaf557fa8f89794ac08597a854475dfc73 (diff)
downloadcompiler-rt-95f630ae40cef78fb03b18110eff43bcf8d1c040.tar.gz
compiler-rt-95f630ae40cef78fb03b18110eff43bcf8d1c040.tar.bz2
compiler-rt-95f630ae40cef78fb03b18110eff43bcf8d1c040.tar.xz
[asan] two more internal flags for asan-rt: print_stats (0) and print_legend (1)
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@173671 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_report.cc')
-rw-r--r--lib/asan/asan_report.cc34
1 files changed, 20 insertions, 14 deletions
diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc
index cf57f625..c381f4f0 100644
--- a/lib/asan/asan_report.cc
+++ b/lib/asan/asan_report.cc
@@ -120,19 +120,7 @@ static void PrintShadowBytes(const char *before, u8 *bytes,
Printf("\n");
}
-static void PrintShadowMemoryForAddress(uptr addr) {
- if (!AddrIsInMem(addr))
- return;
- uptr shadow_addr = MemToShadow(addr);
- const uptr n_bytes_per_row = 16;
- uptr aligned_shadow = shadow_addr & ~(n_bytes_per_row - 1);
- Printf("Shadow bytes around the buggy address:\n");
- for (int i = -5; i <= 5; i++) {
- const char *prefix = (i == 0) ? "=>" : " ";
- PrintShadowBytes(prefix,
- (u8*)(aligned_shadow + i * n_bytes_per_row),
- (u8*)shadow_addr, n_bytes_per_row);
- }
+static void PrintLegend() {
Printf("Shadow byte legend (one shadow byte represents %d "
"application bytes):\n", (int)SHADOW_GRANULARITY);
PrintShadowByte(" Addressable: ", 0);
@@ -155,6 +143,23 @@ static void PrintShadowMemoryForAddress(uptr addr) {
PrintShadowByte(" ASan internal: ", kAsanInternalHeapMagic);
}
+static void PrintShadowMemoryForAddress(uptr addr) {
+ if (!AddrIsInMem(addr))
+ return;
+ uptr shadow_addr = MemToShadow(addr);
+ const uptr n_bytes_per_row = 16;
+ uptr aligned_shadow = shadow_addr & ~(n_bytes_per_row - 1);
+ Printf("Shadow bytes around the buggy address:\n");
+ for (int i = -5; i <= 5; i++) {
+ const char *prefix = (i == 0) ? "=>" : " ";
+ PrintShadowBytes(prefix,
+ (u8*)(aligned_shadow + i * n_bytes_per_row),
+ (u8*)shadow_addr, n_bytes_per_row);
+ }
+ if (flags()->print_legend)
+ PrintLegend();
+}
+
static void PrintZoneForPointer(uptr ptr, uptr zone_ptr,
const char *zone_name) {
if (zone_ptr) {
@@ -446,7 +451,8 @@ class ScopedInErrorReport {
DescribeThread(curr_thread->summary());
}
// Print memory stats.
- __asan_print_accumulated_stats();
+ if (flags()->print_stats)
+ __asan_print_accumulated_stats();
if (error_report_callback) {
error_report_callback(error_message_buffer);
}