[lldb] Fix warning: 'sprintf' is deprecated in RNBSocketTest
[llvm-project.git] / compiler-rt / lib / lsan / lsan_thread.h
blob222066ee93cd9cd42637f81662c43b09b36a8286
1 //=-- lsan_thread.h -------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of LeakSanitizer.
10 // Thread registry for standalone LSan.
12 //===----------------------------------------------------------------------===//
14 #ifndef LSAN_THREAD_H
15 #define LSAN_THREAD_H
17 #include "sanitizer_common/sanitizer_thread_arg_retval.h"
18 #include "sanitizer_common/sanitizer_thread_registry.h"
20 namespace __lsan {
22 class ThreadContextLsanBase : public ThreadContextBase {
23 public:
24 explicit ThreadContextLsanBase(int tid);
25 void OnStarted(void *arg) override;
26 void OnFinished() override;
27 uptr stack_begin() { return stack_begin_; }
28 uptr stack_end() { return stack_end_; }
29 uptr cache_begin() { return cache_begin_; }
30 uptr cache_end() { return cache_end_; }
32 // The argument is passed on to the subclass's OnStarted member function.
33 static void ThreadStart(u32 tid, tid_t os_id, ThreadType thread_type,
34 void *onstarted_arg);
36 protected:
37 ~ThreadContextLsanBase() {}
38 uptr stack_begin_ = 0;
39 uptr stack_end_ = 0;
40 uptr cache_begin_ = 0;
41 uptr cache_end_ = 0;
44 // This subclass of ThreadContextLsanBase is declared in an OS-specific header.
45 class ThreadContext;
47 void InitializeThreads();
48 void InitializeMainThread();
50 ThreadRegistry *GetLsanThreadRegistryLocked();
51 ThreadArgRetval &GetThreadArgRetval();
53 u32 ThreadCreate(u32 tid, bool detached, void *arg = nullptr);
54 void ThreadFinish();
56 ThreadContextLsanBase *GetCurrentThread();
57 inline u32 GetCurrentThreadId() {
58 ThreadContextLsanBase *ctx = GetCurrentThread();
59 return ctx ? ctx->tid : kInvalidTid;
61 void SetCurrentThread(ThreadContextLsanBase *tctx);
62 void EnsureMainThreadIDIsCorrect();
64 } // namespace __lsan
66 #endif // LSAN_THREAD_H