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 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
73private:
74 Status OpenNamedPipe(llvm::StringRef name, bool child_process_inherit,
75 bool is_read);
76
77 HANDLE m_read;
78 HANDLE m_write;
79
82
85};
86
87} // namespace lldb_private
88
89#endif // liblldb_Host_posix_PipePosix_h_
bool CanWrite() const override
Status Write(const void *buf, size_t size, size_t &bytes_written) 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:84
Status ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override
void CloseWriteFileDescriptor() override
Status CreateNewNamed(bool child_process_inherit)
Definition: PipeWindows.cpp:84
OVERLAPPED m_read_overlapped
Definition: PipeWindows.h:83
static const int kInvalidDescriptor
Definition: PipeWindows.h:24
lldb::pipe_t GetWritePipe() const override
Definition: PipeWindows.h:50
Status CreateNew(bool child_process_inherit) override
Definition: PipeWindows.cpp:66
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:49
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.
Definition: SBAttachInfo.h:14
int pipe_t
Definition: lldb-types.h:64