xref: /netbsd-src/external/gpl3/gcc.old/dist/libsanitizer/lsan/lsan_thread.h (revision e7ac2a8b5bd66fa2e050809de09a075c36a7014d)
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 
13 #ifndef LSAN_THREAD_H
14 #define LSAN_THREAD_H
15 
16 #include "sanitizer_common/sanitizer_thread_registry.h"
17 
18 namespace __sanitizer {
19 struct DTLS;
20 }
21 
22 namespace __lsan {
23 
24 class ThreadContext : public ThreadContextBase {
25  public:
26   explicit ThreadContext(int tid);
27   void OnStarted(void *arg) override;
28   void OnFinished() override;
29   uptr stack_begin() { return stack_begin_; }
30   uptr stack_end() { return stack_end_; }
31   uptr tls_begin() { return tls_begin_; }
32   uptr tls_end() { return tls_end_; }
33   uptr cache_begin() { return cache_begin_; }
34   uptr cache_end() { return cache_end_; }
35   DTLS *dtls() { return dtls_; }
36 
37  private:
38   uptr stack_begin_, stack_end_,
39        cache_begin_, cache_end_,
40        tls_begin_, tls_end_;
41   DTLS *dtls_;
42 };
43 
44 void InitializeThreadRegistry();
45 
46 void ThreadStart(u32 tid, tid_t os_id, bool workerthread = false);
47 void ThreadFinish();
48 u32 ThreadCreate(u32 tid, uptr uid, bool detached);
49 void ThreadJoin(u32 tid);
50 u32 ThreadTid(uptr uid);
51 
52 u32 GetCurrentThread();
53 void SetCurrentThread(u32 tid);
54 ThreadContext *CurrentThreadContext();
55 void EnsureMainThreadIDIsCorrect();
56 }  // namespace __lsan
57 
58 #endif  // LSAN_THREAD_H
59