]> git.ipfire.org Git - thirdparty/gcc.git/blame - libsanitizer/lsan/lsan_thread.h
Libsanitizer: merge from master.
[thirdparty/gcc.git] / libsanitizer / lsan / lsan_thread.h
CommitLineData
ef1b3fda
KS
1//=-- lsan_thread.h -------------------------------------------------------===//
2//
b667dd70
ML
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
ef1b3fda
KS
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of LeakSanitizer.
10// Thread registry for standalone LSan.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LSAN_THREAD_H
15#define LSAN_THREAD_H
16
17#include "sanitizer_common/sanitizer_thread_registry.h"
18
19namespace __lsan {
20
3c6331c2 21class ThreadContextLsanBase : public ThreadContextBase {
ef1b3fda 22 public:
3c6331c2 23 explicit ThreadContextLsanBase(int tid);
696d846a 24 void OnFinished() override;
ef1b3fda
KS
25 uptr stack_begin() { return stack_begin_; }
26 uptr stack_end() { return stack_end_; }
ef1b3fda
KS
27 uptr cache_begin() { return cache_begin_; }
28 uptr cache_end() { return cache_end_; }
10189819 29
3c6331c2
ML
30 // The argument is passed on to the subclass's OnStarted member function.
31 static void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type,
32 void *onstarted_arg);
33
34 protected:
35 uptr stack_begin_ = 0;
36 uptr stack_end_ = 0;
37 uptr cache_begin_ = 0;
38 uptr cache_end_ = 0;
ef1b3fda
KS
39};
40
3c6331c2
ML
41// This subclass of ThreadContextLsanBase is declared in an OS-specific header.
42class ThreadContext;
43
ef1b3fda 44void InitializeThreadRegistry();
3c6331c2 45void InitializeMainThread();
ef1b3fda 46
3c6331c2 47u32 ThreadCreate(u32 tid, uptr uid, bool detached, void *arg = nullptr);
ef1b3fda 48void ThreadFinish();
ef1b3fda
KS
49void ThreadJoin(u32 tid);
50u32 ThreadTid(uptr uid);
51
52u32 GetCurrentThread();
53void SetCurrentThread(u32 tid);
54ThreadContext *CurrentThreadContext();
55void EnsureMainThreadIDIsCorrect();
3c6331c2 56
ef1b3fda
KS
57} // namespace __lsan
58
59#endif // LSAN_THREAD_H