[compiler-rt] r193834 - Consistently use StackTrace::PrintStack in ASan, LSan and MSan
Alexey Samsonov
samsonov at google.com
Thu Oct 31 17:19:46 PDT 2013
Author: samsonov
Date: Thu Oct 31 19:19:46 2013
New Revision: 193834
URL: http://llvm.org/viewvc/llvm-project?rev=193834&view=rev
Log:
Consistently use StackTrace::PrintStack in ASan, LSan and MSan
Modified:
compiler-rt/trunk/lib/asan/asan_stack.cc
compiler-rt/trunk/lib/lsan/lsan_common.cc
compiler-rt/trunk/lib/msan/msan_report.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
Modified: compiler-rt/trunk/lib/asan/asan_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.cc?rev=193834&r1=193833&r2=193834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.cc Thu Oct 31 19:19:46 2013
@@ -25,12 +25,7 @@ static bool MaybeCallAsanSymbolize(const
}
void PrintStack(const uptr *trace, uptr size) {
- if (!trace) {
- Printf("<empty stack>\n\n");
- return;
- }
StackTrace::PrintStack(trace, size, MaybeCallAsanSymbolize);
- Printf("\n");
}
void PrintStack(StackTrace *stack) {
Modified: compiler-rt/trunk/lib/lsan/lsan_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.cc?rev=193834&r1=193833&r2=193834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common.cc Thu Oct 31 19:19:46 2013
@@ -492,7 +492,6 @@ void LeakReport::PrintLargest(uptr num_l
leaks_[i].total_size, leaks_[i].hit_count);
Printf("%s", d.End());
PrintStackTraceById(leaks_[i].stack_trace_id);
- Printf("\n");
leaks_printed++;
if (leaks_printed == num_leaks_to_print) break;
}
Modified: compiler-rt/trunk/lib/msan/msan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_report.cc?rev=193834&r1=193833&r2=193834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_report.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_report.cc Thu Oct 31 19:19:46 2013
@@ -34,11 +34,6 @@ class Decorator: private __sanitizer::An
const char *End() { return Default(); }
};
-static void PrintStack(const uptr *trace, uptr size) {
- StackTrace::PrintStack(trace, size);
- Printf("\n");
-}
-
static void DescribeOrigin(u32 origin) {
Decorator d;
if (common_flags()->verbosity)
@@ -60,14 +55,14 @@ static void DescribeOrigin(u32 origin) {
// For some reason function address in LLVM IR is 1 less then the address
// of the first instruction.
pc += 1;
- PrintStack(&pc, 1);
+ StackTrace::PrintStack(&pc, 1);
}
} else {
uptr size = 0;
const uptr *trace = StackDepotGet(origin, &size);
Printf(" %sUninitialized value was created by a heap allocation%s\n",
d.Origin(), d.End());
- PrintStack(trace, size);
+ StackTrace::PrintStack(trace, size);
}
}
@@ -88,7 +83,7 @@ void ReportUMR(StackTrace *stack, u32 or
Printf("%s", d.Warning());
Report(" WARNING: MemorySanitizer: use-of-uninitialized-value\n");
Printf("%s", d.End());
- PrintStack(stack->trace, stack->size);
+ StackTrace::PrintStack(stack->trace, stack->size);
if (origin) {
DescribeOrigin(origin);
}
@@ -99,7 +94,7 @@ void ReportExpectedUMRNotFound(StackTrac
SpinMutexLock l(&CommonSanitizerReportMutex);
Printf(" WARNING: Expected use of uninitialized value not found\n");
- PrintStack(stack->trace, stack->size);
+ StackTrace::PrintStack(stack->trace, stack->size);
}
void ReportAtExitStatistics() {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc?rev=193834&r1=193833&r2=193834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc Thu Oct 31 19:19:46 2013
@@ -40,6 +40,10 @@ static void PrintStackFramePrefix(uptr f
void StackTrace::PrintStack(const uptr *addr, uptr size,
SymbolizeCallback symbolize_callback) {
+ if (addr == 0) {
+ Printf("<empty stack>\n\n");
+ return;
+ }
MemoryMappingLayout proc_maps(/*cache_enabled*/true);
InternalScopedBuffer<char> buff(GetPageSizeCached() * 2);
InternalScopedBuffer<AddressInfo> addr_frames(64);
@@ -100,6 +104,8 @@ void StackTrace::PrintStack(const uptr *
frame_num++;
}
}
+ // Always print a trailing empty line after stack trace.
+ Printf("\n");
}
uptr StackTrace::GetCurrentPc() {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h?rev=193834&r1=193833&r2=193834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h Thu Oct 31 19:19:46 2013
@@ -34,6 +34,7 @@ struct StackTrace {
uptr size;
uptr trace[kStackTraceMax];
+ // Prints a symbolized stacktrace, followed by an empty line.
static void PrintStack(const uptr *addr, uptr size,
SymbolizeCallback symbolize_callback = 0);
More information about the llvm-commits
mailing list