]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Host/posix/PipePosix.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / include / lldb / Host / posix / PipePosix.h
1 //===-- PipePosix.h ---------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_Host_posix_PipePosix_h_
11 #define liblldb_Host_posix_PipePosix_h_
12 #if defined(__cplusplus)
13
14 #include "lldb/Host/PipeBase.h"
15
16 namespace lldb_private {
17
18 //----------------------------------------------------------------------
19 /// @class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h"
20 /// @brief A posix-based implementation of Pipe, a class that abtracts
21 ///        unix style pipes.
22 ///
23 /// A class that abstracts the LLDB core from host pipe functionality.
24 //----------------------------------------------------------------------
25 class PipePosix : public PipeBase {
26 public:
27   static int kInvalidDescriptor;
28
29   PipePosix();
30   PipePosix(int read_fd, int write_fd);
31   PipePosix(const PipePosix &) = delete;
32   PipePosix(PipePosix &&pipe_posix);
33   PipePosix &operator=(const PipePosix &) = delete;
34   PipePosix &operator=(PipePosix &&pipe_posix);
35
36   ~PipePosix() override;
37
38   Error CreateNew(bool child_process_inherit) override;
39   Error CreateNew(llvm::StringRef name, bool child_process_inherit) override;
40   Error CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit,
41                              llvm::SmallVectorImpl<char> &name) override;
42   Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
43   Error
44   OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
45                           const std::chrono::microseconds &timeout) override;
46
47   bool CanRead() const override;
48   bool CanWrite() const override;
49
50   int GetReadFileDescriptor() const override;
51   int GetWriteFileDescriptor() const override;
52   int ReleaseReadFileDescriptor() override;
53   int ReleaseWriteFileDescriptor() override;
54   void CloseReadFileDescriptor() override;
55   void CloseWriteFileDescriptor() override;
56
57   // Close both descriptors
58   void Close() override;
59
60   Error Delete(llvm::StringRef name) override;
61
62   Error Write(const void *buf, size_t size, size_t &bytes_written) override;
63   Error ReadWithTimeout(void *buf, size_t size,
64                         const std::chrono::microseconds &timeout,
65                         size_t &bytes_read) override;
66
67 private:
68   int m_fds[2];
69 };
70
71 } // namespace lldb_private
72
73 #endif // #if defined(__cplusplus)
74 #endif // liblldb_Host_posix_PipePosix_h_