diff options
author | Kostya Serebryany <kcc@google.com> | 2014-03-17 14:41:36 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2014-03-17 14:41:36 +0000 |
commit | 6e756101ca145d7b0a16f2a9eeadc3de38622120 (patch) | |
tree | a08889a5ce69cb4afb4890aa32745ac912e8628f /lib/sanitizer_common/sanitizer_deadlock_detector.h | |
parent | d80aa42b1be94402b1630ef9893bfe468046ba2c (diff) |
[sanitizer] make the deadlock detector print 2*N stack traces on lock-order-inversion with N locks (i.e. print stack traces for both lock acquisitions in every edge in the graph). More improvements to follow
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204042 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_deadlock_detector.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_deadlock_detector.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/sanitizer_common/sanitizer_deadlock_detector.h b/lib/sanitizer_common/sanitizer_deadlock_detector.h index a37310178..a75612a03 100644 --- a/lib/sanitizer_common/sanitizer_deadlock_detector.h +++ b/lib/sanitizer_common/sanitizer_deadlock_detector.h @@ -231,20 +231,24 @@ class DeadlockDetector { added_edges, ARRAY_SIZE(added_edges)); for (uptr i = 0; i < n_added_edges; i++) { if (n_edges_ < ARRAY_SIZE(edges_)) - edges_[n_edges_++] = Edge((u16)added_edges[i], (u16)cur_idx, stk); + edges_[n_edges_++] = Edge((u16)added_edges[i], (u16)cur_idx, stk, + dtls->findLockContext(added_edges[i])); // Printf("Edge [%zd]: %u %zd=>%zd\n", i, stk, added_edges[i], cur_idx); } return n_added_edges; } - u32 findEdge(uptr from_node, uptr to_node) { + bool findEdge(uptr from_node, uptr to_node, u32 *stk_from, u32 *stk_to) { uptr from_idx = nodeToIndex(from_node); uptr to_idx = nodeToIndex(to_node); for (uptr i = 0; i < n_edges_; i++) { - if (edges_[i].from == from_idx && edges_[i].to == to_idx) - return edges_[i].stk; + if (edges_[i].from == from_idx && edges_[i].to == to_idx) { + *stk_from = edges_[i].stk_from; + *stk_to = edges_[i].stk_to; + return true; + } } - return 0; + return false; } // Test-only function. Handles the before/after lock events, @@ -367,9 +371,11 @@ class DeadlockDetector { struct Edge { u16 from; u16 to; - u32 stk; + u32 stk_from; + u32 stk_to; // FIXME: replace with initializer list once the tests are built as c++11. - Edge(u16 f, u16 t, u32 s) : from(f), to(t), stk(s) {} + Edge(u16 f, u16 t, u32 sf, u32 st) + : from(f), to(t), stk_from(sf), stk_to(st) {} Edge() {} }; |