diff options
| author | Julian Lettner <jlettner@apple.com> | 2019-02-27 22:16:02 +0000 |
|---|---|---|
| committer | Julian Lettner <jlettner@apple.com> | 2019-02-27 22:16:02 +0000 |
| commit | a0884da62a471f08c65a03e337aea23203a43eb8 (patch) | |
| tree | dfc44a82b399aa5f2b281a67dc42fcff7b4af2c5 /compiler-rt/lib/asan/asan_stack.cc | |
| parent | 6a198366a0cc214c8876620b6ea6f696620973f9 (diff) | |
| download | bcm5719-llvm-a0884da62a471f08c65a03e337aea23203a43eb8.tar.gz bcm5719-llvm-a0884da62a471f08c65a03e337aea23203a43eb8.zip | |
[NFC][Sanitizer] Pull up GetStackTrace into sanitizer_common
We already independently declare GetStackTrace in all (except TSan)
sanitizer runtime headers. Lets move it to sanitizer_stacktrace.h to
have one canonical way to fill in a BufferedStackFrame. Also enables us
to use it in sanitizer_common itself.
This patch defines GetStackTrace for TSan and moves the function from
ubsan_diag.cc to ubsan_diag_standalone.cc to avoid duplicate symbols
for the UBSan-ASan runtime.
Other than that this patch just moves the code out of headers and into
the correct namespace.
Reviewers: vitalybuka
Differential Revision: https://reviews.llvm.org/D58651
llvm-svn: 355039
Diffstat (limited to 'compiler-rt/lib/asan/asan_stack.cc')
| -rw-r--r-- | compiler-rt/lib/asan/asan_stack.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/asan_stack.cc b/compiler-rt/lib/asan/asan_stack.cc index fe968e8e0d2..e4bc424e53b 100644 --- a/compiler-rt/lib/asan/asan_stack.cc +++ b/compiler-rt/lib/asan/asan_stack.cc @@ -28,6 +28,34 @@ u32 GetMallocContextSize() { } // namespace __asan +void __sanitizer::GetStackTrace(BufferedStackTrace *stack, uptr max_depth, + uptr pc, uptr bp, void *context, bool fast) { + using namespace __asan; +#if SANITIZER_WINDOWS + stack->Unwind(max_depth, pc, 0, context, 0, 0, false); +#else + AsanThread *t; + stack->size = 0; + if (LIKELY(asan_inited)) { + if ((t = GetCurrentThread()) && !t->isUnwinding()) { + uptr stack_top = t->stack_top(); + uptr stack_bottom = t->stack_bottom(); + ScopedUnwinding unwind_scope(t); + if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { + if (StackTrace::WillUseFastUnwind(fast)) + stack->Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, + true); + else + stack->Unwind(max_depth, pc, 0, context, 0, 0, false); + } + } else if (!t && !fast) { + /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ + stack->Unwind(max_depth, pc, bp, context, 0, 0, false); + } + } +#endif // SANITIZER_WINDOWS +} + // ------------------ Interface -------------- {{{1 extern "C" { |

