[compiler-rt] r355380 - [NFC] Move isUnwinding check into ScopedUnwinding
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 21:40:05 PST 2019
Author: vitalybuka
Date: Mon Mar 4 21:40:05 2019
New Revision: 355380
URL: http://llvm.org/viewvc/llvm-project?rev=355380&view=rev
Log:
[NFC] Move isUnwinding check into ScopedUnwinding
Modified:
compiler-rt/trunk/lib/asan/asan_stack.cc
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=355380&r1=355379&r2=355380&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.cc Mon Mar 4 21:40:05 2019
@@ -31,11 +31,22 @@ namespace {
// ScopedUnwinding is a scope for stacktracing member of a context
class ScopedUnwinding {
public:
- explicit ScopedUnwinding(AsanThread *t) : thread(t) { t->setUnwinding(true); }
- ~ScopedUnwinding() { thread->setUnwinding(false); }
+ explicit ScopedUnwinding(AsanThread *t) : thread(t) {
+ if (thread) {
+ can_unwind = !thread->isUnwinding();
+ thread->setUnwinding(true);
+ }
+ }
+ ~ScopedUnwinding() {
+ if (thread)
+ thread->setUnwinding(false);
+ }
+
+ bool CanUnwind() const { return can_unwind; }
private:
- AsanThread *thread;
+ AsanThread *thread = nullptr;
+ bool can_unwind = true;
};
} // namespace
@@ -52,6 +63,9 @@ void __sanitizer::BufferedStackTrace::Un
Unwind(max_depth, pc, bp, context, 0, 0, false);
#else
AsanThread *t = GetCurrentThread();
+ ScopedUnwinding unwind_scope(t);
+ if (!unwind_scope.CanUnwind())
+ return;
if (!t) {
if (!request_fast) {
/* If GetCurrentThread() has failed, try to do slow unwind anyways. */
@@ -59,11 +73,10 @@ void __sanitizer::BufferedStackTrace::Un
}
return;
}
- if (t->isUnwinding())
- return;
+
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))
return;
if (StackTrace::WillUseFastUnwind(request_fast))
More information about the llvm-commits
mailing list