LLDB  mainline
PipeBase.h
Go to the documentation of this file.
1 //===-- PipeBase.h -----------------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_Host_PipeBase_h_
11 #define liblldb_Host_PipeBase_h_
12 
13 #include <chrono>
14 #include <string>
15 
16 #include "lldb/Utility/Status.h"
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/ADT/StringRef.h"
19 
20 namespace lldb_private {
21 class PipeBase {
22 public:
23  virtual ~PipeBase();
24 
25  virtual Status CreateNew(bool child_process_inherit) = 0;
26  virtual Status CreateNew(llvm::StringRef name,
27  bool child_process_inherit) = 0;
28  virtual Status CreateWithUniqueName(llvm::StringRef prefix,
29  bool child_process_inherit,
30  llvm::SmallVectorImpl<char> &name) = 0;
31 
32  virtual Status OpenAsReader(llvm::StringRef name,
33  bool child_process_inherit) = 0;
34 
35  Status OpenAsWriter(llvm::StringRef name, bool child_process_inherit);
36  virtual Status
37  OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
38  const std::chrono::microseconds &timeout) = 0;
39 
40  virtual bool CanRead() const = 0;
41  virtual bool CanWrite() const = 0;
42 
43  virtual lldb::pipe_t GetReadPipe() const = 0;
44  virtual lldb::pipe_t GetWritePipe() const = 0;
45 
46  virtual int GetReadFileDescriptor() const = 0;
47  virtual int GetWriteFileDescriptor() const = 0;
48  virtual int ReleaseReadFileDescriptor() = 0;
49  virtual int ReleaseWriteFileDescriptor() = 0;
50  virtual void CloseReadFileDescriptor() = 0;
51  virtual void CloseWriteFileDescriptor() = 0;
52 
53  // Close both descriptors
54  virtual void Close() = 0;
55 
56  // Delete named pipe.
57  virtual Status Delete(llvm::StringRef name) = 0;
58 
59  virtual Status Write(const void *buf, size_t size, size_t &bytes_written) = 0;
60  virtual Status ReadWithTimeout(void *buf, size_t size,
61  const std::chrono::microseconds &timeout,
62  size_t &bytes_read) = 0;
63  Status Read(void *buf, size_t size, size_t &bytes_read);
64 };
65 }
66 
67 #endif
virtual lldb::pipe_t GetWritePipe() const =0
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
virtual Status ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read)=0
virtual int ReleaseReadFileDescriptor()=0
virtual bool CanWrite() const =0
virtual bool CanRead() const =0
virtual int GetWriteFileDescriptor() const =0
virtual void CloseReadFileDescriptor()=0
virtual Status Write(const void *buf, size_t size, size_t &bytes_written)=0
virtual lldb::pipe_t GetReadPipe() const =0
virtual int ReleaseWriteFileDescriptor()=0
virtual Status OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout)=0
virtual void CloseWriteFileDescriptor()=0
virtual Status CreateNew(bool child_process_inherit)=0
virtual int GetReadFileDescriptor() const =0
virtual void Close()=0
virtual Status Delete(llvm::StringRef name)=0
int pipe_t
Definition: lldb-types.h:64
virtual Status CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl< char > &name)=0
Status Read(void *buf, size_t size, size_t &bytes_read)
Definition: PipeBase.cpp:21
virtual Status OpenAsReader(llvm::StringRef name, bool child_process_inherit)=0
An error handling class.
Definition: Status.h:44
Status OpenAsWriter(llvm::StringRef name, bool child_process_inherit)
Definition: PipeBase.cpp:15