Path: blob/main/contrib/llvm-project/lldb/source/Host/common/HostNativeThreadBase.cpp
39606 views
//===-- HostNativeThreadBase.cpp ------------------------------------------===//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#include "lldb/Host/HostNativeThreadBase.h"9#include "lldb/Host/HostInfo.h"10#include "lldb/Host/ThreadLauncher.h"11#include "lldb/Utility/LLDBLog.h"12#include "lldb/Utility/Log.h"1314#include "llvm/ADT/StringExtras.h"15#include "llvm/Support/Threading.h"1617using namespace lldb;18using namespace lldb_private;1920HostNativeThreadBase::HostNativeThreadBase(thread_t thread)21: m_thread(thread) {}2223lldb::thread_t HostNativeThreadBase::GetSystemHandle() const {24return m_thread;25}2627lldb::thread_result_t HostNativeThreadBase::GetResult() const {28return m_result;29}3031bool HostNativeThreadBase::IsJoinable() const {32return m_thread != LLDB_INVALID_HOST_THREAD;33}3435void HostNativeThreadBase::Reset() {36m_thread = LLDB_INVALID_HOST_THREAD;37m_result = 0; // NOLINT(modernize-use-nullptr)38}3940bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const {41return m_thread == thread;42}4344lldb::thread_t HostNativeThreadBase::Release() {45lldb::thread_t result = m_thread;46m_thread = LLDB_INVALID_HOST_THREAD;47m_result = 0; // NOLINT(modernize-use-nullptr)4849return result;50}5152lldb::thread_result_t53HostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg) {54std::unique_ptr<ThreadLauncher::HostThreadCreateInfo> info_up(55(ThreadLauncher::HostThreadCreateInfo *)arg);56llvm::set_thread_name(info_up->thread_name);5758Log *log = GetLog(LLDBLog::Thread);59LLDB_LOGF(log, "thread created");6061return info_up->impl();62}636465