]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Host/posix/PipePosix.h
Update LLDB snapshot to upstream r225923 (git 2b588ecd)
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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 {
27 public:
28     static int kInvalidDescriptor;
29
30     PipePosix();
31
32     ~PipePosix() override;
33
34     Error
35     CreateNew(bool child_process_inherit) override;
36     Error
37     CreateNew(llvm::StringRef name, bool child_process_inherit) override;
38     Error
39     OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
40     Error
41     OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override;
42
43     bool
44     CanRead() const override;
45     bool
46     CanWrite() const override;
47
48     int
49     GetReadFileDescriptor() const override;
50     int
51     GetWriteFileDescriptor() const override;
52     int
53     ReleaseReadFileDescriptor() override;
54     int
55     ReleaseWriteFileDescriptor() override;
56
57     // Close both descriptors
58     void
59     Close() override;
60
61     Error
62     Delete(llvm::StringRef name) override;
63
64     Error
65     Write(const void *buf, size_t size, size_t &bytes_written) override;
66     Error
67     ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override;
68
69 private:
70     void
71     CloseReadFileDescriptor();
72     void
73     CloseWriteFileDescriptor();
74
75     int m_fds[2];
76 };
77
78 } // namespace lldb_private
79
80 #endif  // #if defined(__cplusplus)
81 #endif  // liblldb_Host_posix_PipePosix_h_