summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_deadlock_detector.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2014-02-25 08:24:15 +0000
committerKostya Serebryany <kcc@google.com>2014-02-25 08:24:15 +0000
commit3faa530943e8fe0ac9f31791919f956b78ead3c3 (patch)
tree2fc324b42a8d13621074c98843abb51ba46bdc58 /lib/sanitizer_common/sanitizer_deadlock_detector.h
parent105e5bca9a1846e65869289b87aaf92f124133d6 (diff)
[sanitizer] add support for try_lock in deadlock detector
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202120 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_deadlock_detector.h')
-rw-r--r--lib/sanitizer_common/sanitizer_deadlock_detector.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_deadlock_detector.h b/lib/sanitizer_common/sanitizer_deadlock_detector.h
index 76ca8611b..30d503def 100644
--- a/lib/sanitizer_common/sanitizer_deadlock_detector.h
+++ b/lib/sanitizer_common/sanitizer_deadlock_detector.h
@@ -143,6 +143,18 @@ class DeadlockDetector {
return is_reachable;
}
+ // Handles the try_lock event, returns false.
+ // When a try_lock event happens (i.e. a try_lock call succeeds) we need
+ // to add this lock to the currently held locks, but we should not try to
+ // change the lock graph or to detect a cycle. We may want to investigate
+ // whether a more aggressive strategy is possible for try_lock.
+ bool onTryLock(DeadlockDetectorTLS<BV> *dtls, uptr cur_node) {
+ ensureCurrentEpoch(dtls);
+ uptr cur_idx = nodeToIndex(cur_node);
+ dtls->addLock(cur_idx, current_epoch_);
+ return false;
+ }
+
// Finds a path between the lock 'cur_node' (which is currently held in dtls)
// and some other currently held lock, returns the length of the path
// or 0 on failure.
@@ -170,8 +182,13 @@ class DeadlockDetector {
}
uptr testOnlyGetEpoch() const { return current_epoch_; }
+ bool testOnlyHasEdge(uptr l1, uptr l2) {
+ return g_.hasEdge(nodeToIndex(l1), nodeToIndex(l2));
+ }
// idx1 and idx2 are raw indices to g_, not lock IDs.
- bool testOnlyHasEdge(uptr idx1, uptr idx2) { return g_.hasEdge(idx1, idx2); }
+ bool testOnlyHasEdgeRaw(uptr idx1, uptr idx2) {
+ return g_.hasEdge(idx1, idx2);
+ }
void Print() {
for (uptr from = 0; from < size(); from++)