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 LLDB_HOST_PIPEBASE_H
11#define LLDB_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
20namespace lldb_private {
21class PipeBase {
22public:
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,
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 WriteWithTimeout(const void *buf, size_t size,
60 const std::chrono::microseconds &timeout,
61 size_t &bytes_written) = 0;
62 Status Write(const void *buf, size_t size, size_t &bytes_written);
63 virtual Status ReadWithTimeout(void *buf, size_t size,
64 const std::chrono::microseconds &timeout,
65 size_t &bytes_read) = 0;
66 Status Read(void *buf, size_t size, size_t &bytes_read);
67};
68}
69
70#endif
virtual Status Delete(llvm::StringRef name)=0
virtual Status CreateNew(llvm::StringRef name, bool child_process_inherit)=0
virtual Status OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout)=0
Status Read(void *buf, size_t size, size_t &bytes_read)
Definition: PipeBase.cpp:26
virtual int GetReadFileDescriptor() const =0
virtual int GetWriteFileDescriptor() const =0
virtual void Close()=0
virtual Status ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read)=0
virtual Status WriteWithTimeout(const void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_written)=0
virtual void CloseWriteFileDescriptor()=0
virtual int ReleaseReadFileDescriptor()=0
virtual bool CanWrite() const =0
virtual void CloseReadFileDescriptor()=0
virtual Status CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl< char > &name)=0
virtual bool CanRead() const =0
virtual Status CreateNew(bool child_process_inherit)=0
Status Write(const void *buf, size_t size, size_t &bytes_written)
Definition: PipeBase.cpp:21
virtual Status OpenAsReader(llvm::StringRef name, bool child_process_inherit)=0
virtual int ReleaseWriteFileDescriptor()=0
virtual lldb::pipe_t GetWritePipe() const =0
Status OpenAsWriter(llvm::StringRef name, bool child_process_inherit)
Definition: PipeBase.cpp:15
virtual lldb::pipe_t GetReadPipe() const =0
An error handling class.
Definition: Status.h:115
A class that represents a running process on the host machine.
int pipe_t
Definition: lldb-types.h:64