1cfca06d7SDimitry Andric //===-- HostNativeThreadBase.cpp ------------------------------------------===// 2205afe67SEd Maste // 35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6205afe67SEd Maste // 7205afe67SEd Maste //===----------------------------------------------------------------------===// 8205afe67SEd Maste 914f1b3e8SDimitry Andric #include "lldb/Host/HostNativeThreadBase.h" 10205afe67SEd Maste #include "lldb/Host/HostInfo.h" 11205afe67SEd Maste #include "lldb/Host/ThreadLauncher.h" 12145449b1SDimitry Andric #include "lldb/Utility/LLDBLog.h" 1374a628f7SDimitry Andric #include "lldb/Utility/Log.h" 1474a628f7SDimitry Andric 15205afe67SEd Maste #include "llvm/ADT/StringExtras.h" 1674a628f7SDimitry Andric #include "llvm/Support/Threading.h" 17205afe67SEd Maste 18205afe67SEd Maste using namespace lldb; 19205afe67SEd Maste using namespace lldb_private; 20205afe67SEd Maste HostNativeThreadBase(thread_t thread)21205afe67SEd MasteHostNativeThreadBase::HostNativeThreadBase(thread_t thread) 22145449b1SDimitry Andric : m_thread(thread) {} 23205afe67SEd Maste GetSystemHandle() const2414f1b3e8SDimitry Andriclldb::thread_t HostNativeThreadBase::GetSystemHandle() const { 25205afe67SEd Maste return m_thread; 26205afe67SEd Maste } 27205afe67SEd Maste GetResult() const2814f1b3e8SDimitry Andriclldb::thread_result_t HostNativeThreadBase::GetResult() const { 29205afe67SEd Maste return m_result; 30205afe67SEd Maste } 31205afe67SEd Maste IsJoinable() const3214f1b3e8SDimitry Andricbool HostNativeThreadBase::IsJoinable() const { 33205afe67SEd Maste return m_thread != LLDB_INVALID_HOST_THREAD; 34205afe67SEd Maste } 35205afe67SEd Maste Reset()3614f1b3e8SDimitry Andricvoid HostNativeThreadBase::Reset() { 37205afe67SEd Maste m_thread = LLDB_INVALID_HOST_THREAD; 386f8fc217SDimitry Andric m_result = 0; // NOLINT(modernize-use-nullptr) 39205afe67SEd Maste } 40205afe67SEd Maste EqualsThread(lldb::thread_t thread) const4194994d37SDimitry Andricbool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const { 4294994d37SDimitry Andric return m_thread == thread; 4394994d37SDimitry Andric } 4494994d37SDimitry Andric Release()4514f1b3e8SDimitry Andriclldb::thread_t HostNativeThreadBase::Release() { 46205afe67SEd Maste lldb::thread_t result = m_thread; 47205afe67SEd Maste m_thread = LLDB_INVALID_HOST_THREAD; 486f8fc217SDimitry Andric m_result = 0; // NOLINT(modernize-use-nullptr) 49205afe67SEd Maste 50205afe67SEd Maste return result; 51205afe67SEd Maste } 52205afe67SEd Maste 53205afe67SEd Maste lldb::thread_result_t ThreadCreateTrampoline(lldb::thread_arg_t arg)5414f1b3e8SDimitry AndricHostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg) { 55145449b1SDimitry Andric std::unique_ptr<ThreadLauncher::HostThreadCreateInfo> info_up( 56145449b1SDimitry Andric (ThreadLauncher::HostThreadCreateInfo *)arg); 57145449b1SDimitry Andric llvm::set_thread_name(info_up->thread_name); 58205afe67SEd Maste 59145449b1SDimitry Andric Log *log = GetLog(LLDBLog::Thread); 60ead24645SDimitry Andric LLDB_LOGF(log, "thread created"); 61205afe67SEd Maste 62145449b1SDimitry Andric return info_up->impl(); 63205afe67SEd Maste } 64