LLDB mainline
|
A posix-based implementation of Pipe, a class that abtracts unix style pipes. More...
#include "lldb/Host/posix/PipePosix.h"
Public Member Functions | |
PipePosix () | |
PipePosix (lldb::pipe_t read, lldb::pipe_t write) | |
PipePosix (const PipePosix &)=delete | |
PipePosix (PipePosix &&pipe_posix) | |
PipePosix & | operator= (const PipePosix &)=delete |
PipePosix & | operator= (PipePosix &&pipe_posix) |
~PipePosix () override | |
Status | CreateNew (bool child_process_inherit) override |
Status | CreateNew (llvm::StringRef name, bool child_process_inherit) override |
Status | CreateWithUniqueName (llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl< char > &name) override |
Status | OpenAsReader (llvm::StringRef name, bool child_process_inherit) override |
Status | OpenAsWriterWithTimeout (llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override |
bool | CanRead () const override |
bool | CanWrite () const override |
lldb::pipe_t | GetReadPipe () const override |
lldb::pipe_t | GetWritePipe () const override |
int | GetReadFileDescriptor () const override |
int | GetWriteFileDescriptor () const override |
int | ReleaseReadFileDescriptor () override |
int | ReleaseWriteFileDescriptor () override |
void | CloseReadFileDescriptor () override |
void | CloseWriteFileDescriptor () override |
void | Close () override |
Status | Delete (llvm::StringRef name) override |
Status | WriteWithTimeout (const void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_written) override |
Status | ReadWithTimeout (void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override |
Public Member Functions inherited from lldb_private::PipeBase | |
virtual | ~PipeBase () |
virtual Status | CreateNew (bool child_process_inherit)=0 |
virtual Status | CreateNew (llvm::StringRef name, bool child_process_inherit)=0 |
virtual Status | CreateWithUniqueName (llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl< char > &name)=0 |
virtual Status | OpenAsReader (llvm::StringRef name, bool child_process_inherit)=0 |
Status | OpenAsWriter (llvm::StringRef name, bool child_process_inherit) |
virtual Status | OpenAsWriterWithTimeout (llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout)=0 |
virtual bool | CanRead () const =0 |
virtual bool | CanWrite () const =0 |
virtual lldb::pipe_t | GetReadPipe () const =0 |
virtual lldb::pipe_t | GetWritePipe () const =0 |
virtual int | GetReadFileDescriptor () const =0 |
virtual int | GetWriteFileDescriptor () const =0 |
virtual int | ReleaseReadFileDescriptor ()=0 |
virtual int | ReleaseWriteFileDescriptor ()=0 |
virtual void | CloseReadFileDescriptor ()=0 |
virtual void | CloseWriteFileDescriptor ()=0 |
virtual void | Close ()=0 |
virtual Status | Delete (llvm::StringRef name)=0 |
virtual Status | WriteWithTimeout (const void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_written)=0 |
Status | Write (const void *buf, size_t size, size_t &bytes_written) |
virtual Status | ReadWithTimeout (void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read)=0 |
Status | Read (void *buf, size_t size, size_t &bytes_read) |
Static Public Attributes | |
static int | kInvalidDescriptor = -1 |
Private Member Functions | |
bool | CanReadUnlocked () const |
bool | CanWriteUnlocked () const |
int | GetReadFileDescriptorUnlocked () const |
int | GetWriteFileDescriptorUnlocked () const |
int | ReleaseReadFileDescriptorUnlocked () |
int | ReleaseWriteFileDescriptorUnlocked () |
void | CloseReadFileDescriptorUnlocked () |
void | CloseWriteFileDescriptorUnlocked () |
void | CloseUnlocked () |
Private Attributes | |
int | m_fds [2] |
std::mutex | m_read_mutex |
Mutexes for m_fds;. | |
std::mutex | m_write_mutex |
A posix-based implementation of Pipe, a class that abtracts unix style pipes.
A class that abstracts the LLDB core from host pipe functionality.
Definition at line 21 of file PipePosix.h.
PipePosix::PipePosix | ( | ) |
Definition at line 56 of file PipePosix.cpp.
PipePosix::PipePosix | ( | lldb::pipe_t | read, |
lldb::pipe_t | write | ||
) |
Definition at line 59 of file PipePosix.cpp.
|
delete |
PipePosix::PipePosix | ( | PipePosix && | pipe_posix | ) |
Definition at line 62 of file PipePosix.cpp.
|
override |
Definition at line 78 of file PipePosix.cpp.
References Close().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 262 of file PipePosix.cpp.
References CanReadUnlocked(), and m_read_mutex.
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
private |
Definition at line 267 of file PipePosix.cpp.
References kInvalidDescriptor, m_fds, and READ.
Referenced by CanRead(), CloseReadFileDescriptorUnlocked(), CreateNew(), OpenAsReader(), OpenAsWriterWithTimeout(), and ReadWithTimeout().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 271 of file PipePosix.cpp.
References CanWriteUnlocked(), and m_write_mutex.
Referenced by lldb_private::ConnectionFileDescriptor::Disconnect(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
private |
Definition at line 276 of file PipePosix.cpp.
References kInvalidDescriptor, m_fds, and WRITE.
Referenced by CanWrite(), CloseWriteFileDescriptorUnlocked(), CreateNew(), OpenAsReader(), OpenAsWriterWithTimeout(), and WriteWithTimeout().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 248 of file PipePosix.cpp.
References CloseUnlocked(), m_read_mutex, and m_write_mutex.
Referenced by lldb_private::ConnectionFileDescriptor::CloseCommandPipe(), lldb_private::ConnectionFileDescriptor::Disconnect(), lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess(), lldb_private::MainLoopPosix::~MainLoopPosix(), and ~PipePosix().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 280 of file PipePosix.cpp.
References CloseReadFileDescriptorUnlocked(), and m_read_mutex.
Referenced by lldb_private::ProcessLauncherPosixFork::LaunchProcess().
|
private |
Definition at line 284 of file PipePosix.cpp.
References CanReadUnlocked(), kInvalidDescriptor, m_fds, and READ.
Referenced by CloseReadFileDescriptor(), and CloseUnlocked().
|
private |
Definition at line 253 of file PipePosix.cpp.
References CloseReadFileDescriptorUnlocked(), and CloseWriteFileDescriptorUnlocked().
Referenced by Close(), and CreateNew().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 291 of file PipePosix.cpp.
References CloseWriteFileDescriptorUnlocked(), and m_write_mutex.
Referenced by lldb_private::ProcessLauncherPosixFork::LaunchProcess(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
private |
Definition at line 296 of file PipePosix.cpp.
References CanWriteUnlocked(), kInvalidDescriptor, m_fds, and WRITE.
Referenced by CloseUnlocked(), and CloseWriteFileDescriptor().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 80 of file PipePosix.cpp.
References CanReadUnlocked(), CanWriteUnlocked(), CloseUnlocked(), lldb::eErrorTypePOSIX, error(), kInvalidDescriptor, m_fds, m_read_mutex, m_write_mutex, READ, SetCloexecFlag(), and WRITE.
Referenced by CreateWithUniqueName(), lldb_private::ProcessLauncherPosixFork::LaunchProcess(), lldb_private::MainLoopPosix::MainLoopPosix(), lldb_private::ConnectionFileDescriptor::OpenCommandPipe(), lldb_private::ScriptInterpreterIORedirect::ScriptInterpreterIORedirect(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 110 of file PipePosix.cpp.
References CanReadUnlocked(), CanWriteUnlocked(), error(), m_read_mutex, and m_write_mutex.
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 122 of file PipePosix.cpp.
References lldb_private::FileSpec::AppendPathComponent(), CreateNew(), error(), and lldb_private::FileSpec::GetPath().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 258 of file PipePosix.cpp.
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 208 of file PipePosix.cpp.
References GetReadFileDescriptorUnlocked(), and m_read_mutex.
Referenced by lldb_private::ConnectionFileDescriptor::BytesAvailable(), GetReadPipe(), lldb_private::ProcessLauncherPosixFork::LaunchProcess(), lldb_private::MainLoopPosix::MainLoopPosix(), lldb_private::ConnectionFileDescriptor::OpenCommandPipe(), lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess(), and lldb_private::MainLoopPosix::~MainLoopPosix().
|
private |
Definition at line 213 of file PipePosix.cpp.
Referenced by GetReadFileDescriptor(), and ReadWithTimeout().
|
inlineoverridevirtual |
Implements lldb_private::PipeBase.
Definition at line 48 of file PipePosix.h.
References GetReadFileDescriptor().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 217 of file PipePosix.cpp.
References GetWriteFileDescriptorUnlocked(), and m_write_mutex.
Referenced by lldb_private::ConnectionFileDescriptor::Disconnect(), GetWritePipe(), and lldb_private::ConnectionFileDescriptor::OpenCommandPipe().
|
private |
Definition at line 222 of file PipePosix.cpp.
Referenced by GetWriteFileDescriptor(), and WriteWithTimeout().
|
inlineoverridevirtual |
Implements lldb_private::PipeBase.
Definition at line 51 of file PipePosix.h.
References GetWriteFileDescriptor().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 147 of file PipePosix.cpp.
References CanReadUnlocked(), CanWriteUnlocked(), error(), lldb_private::FileSystem::Instance(), m_fds, m_read_mutex, m_write_mutex, O_NONBLOCK, lldb_private::FileSystem::Open(), and READ.
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 169 of file PipePosix.cpp.
References CanReadUnlocked(), CanWriteUnlocked(), lldb::eErrorTypePOSIX, m_fds, m_write_mutex, Now(), O_NONBLOCK, OPEN_WRITER_SLEEP_TIMEOUT_MSECS, and WRITE.
Definition at line 67 of file PipePosix.cpp.
References m_fds, m_read_mutex, m_write_mutex, READ, and WRITE.
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 303 of file PipePosix.cpp.
References CanReadUnlocked(), lldb::eErrorTypePOSIX, error(), SelectHelper::FDSetRead(), GetReadFileDescriptorUnlocked(), m_read_mutex, SelectHelper::Select(), and SelectHelper::SetTimeout().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 226 of file PipePosix.cpp.
References m_read_mutex, and ReleaseReadFileDescriptorUnlocked().
Referenced by lldb_private::ScriptInterpreterIORedirect::ScriptInterpreterIORedirect().
|
private |
Definition at line 231 of file PipePosix.cpp.
References kInvalidDescriptor, m_fds, and READ.
Referenced by ReleaseReadFileDescriptor().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 237 of file PipePosix.cpp.
References m_write_mutex, and ReleaseWriteFileDescriptorUnlocked().
Referenced by lldb_private::ProcessLauncherPosixFork::LaunchProcess(), and lldb_private::ScriptInterpreterIORedirect::ScriptInterpreterIORedirect().
|
private |
Definition at line 242 of file PipePosix.cpp.
References kInvalidDescriptor, m_fds, and WRITE.
Referenced by ReleaseWriteFileDescriptor().
|
overridevirtual |
Implements lldb_private::PipeBase.
Definition at line 338 of file PipePosix.cpp.
References CanWriteUnlocked(), lldb::eErrorTypePOSIX, error(), SelectHelper::FDSetWrite(), GetWriteFileDescriptorUnlocked(), m_write_mutex, SelectHelper::Select(), and SelectHelper::SetTimeout().
|
static |
Definition at line 23 of file PipePosix.h.
Referenced by CanReadUnlocked(), CanWriteUnlocked(), CloseReadFileDescriptorUnlocked(), CloseWriteFileDescriptorUnlocked(), CreateNew(), ReleaseReadFileDescriptorUnlocked(), and ReleaseWriteFileDescriptorUnlocked().
|
private |
Definition at line 86 of file PipePosix.h.
Referenced by CanReadUnlocked(), CanWriteUnlocked(), CloseReadFileDescriptorUnlocked(), CloseWriteFileDescriptorUnlocked(), CreateNew(), GetReadFileDescriptorUnlocked(), GetWriteFileDescriptorUnlocked(), OpenAsReader(), OpenAsWriterWithTimeout(), operator=(), ReleaseReadFileDescriptorUnlocked(), and ReleaseWriteFileDescriptorUnlocked().
|
mutableprivate |
Mutexes for m_fds;.
Definition at line 89 of file PipePosix.h.
Referenced by CanRead(), Close(), CloseReadFileDescriptor(), CreateNew(), GetReadFileDescriptor(), OpenAsReader(), operator=(), ReadWithTimeout(), and ReleaseReadFileDescriptor().
|
mutableprivate |
Definition at line 90 of file PipePosix.h.
Referenced by CanWrite(), Close(), CloseWriteFileDescriptor(), CreateNew(), GetWriteFileDescriptor(), OpenAsReader(), OpenAsWriterWithTimeout(), operator=(), ReleaseWriteFileDescriptor(), and WriteWithTimeout().