17aa51b79SEd Maste //===-- HostNativeThreadBase.cpp --------------------------------*- C++ -*-===// 27aa51b79SEd Maste // 37aa51b79SEd Maste // The LLVM Compiler Infrastructure 47aa51b79SEd Maste // 57aa51b79SEd Maste // This file is distributed under the University of Illinois Open Source 67aa51b79SEd Maste // License. See LICENSE.TXT for details. 77aa51b79SEd Maste // 87aa51b79SEd Maste //===----------------------------------------------------------------------===// 97aa51b79SEd Maste 10435933ddSDimitry Andric #include "lldb/Host/HostNativeThreadBase.h" 117aa51b79SEd Maste #include "lldb/Host/HostInfo.h" 127aa51b79SEd Maste #include "lldb/Host/ThreadLauncher.h" 13f678e45dSDimitry Andric #include "lldb/Utility/Log.h" 14f678e45dSDimitry Andric 157aa51b79SEd Maste #include "llvm/ADT/StringExtras.h" 16f678e45dSDimitry Andric #include "llvm/Support/Threading.h" 177aa51b79SEd Maste 187aa51b79SEd Maste using namespace lldb; 197aa51b79SEd Maste using namespace lldb_private; 207aa51b79SEd Maste HostNativeThreadBase()217aa51b79SEd MasteHostNativeThreadBase::HostNativeThreadBase() 22435933ddSDimitry Andric : m_thread(LLDB_INVALID_HOST_THREAD), m_result(0) {} 237aa51b79SEd Maste HostNativeThreadBase(thread_t thread)247aa51b79SEd MasteHostNativeThreadBase::HostNativeThreadBase(thread_t thread) 25435933ddSDimitry Andric : m_thread(thread), m_result(0) {} 267aa51b79SEd Maste GetSystemHandle() const27435933ddSDimitry Andriclldb::thread_t HostNativeThreadBase::GetSystemHandle() const { 287aa51b79SEd Maste return m_thread; 297aa51b79SEd Maste } 307aa51b79SEd Maste GetResult() const31435933ddSDimitry Andriclldb::thread_result_t HostNativeThreadBase::GetResult() const { 327aa51b79SEd Maste return m_result; 337aa51b79SEd Maste } 347aa51b79SEd Maste IsJoinable() const35435933ddSDimitry Andricbool HostNativeThreadBase::IsJoinable() const { 367aa51b79SEd Maste return m_thread != LLDB_INVALID_HOST_THREAD; 377aa51b79SEd Maste } 387aa51b79SEd Maste Reset()39435933ddSDimitry Andricvoid HostNativeThreadBase::Reset() { 407aa51b79SEd Maste m_thread = LLDB_INVALID_HOST_THREAD; 417aa51b79SEd Maste m_result = 0; 427aa51b79SEd Maste } 437aa51b79SEd Maste EqualsThread(lldb::thread_t thread) const44*b5893f02SDimitry Andricbool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const { 45*b5893f02SDimitry Andric return m_thread == thread; 46*b5893f02SDimitry Andric } 47*b5893f02SDimitry Andric Release()48435933ddSDimitry Andriclldb::thread_t HostNativeThreadBase::Release() { 497aa51b79SEd Maste lldb::thread_t result = m_thread; 507aa51b79SEd Maste m_thread = LLDB_INVALID_HOST_THREAD; 517aa51b79SEd Maste m_result = 0; 527aa51b79SEd Maste 537aa51b79SEd Maste return result; 547aa51b79SEd Maste } 557aa51b79SEd Maste 567aa51b79SEd Maste lldb::thread_result_t ThreadCreateTrampoline(lldb::thread_arg_t arg)57435933ddSDimitry AndricHostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg) { 58435933ddSDimitry Andric ThreadLauncher::HostThreadCreateInfo *info = 59435933ddSDimitry Andric (ThreadLauncher::HostThreadCreateInfo *)arg; 60f678e45dSDimitry Andric llvm::set_thread_name(info->thread_name); 617aa51b79SEd Maste 627aa51b79SEd Maste thread_func_t thread_fptr = info->thread_fptr; 637aa51b79SEd Maste thread_arg_t thread_arg = info->thread_arg; 647aa51b79SEd Maste 657aa51b79SEd Maste Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); 667aa51b79SEd Maste if (log) 677aa51b79SEd Maste log->Printf("thread created"); 687aa51b79SEd Maste 697aa51b79SEd Maste delete info; 707aa51b79SEd Maste return thread_fptr(thread_arg); 717aa51b79SEd Maste } 72