diff options
author | Sergey Matveev <earthdok@google.com> | 2013-12-05 12:04:51 +0000 |
---|---|---|
committer | Sergey Matveev <earthdok@google.com> | 2013-12-05 12:04:51 +0000 |
commit | 32bb25a810ce518282d68b342f8df2b50f496188 (patch) | |
tree | a29d9fdad7b7820f5193f2e39e432b58e69dceee /lib/msan | |
parent | 42a6725e69355e42c85b8748391aee67bf00352e (diff) |
[sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.
Instead of "if (common_flags()->verbosity) Report(...)" we now have macros.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan')
-rw-r--r-- | lib/msan/msan.cc | 13 | ||||
-rw-r--r-- | lib/msan/msan_interceptors.cc | 13 | ||||
-rw-r--r-- | lib/msan/msan_linux.cc | 14 | ||||
-rw-r--r-- | lib/msan/msan_report.cc | 3 |
4 files changed, 18 insertions, 25 deletions
diff --git a/lib/msan/msan.cc b/lib/msan/msan.cc index 890a5d93f..72c9a2ea1 100644 --- a/lib/msan/msan.cc +++ b/lib/msan/msan.cc @@ -307,21 +307,19 @@ void __msan_init() { if (MSAN_REPLACE_OPERATORS_NEW_AND_DELETE) ReplaceOperatorsNewAndDelete(); if (StackSizeIsUnlimited()) { - if (common_flags()->verbosity) - Printf("Unlimited stack, doing reexec\n"); + VPrintf(1, "Unlimited stack, doing reexec\n"); // A reasonably large stack size. It is bigger than the usual 8Mb, because, // well, the program could have been run with unlimited stack for a reason. SetStackSizeLimitInBytes(32 * 1024 * 1024); ReExec(); } - if (common_flags()->verbosity) - Printf("MSAN_OPTIONS: %s\n", msan_options ? msan_options : "<empty>"); + VPrintf(1, "MSAN_OPTIONS: %s\n", msan_options ? msan_options : "<empty>"); msan_running_under_dr = IsRunningUnderDr(); __msan_clear_on_return(); - if (__msan_get_track_origins() && common_flags()->verbosity > 0) - Printf("msan_track_origins\n"); + if (__msan_get_track_origins()) + VPrintf(1, "msan_track_origins\n"); if (!InitShadow(/* prot1 */ false, /* prot2 */ true, /* map_shadow */ true, __msan_get_track_origins())) { // FIXME: prot1 = false is only required when running under DR. @@ -345,8 +343,7 @@ void __msan_init() { GetThreadStackTopAndBottom(/* at_initialization */true, &__msan_stack_bounds.stack_top, &__msan_stack_bounds.stack_bottom); - if (common_flags()->verbosity) - Printf("MemorySanitizer init done\n"); + VPrintf(1, "MemorySanitizer init done\n"); msan_init_is_running = 0; msan_inited = 1; } diff --git a/lib/msan/msan_interceptors.cc b/lib/msan/msan_interceptors.cc index 15a8bec12..873d72ec2 100644 --- a/lib/msan/msan_interceptors.cc +++ b/lib/msan/msan_interceptors.cc @@ -1195,8 +1195,8 @@ static void MlockIsUnsupported() { static atomic_uint8_t printed; if (atomic_exchange(&printed, 1, memory_order_relaxed)) return; - if (common_flags()->verbosity > 0) - Printf("INFO: MemorySanitizer ignores mlock/mlockall/munlock/munlockall\n"); + VPrintf(1, + "INFO: MemorySanitizer ignores mlock/mlockall/munlock/munlockall\n"); } INTERCEPTOR(int, mlock, const void *addr, uptr len) { @@ -1242,11 +1242,10 @@ extern "C" int *__errno_location(void); CHECK_UNPOISONED_0(x, n); \ } while (0) -#define MSAN_INTERCEPT_FUNC(name) \ - do { \ - if ((!INTERCEPT_FUNCTION(name) || !REAL(name)) && \ - common_flags()->verbosity > 0) \ - Report("MemorySanitizer: failed to intercept '" #name "'\n"); \ +#define MSAN_INTERCEPT_FUNC(name) \ + do { \ + if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \ + VReport(1, "MemorySanitizer: failed to intercept '" #name "'\n"); \ } while (0) #define COMMON_INTERCEPT_FUNCTION(name) MSAN_INTERCEPT_FUNC(name) diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc index 46f501e48..4cb46e484 100644 --- a/lib/msan/msan_linux.cc +++ b/lib/msan/msan_linux.cc @@ -51,14 +51,12 @@ bool InitShadow(bool prot1, bool prot2, bool map_shadow, bool init_origins) { return false; } - if (common_flags()->verbosity) { - Printf("__msan_init %p\n", &__msan_init); - Printf("Memory : %p %p\n", kMemBeg, kMemEnd); - Printf("Bad2 : %p %p\n", kBad2Beg, kBad2End); - Printf("Origins : %p %p\n", kOriginsBeg, kOriginsEnd); - Printf("Shadow : %p %p\n", kShadowBeg, kShadowEnd); - Printf("Bad1 : %p %p\n", kBad1Beg, kBad1End); - } + VPrintf(1, "__msan_init %p\n", &__msan_init); + VPrintf(1, "Memory : %p %p\n", kMemBeg, kMemEnd); + VPrintf(1, "Bad2 : %p %p\n", kBad2Beg, kBad2End); + VPrintf(1, "Origins : %p %p\n", kOriginsBeg, kOriginsEnd); + VPrintf(1, "Shadow : %p %p\n", kShadowBeg, kShadowEnd); + VPrintf(1, "Bad1 : %p %p\n", kBad1Beg, kBad1End); if (!MemoryRangeIsAvailable(kShadowBeg, init_origins ? kOriginsEnd : kShadowEnd)) { diff --git a/lib/msan/msan_report.cc b/lib/msan/msan_report.cc index e3ef99307..83c1fbb84 100644 --- a/lib/msan/msan_report.cc +++ b/lib/msan/msan_report.cc @@ -36,8 +36,7 @@ class Decorator: private __sanitizer::AnsiColorDecorator { static void DescribeOrigin(u32 origin) { Decorator d; - if (common_flags()->verbosity) - Printf(" raw origin id: %d\n", origin); + VPrintf(1, " raw origin id: %d\n", origin); uptr pc; if (const char *so = GetOriginDescrIfStack(origin, &pc)) { char* s = internal_strdup(so); |