1 //===-- dd_rtl.h ----------------------------------------------------------===// 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 #ifndef DD_RTL_H 10 #define DD_RTL_H 11 12 #include "sanitizer_common/sanitizer_internal_defs.h" 13 #include "sanitizer_common/sanitizer_deadlock_detector_interface.h" 14 #include "sanitizer_common/sanitizer_flags.h" 15 #include "sanitizer_common/sanitizer_allocator_internal.h" 16 #include "sanitizer_common/sanitizer_addrhashmap.h" 17 #include "sanitizer_common/sanitizer_mutex.h" 18 19 namespace __dsan { 20 21 struct Flags : CommonFlags, DDFlags { 22 }; 23 24 struct Mutex { 25 DDMutex dd; 26 }; 27 28 struct Thread { 29 DDPhysicalThread *dd_pt; 30 DDLogicalThread *dd_lt; 31 32 bool ignore_interceptors; 33 }; 34 35 struct Callback : DDCallback { 36 Thread *thr; 37 38 Callback(Thread *thr); 39 virtual u32 Unwind(); 40 }; 41 42 typedef AddrHashMap<Mutex, 31051> MutexHashMap; 43 44 struct Context { 45 DDetector *dd; 46 47 BlockingMutex report_mutex; 48 MutexHashMap mutex_map; 49 }; 50 51 inline Flags* flags() { 52 static Flags flags; 53 return &flags; 54 } 55 56 void Initialize(); 57 void InitializeInterceptors(); 58 59 void ThreadInit(Thread *thr); 60 void ThreadDestroy(Thread *thr); 61 62 void MutexBeforeLock(Thread *thr, uptr m, bool writelock); 63 void MutexAfterLock(Thread *thr, uptr m, bool writelock, bool trylock); 64 void MutexBeforeUnlock(Thread *thr, uptr m, bool writelock); 65 void MutexDestroy(Thread *thr, uptr m); 66 67 } // namespace __dsan 68 #endif // DD_RTL_H 69