696d846a56
libsanitizer/ 2015-10-20 Maxim Ostapenko <m.ostapenko@partner.samsung.com> * All source files: Merge from upstream r250806. * configure.ac (link_sanitizer_common): Add -lrt flag. * configure.tgt: Enable TSAN and LSAN for aarch64-linux targets. Set CXX_ABI_NEEDED=true for darwin. * asan/Makefile.am (asan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0 and remove unused and legacy DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0. * asan/Makefile.in: Regenerate. * ubsan/Makefile.am (ubsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=1. (libubsan_la_LIBADD): Add -lc++abi if CXX_ABI_NEEDED is true. * ubsan/Makefile.in: Regenerate. * tsan/Makefile.am (tsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0. * tsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.am (sanitizer_common_files): Add new files. * sanitizer_common/Makefile.in: Regenerate. * asan/libtool-version: Bump the libasan SONAME. From-SVN: r229111
75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
//===-- sanitizer_stacktrace_libcdep.cc -----------------------------------===//
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file is shared between AddressSanitizer and ThreadSanitizer
|
|
// run-time libraries.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "sanitizer_common.h"
|
|
#include "sanitizer_placement_new.h"
|
|
#include "sanitizer_stacktrace.h"
|
|
#include "sanitizer_stacktrace_printer.h"
|
|
#include "sanitizer_symbolizer.h"
|
|
|
|
namespace __sanitizer {
|
|
|
|
void StackTrace::Print() const {
|
|
if (trace == nullptr || size == 0) {
|
|
Printf(" <empty stack>\n\n");
|
|
return;
|
|
}
|
|
InternalScopedString frame_desc(GetPageSizeCached() * 2);
|
|
uptr frame_num = 0;
|
|
for (uptr i = 0; i < size && trace[i]; i++) {
|
|
// PCs in stack traces are actually the return addresses, that is,
|
|
// addresses of the next instructions after the call.
|
|
uptr pc = GetPreviousInstructionPc(trace[i]);
|
|
SymbolizedStack *frames = Symbolizer::GetOrInit()->SymbolizePC(pc);
|
|
CHECK(frames);
|
|
for (SymbolizedStack *cur = frames; cur; cur = cur->next) {
|
|
frame_desc.clear();
|
|
RenderFrame(&frame_desc, common_flags()->stack_trace_format, frame_num++,
|
|
cur->info, common_flags()->symbolize_vs_style,
|
|
common_flags()->strip_path_prefix);
|
|
Printf("%s\n", frame_desc.data());
|
|
}
|
|
frames->ClearAll();
|
|
}
|
|
// Always print a trailing empty line after stack trace.
|
|
Printf("\n");
|
|
}
|
|
|
|
void BufferedStackTrace::Unwind(u32 max_depth, uptr pc, uptr bp, void *context,
|
|
uptr stack_top, uptr stack_bottom,
|
|
bool request_fast_unwind) {
|
|
top_frame_bp = (max_depth > 0) ? bp : 0;
|
|
// Avoid doing any work for small max_depth.
|
|
if (max_depth == 0) {
|
|
size = 0;
|
|
return;
|
|
}
|
|
if (max_depth == 1) {
|
|
size = 1;
|
|
trace_buffer[0] = pc;
|
|
return;
|
|
}
|
|
if (!WillUseFastUnwind(request_fast_unwind)) {
|
|
#if SANITIZER_CAN_SLOW_UNWIND
|
|
if (context)
|
|
SlowUnwindStackWithContext(pc, context, max_depth);
|
|
else
|
|
SlowUnwindStack(pc, max_depth);
|
|
#else
|
|
UNREACHABLE("slow unwind requested but not available");
|
|
#endif
|
|
} else {
|
|
FastUnwindStack(pc, bp, stack_top, stack_bottom, max_depth);
|
|
}
|
|
}
|
|
|
|
} // namespace __sanitizer
|