Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:48

0001 //===-- PipeWindows.h -------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef liblldb_Host_windows_PipeWindows_h_
0010 #define liblldb_Host_windows_PipeWindows_h_
0011 
0012 #include "lldb/Host/PipeBase.h"
0013 #include "lldb/Host/windows/windows.h"
0014 
0015 namespace lldb_private {
0016 
0017 /// \class Pipe PipeWindows.h "lldb/Host/windows/PipeWindows.h"
0018 /// A windows-based implementation of Pipe, a class that abtracts
0019 ///        unix style pipes.
0020 ///
0021 /// A class that abstracts the LLDB core from host pipe functionality.
0022 class PipeWindows : public PipeBase {
0023 public:
0024   static const int kInvalidDescriptor = -1;
0025 
0026 public:
0027   PipeWindows();
0028   PipeWindows(lldb::pipe_t read, lldb::pipe_t write);
0029   ~PipeWindows() override;
0030 
0031   // Create an unnamed pipe.
0032   Status CreateNew(bool child_process_inherit) override;
0033 
0034   // Create a named pipe.
0035   Status CreateNew(llvm::StringRef name, bool child_process_inherit) override;
0036   Status CreateWithUniqueName(llvm::StringRef prefix,
0037                               bool child_process_inherit,
0038                               llvm::SmallVectorImpl<char> &name) override;
0039   Status OpenAsReader(llvm::StringRef name,
0040                       bool child_process_inherit) override;
0041   Status
0042   OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
0043                           const std::chrono::microseconds &timeout) override;
0044 
0045   bool CanRead() const override;
0046   bool CanWrite() const override;
0047 
0048   lldb::pipe_t GetReadPipe() const override { return lldb::pipe_t(m_read); }
0049   lldb::pipe_t GetWritePipe() const override { return lldb::pipe_t(m_write); }
0050 
0051   int GetReadFileDescriptor() const override;
0052   int GetWriteFileDescriptor() const override;
0053   int ReleaseReadFileDescriptor() override;
0054   int ReleaseWriteFileDescriptor() override;
0055   void CloseReadFileDescriptor() override;
0056   void CloseWriteFileDescriptor() override;
0057 
0058   void Close() override;
0059 
0060   Status Delete(llvm::StringRef name) override;
0061 
0062   Status WriteWithTimeout(const void *buf, size_t size,
0063                           const std::chrono::microseconds &timeout,
0064                           size_t &bytes_written) override;
0065   Status ReadWithTimeout(void *buf, size_t size,
0066                          const std::chrono::microseconds &timeout,
0067                          size_t &bytes_read) override;
0068 
0069   // PipeWindows specific methods.  These allow access to the underlying OS
0070   // handle.
0071   HANDLE GetReadNativeHandle();
0072   HANDLE GetWriteNativeHandle();
0073 
0074 private:
0075   Status OpenNamedPipe(llvm::StringRef name, bool child_process_inherit,
0076                        bool is_read);
0077 
0078   HANDLE m_read;
0079   HANDLE m_write;
0080 
0081   int m_read_fd;
0082   int m_write_fd;
0083 
0084   OVERLAPPED m_read_overlapped;
0085   OVERLAPPED m_write_overlapped;
0086 };
0087 
0088 } // namespace lldb_private
0089 
0090 #endif // liblldb_Host_posix_PipePosix_h_