* gcc-interface/trans.c (Subprogram_Body_to_gnu): Initialize locus.
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_deadlock_detector_interface.h
blobf8da20612dbdb10494f6049de873f1bff63628e5
1 //===-- sanitizer_deadlock_detector_interface.h -----------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of Sanitizer runtime.
9 // Abstract deadlock detector interface.
10 // FIXME: this is work in progress, nothing really works yet.
12 //===----------------------------------------------------------------------===//
14 #ifndef SANITIZER_DEADLOCK_DETECTOR_INTERFACE_H
15 #define SANITIZER_DEADLOCK_DETECTOR_INTERFACE_H
17 #ifndef SANITIZER_DEADLOCK_DETECTOR_VERSION
18 # define SANITIZER_DEADLOCK_DETECTOR_VERSION 1
19 #endif
21 #include "sanitizer_internal_defs.h"
22 #include "sanitizer_atomic.h"
24 namespace __sanitizer {
26 // dd - deadlock detector.
27 // lt - logical (user) thread.
28 // pt - physical (OS) thread.
30 struct DDPhysicalThread;
31 struct DDLogicalThread;
33 struct DDMutex {
34 #if SANITIZER_DEADLOCK_DETECTOR_VERSION == 1
35 uptr id;
36 u32 stk; // creation stack
37 #elif SANITIZER_DEADLOCK_DETECTOR_VERSION == 2
38 u32 id;
39 u32 recursion;
40 atomic_uintptr_t owner;
41 #else
42 # error "BAD SANITIZER_DEADLOCK_DETECTOR_VERSION"
43 #endif
44 u64 ctx;
47 struct DDFlags {
48 bool second_deadlock_stack;
51 struct DDReport {
52 enum { kMaxLoopSize = 20 };
53 int n; // number of entries in loop
54 struct {
55 u64 thr_ctx; // user thread context
56 u64 mtx_ctx0; // user mutex context, start of the edge
57 u64 mtx_ctx1; // user mutex context, end of the edge
58 u32 stk[2]; // stack ids for the edge
59 } loop[kMaxLoopSize];
62 struct DDCallback {
63 DDPhysicalThread *pt;
64 DDLogicalThread *lt;
66 virtual u32 Unwind() { return 0; }
67 virtual int UniqueTid() { return 0; }
70 struct DDetector {
71 static DDetector *Create(const DDFlags *flags);
73 virtual DDPhysicalThread* CreatePhysicalThread() { return nullptr; }
74 virtual void DestroyPhysicalThread(DDPhysicalThread *pt) {}
76 virtual DDLogicalThread* CreateLogicalThread(u64 ctx) { return nullptr; }
77 virtual void DestroyLogicalThread(DDLogicalThread *lt) {}
79 virtual void MutexInit(DDCallback *cb, DDMutex *m) {}
80 virtual void MutexBeforeLock(DDCallback *cb, DDMutex *m, bool wlock) {}
81 virtual void MutexAfterLock(DDCallback *cb, DDMutex *m, bool wlock,
82 bool trylock) {}
83 virtual void MutexBeforeUnlock(DDCallback *cb, DDMutex *m, bool wlock) {}
84 virtual void MutexDestroy(DDCallback *cb, DDMutex *m) {}
86 virtual DDReport *GetReport(DDCallback *cb) { return nullptr; }
89 } // namespace __sanitizer
91 #endif // SANITIZER_DEADLOCK_DETECTOR_INTERFACE_H