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