LLDB
mainline
llvm-project
lldb
source
Host
posix
HostThreadPosix.cpp
Go to the documentation of this file.
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
HostThreadPosix::HostThreadPosix() =
default
;
19
20
HostThreadPosix::HostThreadPosix(
lldb::thread_t
thread)
21
:
HostNativeThreadBase
(thread) {}
22
23
HostThreadPosix::~HostThreadPosix
() =
default
;
24
25
Status
HostThreadPosix::Join
(
lldb::thread_result_t
*result) {
26
Status
error
;
27
if
(
IsJoinable
()) {
28
int
err = ::pthread_join(
m_thread
, result);
29
error
.SetError(err,
lldb::eErrorTypePOSIX
);
30
}
else
{
31
if
(result)
32
*result =
nullptr
;
33
error
.SetError(EINVAL,
eErrorTypePOSIX
);
34
}
35
36
Reset
();
37
return
error
;
38
}
39
40
Status
HostThreadPosix::Cancel
() {
41
Status
error
;
42
if
(
IsJoinable
()) {
43
#ifndef __FreeBSD__
44
llvm_unreachable(
"someone is calling HostThread::Cancel()"
);
45
#else
46
int
err = ::pthread_cancel(
m_thread
);
47
error
.SetError(err,
eErrorTypePOSIX
);
48
#endif
49
}
50
return
error
;
51
}
52
53
Status
HostThreadPosix::Detach
() {
54
Status
error
;
55
if
(
IsJoinable
()) {
56
int
err = ::pthread_detach(
m_thread
);
57
error
.SetError(err,
eErrorTypePOSIX
);
58
}
59
Reset
();
60
return
error
;
61
}
lldb_private::HostThreadPosix::Join
Status Join(lldb::thread_result_t *result) override
Definition:
HostThreadPosix.cpp:25
lldb_private::HostNativeThreadBase
Definition:
HostNativeThreadBase.h:24
lldb::eErrorTypePOSIX
@ eErrorTypePOSIX
POSIX error codes.
Definition:
lldb-enumerations.h:310
lldb_private::HostThreadPosix::Cancel
Status Cancel() override
Definition:
HostThreadPosix.cpp:40
error
static llvm::raw_ostream & error(Stream &strm)
Definition:
CommandReturnObject.cpp:17
lldb::thread_t
pthread_t thread_t
Definition:
lldb-types.h:58
lldb_private::HostNativeThreadBase::IsJoinable
virtual bool IsJoinable() const
Definition:
HostNativeThreadBase.cpp:32
lldb_private::Status
Definition:
Status.h:44
lldb::thread_result_t
void * thread_result_t
Definition:
lldb-types.h:62
lldb_private::HostThreadPosix::Detach
Status Detach()
Definition:
HostThreadPosix.cpp:53
lldb_private::HostNativeThreadBase::Reset
virtual void Reset()
Definition:
HostNativeThreadBase.cpp:36
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition:
SBCommandInterpreterRunOptions.h:16
lldb_private::HostNativeThreadBase::m_thread
lldb::thread_t m_thread
Definition:
HostNativeThreadBase.h:48
lldb_private::HostThreadPosix::~HostThreadPosix
~HostThreadPosix() override
HostThreadPosix.h
lldb
Definition:
SBAddress.h:15
Generated on Wed Jul 20 2022 21:29:09 for LLDB by
1.8.17