Path: blob/main/contrib/llvm-project/compiler-rt/lib/nsan/nsan_thread.h
213766 views
//===- nsan_thread.h --------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef NSAN_THREAD_H9#define NSAN_THREAD_H1011#include "nsan_allocator.h"12#include "sanitizer_common/sanitizer_common.h"13#include "sanitizer_common/sanitizer_posix.h"1415namespace __nsan {1617class NsanThread {18public:19static NsanThread *Create(thread_callback_t start_routine, void *arg);20static void TSDDtor(void *tsd);21void Destroy();2223void Init(); // Should be called from the thread itself.24thread_return_t ThreadStart();2526uptr stack_top();27uptr stack_bottom();28uptr tls_begin() { return tls_begin_; }29uptr tls_end() { return tls_end_; }30bool IsMainThread() { return start_routine_ == nullptr; }3132bool AddrIsInStack(uptr addr);3334void StartSwitchFiber(uptr bottom, uptr size);35void FinishSwitchFiber(uptr *bottom_old, uptr *size_old);3637NsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; }3839int destructor_iterations_;40__sanitizer_sigset_t starting_sigset_;4142private:43void SetThreadStackAndTls();44void ClearShadowForThreadStackAndTLS();45struct StackBounds {46uptr bottom;47uptr top;48};49StackBounds GetStackBounds() const;5051thread_callback_t start_routine_;52void *arg_;5354bool stack_switching_;5556StackBounds stack_;57StackBounds next_stack_;5859uptr tls_begin_;60uptr tls_end_;6162NsanThreadLocalMallocStorage malloc_storage_;63};6465NsanThread *GetCurrentThread();66void SetCurrentThread(NsanThread *t);67void NsanTSDInit(void (*destructor)(void *tsd));68void NsanTSDDtor(void *tsd);6970} // namespace __nsan7172#endif // NSAN_THREAD_H737475