dd_rtl.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //===-- dd_rtl.h ----------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef DD_RTL_H
  9. #define DD_RTL_H
  10. #include "sanitizer_common/sanitizer_internal_defs.h"
  11. #include "sanitizer_common/sanitizer_deadlock_detector_interface.h"
  12. #include "sanitizer_common/sanitizer_flags.h"
  13. #include "sanitizer_common/sanitizer_allocator_internal.h"
  14. #include "sanitizer_common/sanitizer_addrhashmap.h"
  15. #include "sanitizer_common/sanitizer_mutex.h"
  16. namespace __dsan {
  17. typedef DDFlags Flags;
  18. struct UserMutex {
  19. DDMutex dd;
  20. };
  21. struct Thread {
  22. DDPhysicalThread *dd_pt;
  23. DDLogicalThread *dd_lt;
  24. bool ignore_interceptors;
  25. };
  26. struct Callback final : public DDCallback {
  27. Thread *thr;
  28. Callback(Thread *thr);
  29. u32 Unwind() override;
  30. };
  31. typedef AddrHashMap<UserMutex, 31051> MutexHashMap;
  32. struct Context {
  33. DDetector *dd;
  34. Mutex report_mutex;
  35. MutexHashMap mutex_map;
  36. };
  37. inline Flags* flags() {
  38. static Flags flags;
  39. return &flags;
  40. }
  41. void Initialize();
  42. void InitializeInterceptors();
  43. void ThreadInit(Thread *thr);
  44. void ThreadDestroy(Thread *thr);
  45. void MutexBeforeLock(Thread *thr, uptr m, bool writelock);
  46. void MutexAfterLock(Thread *thr, uptr m, bool writelock, bool trylock);
  47. void MutexBeforeUnlock(Thread *thr, uptr m, bool writelock);
  48. void MutexDestroy(Thread *thr, uptr m);
  49. } // namespace __dsan
  50. #endif // DD_RTL_H