[compiler-rt] r204034 - [sanitizer] print more stack traces when reporting a deadlock (even more to come)

Kostya Serebryany kcc at google.com
Mon Mar 17 02:07:26 PDT 2014


Author: kcc
Date: Mon Mar 17 04:07:24 2014
New Revision: 204034

URL: http://llvm.org/viewvc/llvm-project?rev=204034&view=rev
Log:
[sanitizer] print more stack traces when reporting a deadlock (even more to come)

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc?rev=204034&r1=204033&r2=204034&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector1.cc Mon Mar 17 04:07:24 2014
@@ -118,11 +118,12 @@ void DD::MutexBeforeLock(DDCallback *cb,
       DDMutex *m0 = (DDMutex*)dd.getData(from);
       DDMutex *m1 = (DDMutex*)dd.getData(to);
 
-      Printf("Edge: %zd=>%zd: %u\n", from, to, dd.findEdge(from, to));
+      u32 stk = dd.findEdge(from, to);
+      // Printf("Edge: %zd=>%zd: %u\n", from, to, stk);
       rep->loop[i].thr_ctx = 0;  // don't know
       rep->loop[i].mtx_ctx0 = m0->ctx;
       rep->loop[i].mtx_ctx1 = m1->ctx;
-      rep->loop[i].stk = m0->stk;
+      rep->loop[i].stk = stk;
     }
   }
 }

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc?rev=204034&r1=204033&r2=204034&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc Mon Mar 17 04:07:24 2014
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <sanitizer_common/sanitizer_deadlock_detector_interface.h>
+#include <sanitizer_common/sanitizer_stackdepot.h>
 
 #include "tsan_rtl.h"
 #include "tsan_flags.h"
@@ -425,6 +426,14 @@ void ReportDeadlock(ThreadState *thr, up
   ScopedReport rep(ReportTypeDeadlock);
   for (int i = 0; i < r->n; i++)
     rep.AddMutex(r->loop[i].mtx_ctx0);
+  StackTrace stacks[ARRAY_SIZE(DDReport::loop)];
+  for (int i = 0; i < r->n; i++) {
+    if (!r->loop[i].stk) continue;
+    uptr size;
+    const uptr *trace = StackDepotGet(r->loop[i].stk, &size);
+    stacks[i].Init(const_cast<uptr *>(trace), size);
+    rep.AddStack(&stacks[i]);
+  }
   StackTrace trace;
   trace.ObtainCurrent(thr, pc);
   rep.AddStack(&trace);





More information about the llvm-commits mailing list