[NFC] Move isUnwinding check into ScopedUnwinding

llvm-svn: 355380
This commit is contained in:
Vitaly Buka 2019-03-05 05:40:05 +00:00
parent 7a091ae580
commit 1ac22bfef0
1 changed files with 19 additions and 6 deletions

View File

@ -31,11 +31,22 @@ namespace {
// ScopedUnwinding is a scope for stacktracing member of a context // ScopedUnwinding is a scope for stacktracing member of a context
class ScopedUnwinding { class ScopedUnwinding {
public: public:
explicit ScopedUnwinding(AsanThread *t) : thread(t) { t->setUnwinding(true); } explicit ScopedUnwinding(AsanThread *t) : thread(t) {
~ScopedUnwinding() { thread->setUnwinding(false); } if (thread) {
can_unwind = !thread->isUnwinding();
thread->setUnwinding(true);
}
}
~ScopedUnwinding() {
if (thread)
thread->setUnwinding(false);
}
bool CanUnwind() const { return can_unwind; }
private: private:
AsanThread *thread; AsanThread *thread = nullptr;
bool can_unwind = true;
}; };
} // namespace } // namespace
@ -52,6 +63,9 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
Unwind(max_depth, pc, bp, context, 0, 0, false); Unwind(max_depth, pc, bp, context, 0, 0, false);
#else #else
AsanThread *t = GetCurrentThread(); AsanThread *t = GetCurrentThread();
ScopedUnwinding unwind_scope(t);
if (!unwind_scope.CanUnwind())
return;
if (!t) { if (!t) {
if (!request_fast) { if (!request_fast) {
/* If GetCurrentThread() has failed, try to do slow unwind anyways. */ /* If GetCurrentThread() has failed, try to do slow unwind anyways. */
@ -59,11 +73,10 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
} }
return; return;
} }
if (t->isUnwinding())
return;
uptr stack_top = t->stack_top(); uptr stack_top = t->stack_top();
uptr stack_bottom = t->stack_bottom(); uptr stack_bottom = t->stack_bottom();
ScopedUnwinding unwind_scope(t);
if (SANITIZER_MIPS && !IsValidFrame(bp, stack_top, stack_bottom)) if (SANITIZER_MIPS && !IsValidFrame(bp, stack_top, stack_bottom))
return; return;
if (StackTrace::WillUseFastUnwind(request_fast)) if (StackTrace::WillUseFastUnwind(request_fast))