LLDB  mainline
PipePosix.h
Go to the documentation of this file.
1 //===-- PipePosix.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 LLDB_HOST_POSIX_PIPEPOSIX_H
10 #define LLDB_HOST_POSIX_PIPEPOSIX_H
11 #if defined(__cplusplus)
12 
13 #include "lldb/Host/PipeBase.h"
14 
15 namespace lldb_private {
16 
17 /// \class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h"
18 /// A posix-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 PipePosix : public PipeBase {
23 public:
24  static int kInvalidDescriptor;
25 
26  PipePosix();
27  PipePosix(lldb::pipe_t read, lldb::pipe_t write);
28  PipePosix(const PipePosix &) = delete;
29  PipePosix(PipePosix &&pipe_posix);
30  PipePosix &operator=(const PipePosix &) = delete;
31  PipePosix &operator=(PipePosix &&pipe_posix);
32 
33  ~PipePosix() override;
34 
35  Status CreateNew(bool child_process_inherit) override;
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 {
50  return lldb::pipe_t(GetReadFileDescriptor());
51  }
52  lldb::pipe_t GetWritePipe() const override {
53  return lldb::pipe_t(GetWriteFileDescriptor());
54  }
55 
56  int GetReadFileDescriptor() const override;
57  int GetWriteFileDescriptor() const override;
58  int ReleaseReadFileDescriptor() override;
59  int ReleaseWriteFileDescriptor() override;
60  void CloseReadFileDescriptor() override;
61  void CloseWriteFileDescriptor() override;
62 
63  // Close both descriptors
64  void Close() override;
65 
66  Status Delete(llvm::StringRef name) override;
67 
68  Status Write(const void *buf, size_t size, size_t &bytes_written) override;
69  Status ReadWithTimeout(void *buf, size_t size,
70  const std::chrono::microseconds &timeout,
71  size_t &bytes_read) override;
72 
73 private:
74  int m_fds[2];
75 };
76 
77 } // namespace lldb_private
78 
79 #endif // #if defined(__cplusplus)
80 #endif // LLDB_HOST_POSIX_PIPEPOSIX_H
lldb::pipe_t
int pipe_t
Definition: lldb-types.h:64
PipeBase.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
llvm::SmallVectorImpl
Definition: Disassembler.h:42
lldb_private::LineStatus::Status
@ Status