llvm/compiler-rt/lib/asan/asan_thread.cpp

//===-- asan_thread.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer, an address sanity checker.
//
// Thread-related code.
//===----------------------------------------------------------------------===//
#include "asan_thread.h"

#include "asan_allocator.h"
#include "asan_interceptors.h"
#include "asan_mapping.h"
#include "asan_poisoning.h"
#include "asan_stack.h"
#include "lsan/lsan_common.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"

namespace __asan {

// AsanThreadContext implementation.

void AsanThreadContext::OnCreated(void *arg) {}

void AsanThreadContext::OnFinished() {}

static ThreadRegistry *asan_thread_registry;
static ThreadArgRetval *thread_data;

static Mutex mu_for_thread_context;
// TODO(leonardchan@): It should be possible to make LowLevelAllocator
// threadsafe and consolidate this one into the GlobalLoweLevelAllocator.
// We should be able to do something similar to what's in
// sanitizer_stack_store.cpp.
static LowLevelAllocator allocator_for_thread_context;

static ThreadContextBase *GetAsanThreadContext(u32 tid) {}

static void InitThreads() {}

ThreadRegistry &asanThreadRegistry() {}

ThreadArgRetval &asanThreadArgRetval() {}

AsanThreadContext *GetThreadContextByTidLocked(u32 tid) {}

// AsanThread implementation.

AsanThread *AsanThread::Create(const void *start_data, uptr data_size,
                               u32 parent_tid, StackTrace *stack,
                               bool detached) {}

void AsanThread::GetStartData(void *out, uptr out_size) const {}

void AsanThread::TSDDtor(void *tsd) {}

void AsanThread::Destroy() {}

void AsanThread::StartSwitchFiber(FakeStack **fake_stack_save, uptr bottom,
                                  uptr size) {}

void AsanThread::FinishSwitchFiber(FakeStack *fake_stack_save, uptr *bottom_old,
                                   uptr *size_old) {}

inline AsanThread::StackBounds AsanThread::GetStackBounds() const {}

uptr AsanThread::stack_top() {}

uptr AsanThread::stack_bottom() {}

uptr AsanThread::stack_size() {}

// We want to create the FakeStack lazily on the first use, but not earlier
// than the stack size is known and the procedure has to be async-signal safe.
FakeStack *AsanThread::AsyncSignalSafeLazyInitFakeStack() {}

void AsanThread::Init(const InitOptions *options) {}

// Fuchsia doesn't use ThreadStart.
// asan_fuchsia.c definies CreateMainThread and SetThreadStackAndTls.
#if !SANITIZER_FUCHSIA

void AsanThread::ThreadStart(tid_t os_id) {}

AsanThread *CreateMainThread() {}

// This implementation doesn't use the argument, which is just passed down
// from the caller of Init (which see, above).  It's only there to support
// OS-specific implementations that need more information passed through.
void AsanThread::SetThreadStackAndTls(const InitOptions *options) {}

#endif  // !SANITIZER_FUCHSIA

void AsanThread::ClearShadowForThreadStackAndTLS() {}

bool AsanThread::GetStackFrameAccessByAddr(uptr addr,
                                           StackFrameAccess *access) {}

uptr AsanThread::GetStackVariableShadowStart(uptr addr) {}

bool AsanThread::AddrIsInStack(uptr addr) {}

static bool ThreadStackContainsAddress(ThreadContextBase *tctx_base,
                                       void *addr) {}

AsanThread *GetCurrentThread() {}

void SetCurrentThread(AsanThread *t) {}

u32 GetCurrentTidOrInvalid() {}

AsanThread *FindThreadByStackAddress(uptr addr) {}

void EnsureMainThreadIDIsCorrect() {}

__asan::AsanThread *GetAsanThreadByOsIDLocked(tid_t os_id) {}
}  // namespace __asan

// --- Implementation of LSan-specific functions --- {{{1
namespace __lsan {
void LockThreads() {}

void UnlockThreads() {}

static ThreadRegistry *GetAsanThreadRegistryLocked() {}

void EnsureMainThreadIDIsCorrect() {}

bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
                           uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
                           uptr *cache_end, DTLS **dtls) {}

void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {}

void GetThreadExtraStackRangesLocked(tid_t os_id,
                                     InternalMmapVector<Range> *ranges) {}

void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges) {}

void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs) {}

void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads) {}

}  // namespace __lsan

// ---------------------- Interface ---------------- {{{1
usingnamespace__asan;

extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE
void __sanitizer_start_switch_fiber(void **fakestacksave, const void *bottom,
                                    uptr size) {}

SANITIZER_INTERFACE_ATTRIBUTE
void __sanitizer_finish_switch_fiber(void *fakestack, const void **bottom_old,
                                     uptr *size_old) {}
}