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
20namespace __sanitizer {
21struct DTLS;
22}
23
24namespace __lsan {
25
26class ThreadContext : public ThreadContextBase {
27 public:
28  explicit ThreadContext(int tid);
29  void OnStarted(void *arg) override;
30  void OnFinished() override;
31  uptr stack_begin() { return stack_begin_; }
32  uptr stack_end() { return stack_end_; }
33  uptr tls_begin() { return tls_begin_; }
34  uptr tls_end() { return tls_end_; }
35  uptr cache_begin() { return cache_begin_; }
36  uptr cache_end() { return cache_end_; }
37  DTLS *dtls() { return dtls_; }
38
39 private:
40  uptr stack_begin_, stack_end_,
41       cache_begin_, cache_end_,
42       tls_begin_, tls_end_;
43  DTLS *dtls_;
44};
45
46void InitializeThreadRegistry();
47
48void ThreadStart(u32 tid, uptr os_id);
49void ThreadFinish();
50u32 ThreadCreate(u32 tid, uptr uid, bool detached);
51void ThreadJoin(u32 tid);
52u32 ThreadTid(uptr uid);
53
54u32 GetCurrentThread();
55void SetCurrentThread(u32 tid);
56ThreadContext *CurrentThreadContext();
57void EnsureMainThreadIDIsCorrect();
58}  // namespace __lsan
59
60#endif  // LSAN_THREAD_H
61