12d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines//===-- dd_rtl.h ----------------------------------------------------------===// 22d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// 32d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// The LLVM Compiler Infrastructure 42d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// 52d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// This file is distributed under the University of Illinois Open Source 62d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// License. See LICENSE.TXT for details. 72d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// 82d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines//===----------------------------------------------------------------------===// 92d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#ifndef DD_RTL_H 102d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#define DD_RTL_H 112d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 122d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#include "sanitizer_common/sanitizer_internal_defs.h" 132d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#include "sanitizer_common/sanitizer_deadlock_detector_interface.h" 142d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#include "sanitizer_common/sanitizer_flags.h" 152d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#include "sanitizer_common/sanitizer_allocator_internal.h" 162d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#include "sanitizer_common/sanitizer_addrhashmap.h" 172d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#include "sanitizer_common/sanitizer_mutex.h" 182d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 192d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesnamespace __dsan { 202d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 2186277eb844c4983c81de62d7c050e92fe7155788Stephen Hinestypedef DDFlags Flags; 222d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 232d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesstruct Mutex { 242d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines DDMutex dd; 252d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}; 262d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 272d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesstruct Thread { 282d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines DDPhysicalThread *dd_pt; 292d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines DDLogicalThread *dd_lt; 302d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 312d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines bool ignore_interceptors; 322d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}; 332d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 342d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesstruct Callback : DDCallback { 352d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines Thread *thr; 362d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 372d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines Callback(Thread *thr); 38259f7063e3e4c4b94dded1e90ab0a943d0fa737bPirama Arumuga Nainar u32 Unwind() override; 392d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}; 402d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 412d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinestypedef AddrHashMap<Mutex, 31051> MutexHashMap; 422d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 432d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesstruct Context { 442d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines DDetector *dd; 452d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 462d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines BlockingMutex report_mutex; 472d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines MutexHashMap mutex_map; 482d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}; 492d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 502d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesinline Flags* flags() { 512d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines static Flags flags; 522d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines return &flags; 532d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines} 542d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 552d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvoid Initialize(); 562d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvoid InitializeInterceptors(); 572d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 582d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvoid ThreadInit(Thread *thr); 592d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvoid ThreadDestroy(Thread *thr); 602d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 612d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvoid MutexBeforeLock(Thread *thr, uptr m, bool writelock); 622d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvoid MutexAfterLock(Thread *thr, uptr m, bool writelock, bool trylock); 632d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvoid MutexBeforeUnlock(Thread *thr, uptr m, bool writelock); 642d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvoid MutexDestroy(Thread *thr, uptr m); 652d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines 662d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines} // namespace __dsan 672d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#endif // DD_RTL_H 68