Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Host/common/HostNativeThreadBase.cpp
Line
Count
Source (jump to first uncovered line)
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/Log.h"
13
14
#include "llvm/ADT/StringExtras.h"
15
#include "llvm/Support/Threading.h"
16
17
using namespace lldb;
18
using namespace lldb_private;
19
20
HostNativeThreadBase::HostNativeThreadBase(thread_t thread)
21
8.60k
    : m_thread(thread), m_result(0) {} // NOLINT(modernize-use-nullptr)
22
23
0
lldb::thread_t HostNativeThreadBase::GetSystemHandle() const {
24
0
  return m_thread;
25
0
}
26
27
0
lldb::thread_result_t HostNativeThreadBase::GetResult() const {
28
0
  return m_result;
29
0
}
30
31
115k
bool HostNativeThreadBase::IsJoinable() const {
32
115k
  return m_thread != LLDB_INVALID_HOST_THREAD;
33
115k
}
34
35
14.0k
void HostNativeThreadBase::Reset() {
36
14.0k
  m_thread = LLDB_INVALID_HOST_THREAD;
37
14.0k
  m_result = 0; // NOLINT(modernize-use-nullptr)
38
14.0k
}
39
40
628k
bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const {
41
628k
  return m_thread == thread;
42
628k
}
43
44
0
lldb::thread_t HostNativeThreadBase::Release() {
45
0
  lldb::thread_t result = m_thread;
46
0
  m_thread = LLDB_INVALID_HOST_THREAD;
47
0
  m_result = 0; // NOLINT(modernize-use-nullptr)
48
49
0
  return result;
50
0
}
51
52
lldb::thread_result_t
53
8.60k
HostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg) {
54
8.60k
  ThreadLauncher::HostThreadCreateInfo *info =
55
8.60k
      (ThreadLauncher::HostThreadCreateInfo *)arg;
56
8.60k
  llvm::set_thread_name(info->thread_name);
57
58
8.60k
  thread_func_t thread_fptr = info->thread_fptr;
59
8.60k
  thread_arg_t thread_arg = info->thread_arg;
60
61
8.60k
  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
62
8.60k
  LLDB_LOGF(log, "thread created");
63
64
8.60k
  delete info;
65
8.60k
  return thread_fptr(thread_arg);
66
8.60k
}