[ASan/Win tests] Bring back -GS- as SEH tests fail otherwise
[blocksruntime.git] / lib / sanitizer_common / sanitizer_deadlock_detector_interface.h
blob8cf26e0d552870d469f70ed558105a310913722e
1 //===-- sanitizer_deadlock_detector_interface.h -----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of Sanitizer runtime.
11 // Abstract deadlock detector interface.
12 // FIXME: this is work in progress, nothing really works yet.
14 //===----------------------------------------------------------------------===//
16 #ifndef SANITIZER_DEADLOCK_DETECTOR_INTERFACE_H
17 #define SANITIZER_DEADLOCK_DETECTOR_INTERFACE_H
19 #ifndef SANITIZER_DEADLOCK_DETECTOR_VERSION
20 # define SANITIZER_DEADLOCK_DETECTOR_VERSION 1
21 #endif
23 #include "sanitizer_internal_defs.h"
24 #include "sanitizer_atomic.h"
26 namespace __sanitizer {
28 // dd - deadlock detector.
29 // lt - logical (user) thread.
30 // pt - physical (OS) thread.
32 struct DDPhysicalThread;
33 struct DDLogicalThread;
35 struct DDMutex {
36 #if SANITIZER_DEADLOCK_DETECTOR_VERSION == 1
37 uptr id;
38 u32 stk; // creation stack
39 #elif SANITIZER_DEADLOCK_DETECTOR_VERSION == 2
40 u32 id;
41 u32 recursion;
42 atomic_uintptr_t owner;
43 #else
44 # error "BAD SANITIZER_DEADLOCK_DETECTOR_VERSION"
45 #endif
46 u64 ctx;
49 struct DDFlags {
50 bool second_deadlock_stack;
53 struct DDReport {
54 enum { kMaxLoopSize = 8 };
55 int n; // number of entries in loop
56 struct {
57 u64 thr_ctx; // user thread context
58 u64 mtx_ctx0; // user mutex context, start of the edge
59 u64 mtx_ctx1; // user mutex context, end of the edge
60 u32 stk[2]; // stack ids for the edge
61 } loop[kMaxLoopSize];
64 struct DDCallback {
65 DDPhysicalThread *pt;
66 DDLogicalThread *lt;
68 virtual u32 Unwind() { return 0; }
69 virtual int UniqueTid() { return 0; }
72 struct DDetector {
73 static DDetector *Create(const DDFlags *flags);
75 virtual DDPhysicalThread* CreatePhysicalThread() { return 0; }
76 virtual void DestroyPhysicalThread(DDPhysicalThread *pt) {}
78 virtual DDLogicalThread* CreateLogicalThread(u64 ctx) { return 0; }
79 virtual void DestroyLogicalThread(DDLogicalThread *lt) {}
81 virtual void MutexInit(DDCallback *cb, DDMutex *m) {}
82 virtual void MutexBeforeLock(DDCallback *cb, DDMutex *m, bool wlock) {}
83 virtual void MutexAfterLock(DDCallback *cb, DDMutex *m, bool wlock,
84 bool trylock) {}
85 virtual void MutexBeforeUnlock(DDCallback *cb, DDMutex *m, bool wlock) {}
86 virtual void MutexDestroy(DDCallback *cb, DDMutex *m) {}
88 virtual DDReport *GetReport(DDCallback *cb) { return 0; }
91 } // namespace __sanitizer
93 #endif // SANITIZER_DEADLOCK_DETECTOR_INTERFACE_H