Consistently use StackTrace::PrintStack in ASan, LSan and MSan
llvm-svn: 193834
This commit is contained in:
parent
3c5ac81032
commit
4708c5912b
|
@ -25,12 +25,7 @@ static bool MaybeCallAsanSymbolize(const void *pc, char *out_buffer,
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -492,7 +492,6 @@ void LeakReport::PrintLargest(uptr num_leaks_to_print) {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -34,11 +34,6 @@ class Decorator: private __sanitizer::AnsiColorDecorator {
|
|||
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 origin) {
|
|||
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(StackTrace *stack) {
|
|||
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() {
|
||||
|
|
|
@ -40,6 +40,10 @@ static void PrintStackFramePrefix(uptr frame_num, uptr pc) {
|
|||
|
||||
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 *addr, uptr size,
|
|||
frame_num++;
|
||||
}
|
||||
}
|
||||
// Always print a trailing empty line after stack trace.
|
||||
Printf("\n");
|
||||
}
|
||||
|
||||
uptr StackTrace::GetCurrentPc() {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue