diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-11-07 06:33:06 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-11-07 06:33:06 +0000 |
commit | e74968cbb29c80073e4ff440555e35f3fbed2f20 (patch) | |
tree | 44f40a2f4f65292686ddf3148ed105a4aff9282d | |
parent | e041c6024b3ebf1365c0f99732fc69c607577571 (diff) | |
download | compiler-rt-e74968cbb29c80073e4ff440555e35f3fbed2f20.tar.gz compiler-rt-e74968cbb29c80073e4ff440555e35f3fbed2f20.tar.bz2 compiler-rt-e74968cbb29c80073e4ff440555e35f3fbed2f20.tar.xz |
[Sanitizer] Call Windows unwinder 'slow' and share StackTrace::Unwind across all platforms. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194193 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/sanitizer_common/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_posix_libcdep.cc | 16 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_stacktrace.h | 6 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc | 32 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_win.cc | 6 |
5 files changed, 38 insertions, 23 deletions
diff --git a/lib/sanitizer_common/CMakeLists.txt b/lib/sanitizer_common/CMakeLists.txt index 923cf234..8c2f2e40 100644 --- a/lib/sanitizer_common/CMakeLists.txt +++ b/lib/sanitizer_common/CMakeLists.txt @@ -25,6 +25,7 @@ set(SANITIZER_LIBCDEP_SOURCES sanitizer_common_libcdep.cc sanitizer_linux_libcdep.cc sanitizer_posix_libcdep.cc + sanitizer_stacktrace_libcdep.cc sanitizer_stoptheworld_linux_libcdep.cc sanitizer_symbolizer_libcdep.cc sanitizer_symbolizer_posix_libcdep.cc) diff --git a/lib/sanitizer_common/sanitizer_posix_libcdep.cc b/lib/sanitizer_common/sanitizer_posix_libcdep.cc index c28822fb..6032f520 100644 --- a/lib/sanitizer_common/sanitizer_posix_libcdep.cc +++ b/lib/sanitizer_common/sanitizer_posix_libcdep.cc @@ -89,22 +89,6 @@ int internal_isatty(fd_t fd) { return isatty(fd); } -#ifndef SANITIZER_GO -void StackTrace::Unwind(uptr max_depth, uptr pc, uptr bp, uptr stack_top, - uptr stack_bottom, bool fast) { - // Check if fast unwind is available. Fast unwind is the only option on Mac. - if (!SANITIZER_CAN_FAST_UNWIND) - fast = false; - else if (SANITIZER_MAC) - fast = true; - - if (!fast) - SlowUnwindStack(pc, max_depth); - else - FastUnwindStack(pc, bp, stack_top, stack_bottom, max_depth); -} -#endif // SANITIZER_GO - } // namespace __sanitizer #endif diff --git a/lib/sanitizer_common/sanitizer_stacktrace.h b/lib/sanitizer_common/sanitizer_stacktrace.h index 7c6a25cc..b03f5791 100644 --- a/lib/sanitizer_common/sanitizer_stacktrace.h +++ b/lib/sanitizer_common/sanitizer_stacktrace.h @@ -23,9 +23,11 @@ static const uptr kStackTraceMax = 256; defined(__powerpc__) || defined(__powerpc64__) || \ defined(__sparc__) || \ defined(__mips__)) -#define SANITIZER_CAN_FAST_UNWIND 0 +# define SANITIZER_CAN_FAST_UNWIND 0 +#elif SANITIZER_WINDOWS +# define SANITIZER_CAN_FAST_UNWIND 0 #else -#define SANITIZER_CAN_FAST_UNWIND 1 +# define SANITIZER_CAN_FAST_UNWIND 1 #endif struct StackTrace { diff --git a/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc b/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc new file mode 100644 index 00000000..8ce0918d --- /dev/null +++ b/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc @@ -0,0 +1,32 @@ +//===-- sanitizer_stacktrace_libcdep.cc -----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// 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_stacktrace.h" + +namespace __sanitizer { + +void StackTrace::Unwind(uptr max_depth, uptr pc, uptr bp, uptr stack_top, + uptr stack_bottom, bool fast) { + // Check if fast unwind is available. Fast unwind is the only option on Mac. + if (!SANITIZER_CAN_FAST_UNWIND) + fast = false; + else if (SANITIZER_MAC) + fast = true; + + if (!fast) + SlowUnwindStack(pc, max_depth); + else + FastUnwindStack(pc, bp, stack_top, stack_bottom, max_depth); +} + +} // namespace __sanitizer diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc index 77e62180..8c4c9b62 100644 --- a/lib/sanitizer_common/sanitizer_win.cc +++ b/lib/sanitizer_common/sanitizer_win.cc @@ -376,11 +376,7 @@ void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size, #endif } -void StackTrace::Unwind(uptr max_depth, uptr pc, uptr bp, uptr stack_top, - uptr stack_bottom, bool fast) { - (void)fast; - (void)stack_top; - (void)stack_bottom; +void StackTrace::SlowUnwindStack(uptr pc, uptr max_depth) { void *tmp[kStackTraceMax]; // FIXME: CaptureStackBackTrace might be too slow for us. |