lsan_thread.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //=-- lsan_thread.h -------------------------------------------------------===//
  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 LeakSanitizer.
  9. // Thread registry for standalone LSan.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LSAN_THREAD_H
  13. #define LSAN_THREAD_H
  14. #include "sanitizer_common/sanitizer_thread_registry.h"
  15. namespace __lsan {
  16. class ThreadContext : public ThreadContextBase {
  17. public:
  18. explicit ThreadContext(int tid);
  19. void OnStarted(void *arg);
  20. void OnFinished();
  21. uptr stack_begin() { return stack_begin_; }
  22. uptr stack_end() { return stack_end_; }
  23. uptr tls_begin() { return tls_begin_; }
  24. uptr tls_end() { return tls_end_; }
  25. uptr cache_begin() { return cache_begin_; }
  26. uptr cache_end() { return cache_end_; }
  27. private:
  28. uptr stack_begin_, stack_end_,
  29. cache_begin_, cache_end_,
  30. tls_begin_, tls_end_;
  31. };
  32. void InitializeThreadRegistry();
  33. void ThreadStart(u32 tid, uptr os_id);
  34. void ThreadFinish();
  35. u32 ThreadCreate(u32 tid, uptr uid, bool detached);
  36. void ThreadJoin(u32 tid);
  37. u32 ThreadTid(uptr uid);
  38. u32 GetCurrentThread();
  39. void SetCurrentThread(u32 tid);
  40. ThreadContext *CurrentThreadContext();
  41. void EnsureMainThreadIDIsCorrect();
  42. } // namespace __lsan
  43. #endif // LSAN_THREAD_H