summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2019-03-05 05:40:05 +0000
committerVitaly Buka <vitalybuka@google.com>2019-03-05 05:40:05 +0000
commit1ac22bfef04aa829f47b1f5428cfe9f377ee07e6 (patch)
treeb03a40815548f9f7028d2b3307ae88ece0864914
parent7a091ae5809cec6393c9fc5fbc474ee65954d625 (diff)
downloadbcm5719-llvm-1ac22bfef04aa829f47b1f5428cfe9f377ee07e6.tar.gz
bcm5719-llvm-1ac22bfef04aa829f47b1f5428cfe9f377ee07e6.zip
[NFC] Move isUnwinding check into ScopedUnwinding
llvm-svn: 355380
-rw-r--r--compiler-rt/lib/asan/asan_stack.cc25
1 files changed, 19 insertions, 6 deletions
diff --git a/compiler-rt/lib/asan/asan_stack.cc b/compiler-rt/lib/asan/asan_stack.cc
index f5a8e813b99..dde8f7f0e08 100644
--- a/compiler-rt/lib/asan/asan_stack.cc
+++ b/compiler-rt/lib/asan/asan_stack.cc
@@ -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::UnwindImpl(
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::UnwindImpl(
}
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))
OpenPOWER on IntegriCloud