Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Host/common/ProcessRunLock.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- ProcessRunLock.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
#ifndef _WIN32
10
#include "lldb/Host/ProcessRunLock.h"
11
12
namespace lldb_private {
13
14
6.05k
ProcessRunLock::ProcessRunLock() {
15
6.05k
  int err = ::pthread_rwlock_init(&m_rwlock, nullptr);
16
6.05k
  (void)err;
17
6.05k
}
18
19
5.80k
ProcessRunLock::~ProcessRunLock() {
20
5.80k
  int err = ::pthread_rwlock_destroy(&m_rwlock);
21
5.80k
  (void)err;
22
5.80k
}
23
24
390k
bool ProcessRunLock::ReadTryLock() {
25
390k
  ::pthread_rwlock_rdlock(&m_rwlock);
26
390k
  if (!m_running) {
27
390k
    return true;
28
390k
  }
29
8
  ::pthread_rwlock_unlock(&m_rwlock);
30
8
  return false;
31
390k
}
32
33
390k
bool ProcessRunLock::ReadUnlock() {
34
390k
  return ::pthread_rwlock_unlock(&m_rwlock) == 0;
35
390k
}
36
37
17.4k
bool ProcessRunLock::SetRunning() {
38
17.4k
  ::pthread_rwlock_wrlock(&m_rwlock);
39
17.4k
  m_running = true;
40
17.4k
  ::pthread_rwlock_unlock(&m_rwlock);
41
17.4k
  return true;
42
17.4k
}
43
44
13.7k
bool ProcessRunLock::TrySetRunning() {
45
13.7k
  bool r;
46
47
13.7k
  if (::pthread_rwlock_trywrlock(&m_rwlock) == 0) {
48
13.7k
    r = !m_running;
49
13.7k
    m_running = true;
50
13.7k
    ::pthread_rwlock_unlock(&m_rwlock);
51
13.7k
    return r;
52
13.7k
  }
53
0
  return false;
54
13.7k
}
55
56
45.0k
bool ProcessRunLock::SetStopped() {
57
45.0k
  ::pthread_rwlock_wrlock(&m_rwlock);
58
45.0k
  m_running = false;
59
45.0k
  ::pthread_rwlock_unlock(&m_rwlock);
60
45.0k
  return true;
61
45.0k
}
62
}
63
64
#endif