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-exception |
6 | // |
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 | |
18 | using namespace lldb; |
19 | using namespace lldb_private; |
20 | |
21 | HostNativeThreadBase::HostNativeThreadBase(thread_t thread) |
22 | : m_thread(thread) {} |
23 | |
24 | lldb::thread_t HostNativeThreadBase::GetSystemHandle() const { |
25 | return m_thread; |
26 | } |
27 | |
28 | lldb::thread_result_t HostNativeThreadBase::GetResult() const { |
29 | return m_result; |
30 | } |
31 | |
32 | bool HostNativeThreadBase::IsJoinable() const { |
33 | return m_thread != LLDB_INVALID_HOST_THREAD; |
34 | } |
35 | |
36 | void HostNativeThreadBase::Reset() { |
37 | m_thread = LLDB_INVALID_HOST_THREAD; |
38 | m_result = 0; // NOLINT(modernize-use-nullptr) |
39 | } |
40 | |
41 | bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const { |
42 | return m_thread == thread; |
43 | } |
44 | |
45 | lldb::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 | |
53 | lldb::thread_result_t |
54 | HostNativeThreadBase::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(mask: LLDBLog::Thread); |
60 | LLDB_LOGF(log, "thread created"); |
61 | |
62 | return info_up->impl(); |
63 | } |
64 |