LLDB  mainline
PipeWindows.h
Go to the documentation of this file.
1 //===-- PipeWindows.h -------------------------------------------*- C++ -*-===//
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 liblldb_Host_windows_PipeWindows_h_
10 #define liblldb_Host_windows_PipeWindows_h_
11 
12 #include "lldb/Host/PipeBase.h"
14 
15 namespace lldb_private {
16 
17 /// \class Pipe PipeWindows.h "lldb/Host/windows/PipeWindows.h"
18 /// A windows-based implementation of Pipe, a class that abtracts
19 /// unix style pipes.
20 ///
21 /// A class that abstracts the LLDB core from host pipe functionality.
22 class PipeWindows : public PipeBase {
23 public:
24  static const int kInvalidDescriptor = -1;
25 
26 public:
27  PipeWindows();
29  ~PipeWindows() override;
30 
31  // Create an unnamed pipe.
32  Status CreateNew(bool child_process_inherit) override;
33 
34  // Create a named pipe.
35  Status CreateNewNamed(bool child_process_inherit);
36  Status CreateNew(llvm::StringRef name, bool child_process_inherit) override;
37  Status CreateWithUniqueName(llvm::StringRef prefix,
38  bool child_process_inherit,
39  llvm::SmallVectorImpl<char> &name) override;
40  Status OpenAsReader(llvm::StringRef name,
41  bool child_process_inherit) override;
42  Status
43  OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
44  const std::chrono::microseconds &timeout) override;
45 
46  bool CanRead() const override;
47  bool CanWrite() const override;
48 
49  lldb::pipe_t GetReadPipe() const override { return lldb::pipe_t(m_read); }
50  lldb::pipe_t GetWritePipe() const override { return lldb::pipe_t(m_write); }
51 
52  int GetReadFileDescriptor() const override;
53  int GetWriteFileDescriptor() const override;
54  int ReleaseReadFileDescriptor() override;
55  int ReleaseWriteFileDescriptor() override;
56  void CloseReadFileDescriptor() override;
57  void CloseWriteFileDescriptor() override;
58 
59  void Close() override;
60 
61  Status Delete(llvm::StringRef name) override;
62 
63  Status Write(const void *buf, size_t size, size_t &bytes_written) override;
64  Status ReadWithTimeout(void *buf, size_t size,
65  const std::chrono::microseconds &timeout,
66  size_t &bytes_read) override;
67 
68  // PipeWindows specific methods. These allow access to the underlying OS
69  // handle.
70  HANDLE GetReadNativeHandle();
71  HANDLE GetWriteNativeHandle();
72 
73 private:
74  Status OpenNamedPipe(llvm::StringRef name, bool child_process_inherit,
75  bool is_read);
76 
77  HANDLE m_read;
78  HANDLE m_write;
79 
80  int m_read_fd;
82 
83  OVERLAPPED m_read_overlapped;
84  OVERLAPPED m_write_overlapped;
85 };
86 
87 } // namespace lldb_private
88 
89 #endif // liblldb_Host_posix_PipePosix_h_
lldb_private::PipeWindows
Definition: PipeWindows.h:22
lldb_private::PipeWindows::~PipeWindows
~PipeWindows() override
Definition: PipeWindows.cpp:64
lldb_private::PipeWindows::m_read_overlapped
OVERLAPPED m_read_overlapped
Definition: PipeWindows.h:83
lldb_private::PipeWindows::Write
Status Write(const void *buf, size_t size, size_t &bytes_written) override
Definition: PipeWindows.cpp:320
lldb_private::PipeWindows::ReadWithTimeout
Status ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override
Definition: PipeWindows.cpp:276
lldb_private::PipeWindows::GetWriteFileDescriptor
int GetWriteFileDescriptor() const override
Definition: PipeWindows.cpp:212
lldb_private::PipeWindows::GetReadPipe
lldb::pipe_t GetReadPipe() const override
Definition: PipeWindows.h:49
lldb_private::PipeWindows::m_read_fd
int m_read_fd
Definition: PipeWindows.h:80
lldb_private::PipeWindows::ReleaseWriteFileDescriptor
int ReleaseWriteFileDescriptor() override
Definition: PipeWindows.cpp:226
lldb_private::PipeBase
Definition: PipeBase.h:21
lldb::pipe_t
int pipe_t
Definition: lldb-types.h:64
lldb_private::PipeWindows::CanWrite
bool CanWrite() const override
Definition: PipeWindows.cpp:268
lldb_private::PipeWindows::kInvalidDescriptor
static const int kInvalidDescriptor
Definition: PipeWindows.h:24
lldb_private::PipeWindows::OpenAsWriterWithTimeout
Status OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override
Definition: PipeWindows.cpp:164
lldb_private::PipeWindows::CreateWithUniqueName
Status CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl< char > &name) override
Definition: PipeWindows.cpp:131
lldb_private::PipeWindows::CloseWriteFileDescriptor
void CloseWriteFileDescriptor() override
Definition: PipeWindows.cpp:249
lldb_private::PipeWindows::OpenNamedPipe
Status OpenNamedPipe(llvm::StringRef name, bool child_process_inherit, bool is_read)
Definition: PipeWindows.cpp:173
lldb_private::PipeWindows::m_write
HANDLE m_write
Definition: PipeWindows.h:78
lldb_private::PipeWindows::CloseReadFileDescriptor
void CloseReadFileDescriptor() override
Definition: PipeWindows.cpp:236
PipeBase.h
lldb_private::PipeWindows::Close
void Close() override
Definition: PipeWindows.cpp:259
lldb_private::PipeWindows::GetWriteNativeHandle
HANDLE GetWriteNativeHandle()
Definition: PipeWindows.cpp:274
lldb_private::PipeWindows::CreateNew
Status CreateNew(bool child_process_inherit) override
Definition: PipeWindows.cpp:66
lldb_private::Status
Definition: Status.h:44
lldb_private::PipeWindows::PipeWindows
PipeWindows()
Definition: PipeWindows.cpp:28
lldb_private::PipeWindows::OpenAsReader
Status OpenAsReader(llvm::StringRef name, bool child_process_inherit) override
Definition: PipeWindows.cpp:155
windows.h
lldb_private::PipeWindows::GetReadFileDescriptor
int GetReadFileDescriptor() const override
Definition: PipeWindows.cpp:210
lldb_private::PipeWindows::GetWritePipe
lldb::pipe_t GetWritePipe() const override
Definition: PipeWindows.h:50
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::PipeWindows::Delete
Status Delete(llvm::StringRef name) override
Definition: PipeWindows.cpp:264
lldb_private::PipeWindows::m_read
HANDLE m_read
Definition: PipeWindows.h:77
lldb_private::PipeWindows::CreateNewNamed
Status CreateNewNamed(bool child_process_inherit)
Definition: PipeWindows.cpp:84
llvm::SmallVectorImpl
Definition: Disassembler.h:42
lldb_private::PipeWindows::CanRead
bool CanRead() const override
Definition: PipeWindows.cpp:266
lldb_private::PipeWindows::ReleaseReadFileDescriptor
int ReleaseReadFileDescriptor() override
Definition: PipeWindows.cpp:214
lldb_private::PipeWindows::m_write_fd
int m_write_fd
Definition: PipeWindows.h:81
lldb_private::PipeWindows::GetReadNativeHandle
HANDLE GetReadNativeHandle()
Definition: PipeWindows.cpp:271
lldb_private::PipeWindows::m_write_overlapped
OVERLAPPED m_write_overlapped
Definition: PipeWindows.h:84