brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · a9cbb69 Raw
64 lines · cpp
1//===-- HostNativeThreadBase.cpp ------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/Host/HostNativeThreadBase.h"10#include "lldb/Host/HostInfo.h"11#include "lldb/Host/ThreadLauncher.h"12#include "lldb/Utility/LLDBLog.h"13#include "lldb/Utility/Log.h"14 15#include "llvm/ADT/StringExtras.h"16#include "llvm/Support/Threading.h"17 18using namespace lldb;19using namespace lldb_private;20 21HostNativeThreadBase::HostNativeThreadBase(thread_t thread)22    : m_thread(thread) {}23 24lldb::thread_t HostNativeThreadBase::GetSystemHandle() const {25  return m_thread;26}27 28lldb::thread_result_t HostNativeThreadBase::GetResult() const {29  return m_result;30}31 32bool HostNativeThreadBase::IsJoinable() const {33  return m_thread != LLDB_INVALID_HOST_THREAD;34}35 36void HostNativeThreadBase::Reset() {37  m_thread = LLDB_INVALID_HOST_THREAD;38  m_result = 0; // NOLINT(modernize-use-nullptr)39}40 41bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const {42  return m_thread == thread;43}44 45lldb::thread_t HostNativeThreadBase::Release() {46  lldb::thread_t result = m_thread;47  m_thread = LLDB_INVALID_HOST_THREAD;48  m_result = 0; // NOLINT(modernize-use-nullptr)49 50  return result;51}52 53lldb::thread_result_t54HostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg) {55  std::unique_ptr<ThreadLauncher::HostThreadCreateInfo> info_up(56      (ThreadLauncher::HostThreadCreateInfo *)arg);57  llvm::set_thread_name(info_up->thread_name);58 59  Log *log = GetLog(LLDBLog::Thread);60  LLDB_LOGF(log, "thread created");61 62  return info_up->impl();63}64