Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Host/posix/HostThreadPosix.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- HostThreadPosix.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/posix/HostThreadPosix.h"
10
#include "lldb/Utility/Status.h"
11
12
#include <cerrno>
13
#include <pthread.h>
14
15
using namespace lldb;
16
using namespace lldb_private;
17
18
42.9k
HostThreadPosix::HostThreadPosix() = default;
19
20
HostThreadPosix::HostThreadPosix(lldb::thread_t thread)
21
8.60k
    : HostNativeThreadBase(thread) {}
22
23
50.9k
HostThreadPosix::~HostThreadPosix() = default;
24
25
8.59k
Status HostThreadPosix::Join(lldb::thread_result_t *result) {
26
8.59k
  Status error;
27
8.59k
  if (IsJoinable()) {
28
8.59k
    int err = ::pthread_join(m_thread, result);
29
8.59k
    error.SetError(err, lldb::eErrorTypePOSIX);
30
8.59k
  } else {
31
1
    if (result)
32
0
      *result = nullptr;
33
1
    error.SetError(EINVAL, eErrorTypePOSIX);
34
1
  }
35
36
8.59k
  Reset();
37
8.59k
  return error;
38
8.59k
}
39
40
0
Status HostThreadPosix::Cancel() {
41
0
  Status error;
42
0
  if (IsJoinable()) {
43
0
#ifndef __FreeBSD__
44
0
    llvm_unreachable("someone is calling HostThread::Cancel()");
45
#else
46
    int err = ::pthread_cancel(m_thread);
47
    error.SetError(err, eErrorTypePOSIX);
48
#endif
49
0
  }
50
0
  return error;
51
0
}
52
53
0
Status HostThreadPosix::Detach() {
54
0
  Status error;
55
0
  if (IsJoinable()) {
56
0
    int err = ::pthread_detach(m_thread);
57
0
    error.SetError(err, eErrorTypePOSIX);
58
0
  }
59
0
  Reset();
60
0
  return error;
61
0
}