Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance the Pipe interface for better portability.
This patch makes a number of improvements to the Pipe interface. 1) An interface (PipeBase) is provided which exposes pure virtual methods for any implementation of Pipe to override. While not strictly necessary, this helps catch errors where the interfaces are out of sync. 2) All methods return lldb_private::Error instead of returning bool or void. This allows richer error information to be propagated up to LLDB. 3) A new ReadWithTimeout() method is exposed in the base class and implemented on Windows. 4) Support for both named and anonymous pipes is exposed through the base interface and implemented on Windows. For creating a new pipe, both named and anonymous pipes are supported, and for opening an existing pipe, only named pipes are supported. New methods described in points #3 and #4 are stubbed out on posix, but fully implemented on Windows. These should be implemented by someone on the linux / mac / bsd side. Reviewed by: Greg Clayton, Oleksiy Vyalov Differential Revision: http://reviews.llvm.org/D6686 llvm-svn: 224442
- Loading branch information
Zachary Turner
committed
Dec 17, 2014
1 parent
06b2c54
commit 0b9d3ee
Showing
10 changed files
with
452 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//===-- PipeBase.h -----------------------------------------------*- C++ -*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef liblldb_Host_PipeBase_h_ | ||
#define liblldb_Host_PipeBase_h_ | ||
|
||
#include <chrono> | ||
#include <string> | ||
|
||
#include "lldb/Core/Error.h" | ||
#include "llvm/ADT/StringRef.h" | ||
|
||
namespace lldb_private | ||
{ | ||
class PipeBase | ||
{ | ||
public: | ||
virtual ~PipeBase() {} | ||
|
||
virtual Error CreateNew(bool child_process_inherit) = 0; | ||
virtual Error CreateNew(llvm::StringRef name, bool child_process_inherit) = 0; | ||
virtual Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) = 0; | ||
virtual Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit) = 0; | ||
|
||
virtual bool CanRead() const = 0; | ||
virtual bool CanWrite() const = 0; | ||
|
||
virtual int GetReadFileDescriptor() const = 0; | ||
virtual int GetWriteFileDescriptor() const = 0; | ||
virtual int ReleaseReadFileDescriptor() = 0; | ||
virtual int ReleaseWriteFileDescriptor() = 0; | ||
|
||
// Close both descriptors | ||
virtual void Close() = 0; | ||
|
||
virtual Error Write(const void *buf, size_t size, size_t &bytes_written) = 0; | ||
virtual Error Read(void *buf, size_t size, size_t &bytes_read) = 0; | ||
virtual Error ReadWithTimeout(void *buf, size_t size, const std::chrono::milliseconds &timeout, size_t &bytes_read) = 0; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.