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
15namespace 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.
22class PipeWindows : public PipeBase {
23public:
24 static const int kInvalidDescriptor = -1;
25
26public:
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 CreateNew(llvm::StringRef name, bool child_process_inherit) override;
36 Status CreateWithUniqueName(llvm::StringRef prefix,
37 bool child_process_inherit,
38 llvm::SmallVectorImpl<char> &name) override;
39 Status OpenAsReader(llvm::StringRef name,
40 bool child_process_inherit) override;
41 Status
42 OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
43 const std::chrono::microseconds &timeout) override;
44
45 bool CanRead() const override;
46 bool CanWrite() const override;
47
48 lldb::pipe_t GetReadPipe() const override { return lldb::pipe_t(m_read); }
49 lldb::pipe_t GetWritePipe() const override { return lldb::pipe_t(m_write); }
50
51 int GetReadFileDescriptor() const override;
52 int GetWriteFileDescriptor() const override;
53 int ReleaseReadFileDescriptor() override;
54 int ReleaseWriteFileDescriptor() override;
55 void CloseReadFileDescriptor() override;
56 void CloseWriteFileDescriptor() override;
57
58 void Close() override;
59
60 Status Delete(llvm::StringRef name) override;
61
62 Status WriteWithTimeout(const void *buf, size_t size,
63 const std::chrono::microseconds &timeout,
64 size_t &bytes_written) override;
65 Status ReadWithTimeout(void *buf, size_t size,
66 const std::chrono::microseconds &timeout,
67 size_t &bytes_read) override;
68
69 // PipeWindows specific methods. These allow access to the underlying OS
70 // handle.
71 HANDLE GetReadNativeHandle();
72 HANDLE GetWriteNativeHandle();
73
74private:
75 Status OpenNamedPipe(llvm::StringRef name, bool child_process_inherit,
76 bool is_read);
77
78 HANDLE m_read;
79 HANDLE m_write;
80
83
86};
87
88} // namespace lldb_private
89
90#endif // liblldb_Host_posix_PipePosix_h_
bool CanWrite() const override
Status OpenAsReader(llvm::StringRef name, bool child_process_inherit) override
Status CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl< char > &name) override
Status Delete(llvm::StringRef name) override
int ReleaseReadFileDescriptor() override
void CloseReadFileDescriptor() override
OVERLAPPED m_write_overlapped
Definition: PipeWindows.h:85
Status ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override
void CloseWriteFileDescriptor() override
OVERLAPPED m_read_overlapped
Definition: PipeWindows.h:84
static const int kInvalidDescriptor
Definition: PipeWindows.h:24
lldb::pipe_t GetWritePipe() const override
Definition: PipeWindows.h:49
Status CreateNew(bool child_process_inherit) override
Definition: PipeWindows.cpp:69
Status WriteWithTimeout(const void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_written) override
Status OpenNamedPipe(llvm::StringRef name, bool child_process_inherit, bool is_read)
Status OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override
lldb::pipe_t GetReadPipe() const override
Definition: PipeWindows.h:48
int ReleaseWriteFileDescriptor() override
int GetWriteFileDescriptor() const override
int GetReadFileDescriptor() const override
bool CanRead() const override
An error handling class.
Definition: Status.h:44
A class that represents a running process on the host machine.
int pipe_t
Definition: lldb-types.h:64