[compiler-rt] r355369 - Revert "[NFC][Sanitizer] Cleanup ASan's GetStackTrace implementation"

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 18:35:49 PST 2019


Author: vitalybuka
Date: Mon Mar  4 18:35:49 2019
New Revision: 355369

URL: http://llvm.org/viewvc/llvm-project?rev=355369&view=rev
Log:
Revert "[NFC][Sanitizer] Cleanup ASan's GetStackTrace implementation"

I've missed that UnwindSlow was removed from ScopedUnwinding.

This reverts commit 4ce918e3942f0333ccb7d65d6265f4fc5f5324be.

Modified:
    compiler-rt/trunk/lib/asan/asan_stack.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h

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=355369&r1=355368&r2=355369&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.cc Mon Mar  4 18:35:49 2019
@@ -31,23 +31,28 @@ u32 GetMallocContextSize() {
 void __sanitizer::BufferedStackTrace::UnwindImpl(
     uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) {
   using namespace __asan;
+#if SANITIZER_WINDOWS
+  Unwind(max_depth, pc, 0, context, 0, 0, false);
+#else
+  AsanThread *t;
   size = 0;
-  if (UNLIKELY(!asan_inited)) return;
-
-  AsanThread *t = GetCurrentThread();
-  if (t && !t->isUnwinding() && WillUseFastUnwind(request_fast)) {
-    uptr top = t->stack_top();
-    uptr bottom = t->stack_bottom();
-    ScopedUnwinding unwind_scope(t);
-    if (!SANITIZER_MIPS || IsValidFrame(bp, top, bottom)) {
-      UnwindFast(pc, bp, top, bottom, max_depth);
-      return;
+  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(request_fast))
+          Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true);
+        else
+          Unwind(max_depth, pc, 0, context, 0, 0, false);
+      }
+    } else if (!t && !request_fast) {
+      /* If GetCurrentThread() has failed, try to do slow unwind anyways. */
+      Unwind(max_depth, pc, bp, context, 0, 0, false);
     }
   }
-
-#if SANITIZER_CAN_SLOW_UNWIND
-    UnwindSlowWithOptionalContext(pc, context, max_depth);
-#endif
+#endif // SANITIZER_WINDOWS
 }
 
 // ------------------ Interface -------------- {{{1

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h?rev=355369&r1=355368&r2=355369&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h Mon Mar  4 18:35:49 2019
@@ -134,11 +134,6 @@ struct BufferedStackTrace : public Stack
   void UnwindSlow(uptr pc, u32 max_depth);
   void UnwindSlow(uptr pc, void *context, u32 max_depth);
 
-  void UnwindSlowWithOptionalContext(uptr pc, void *context, u32 max_depth) {
-    if (context) UnwindSlow(pc, context, max_depth);
-    else         UnwindSlow(pc, max_depth);
-  }
-
   void PopStackFrames(uptr count);
   uptr LocatePcInTrace(uptr pc);
 




More information about the llvm-commits mailing list