//===-- sanitizer_deadlock_detector.h ---------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file is a part of Sanitizer runtime. // The deadlock detector maintains a directed graph of lock acquisitions. // When a lock event happens, the detector checks if the locks already held by // the current thread are reachable from the newly acquired lock. // // The detector can handle only a fixed amount of simultaneously live locks // (a lock is alive if it has been locked at least once and has not been // destroyed). When the maximal number of locks is reached the entire graph // is flushed and the new lock epoch is started. The node ids from the old // epochs can not be used with any of the detector methods except for // nodeBelongsToCurrentEpoch(). // // FIXME: this is work in progress, nothing really works yet. // //===----------------------------------------------------------------------===// #ifndef SANITIZER_DEADLOCK_DETECTOR_H #define SANITIZER_DEADLOCK_DETECTOR_H #include "sanitizer_bvgraph.h" #include "sanitizer_common.h" namespace __sanitizer { // Thread-local state for DeadlockDetector. // It contains the locks currently held by the owning thread. template <class BV> class DeadlockDetectorTLS { … }; // DeadlockDetector. // For deadlock detection to work we need one global DeadlockDetector object // and one DeadlockDetectorTLS object per evey thread. // This class is not thread safe, all concurrent accesses should be guarded // by an external lock. // Most of the methods of this class are not thread-safe (i.e. should // be protected by an external lock) unless explicitly told otherwise. template <class BV> class DeadlockDetector { … }; } // namespace __sanitizer #endif // SANITIZER_DEADLOCK_DETECTOR_H