[Lldb-commits] [lldb] r236133 - Add file descriptor constructor for PipePosix.

Chaoren Lin chaorenl at google.com
Wed Apr 29 10:36:58 PDT 2015


Author: chaoren
Date: Wed Apr 29 12:36:58 2015
New Revision: 236133

URL: http://llvm.org/viewvc/llvm-project?rev=236133&view=rev
Log:
Add file descriptor constructor for PipePosix.

Modified:
    lldb/trunk/include/lldb/Host/posix/PipePosix.h
    lldb/trunk/source/Host/posix/PipePosix.cpp
    lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp

Modified: lldb/trunk/include/lldb/Host/posix/PipePosix.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/PipePosix.h?rev=236133&r1=236132&r2=236133&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/posix/PipePosix.h (original)
+++ lldb/trunk/include/lldb/Host/posix/PipePosix.h Wed Apr 29 12:36:58 2015
@@ -28,6 +28,7 @@ public:
     static int kInvalidDescriptor;
 
     PipePosix();
+    PipePosix(int read_fd, int write_fd);
 
     ~PipePosix() override;
 
@@ -36,8 +37,6 @@ public:
     Error
     CreateNew(llvm::StringRef name, bool child_process_inherit) override;
     Error
-    CreateWithFD(int read_fd, int write_fd);
-    Error
     CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl<char>& name) override;
     Error
     OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;

Modified: lldb/trunk/source/Host/posix/PipePosix.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/PipePosix.cpp?rev=236133&r1=236132&r2=236133&view=diff
==============================================================================
--- lldb/trunk/source/Host/posix/PipePosix.cpp (original)
+++ lldb/trunk/source/Host/posix/PipePosix.cpp Wed Apr 29 12:36:58 2015
@@ -129,10 +129,10 @@ SelectIO(int handle, bool is_read, const
 }
 
 PipePosix::PipePosix()
-{
-    m_fds[READ] = PipePosix::kInvalidDescriptor;
-    m_fds[WRITE] = PipePosix::kInvalidDescriptor;
-}
+    : m_fds{PipePosix::kInvalidDescriptor, PipePosix::kInvalidDescriptor} {}
+
+PipePosix::PipePosix(int read_fd, int write_fd)
+    : m_fds{read_fd, write_fd} {}
 
 PipePosix::~PipePosix()
 {
@@ -187,15 +187,6 @@ PipePosix::CreateNew(llvm::StringRef nam
 }
 
 Error
-PipePosix::CreateWithFD(int read_fd, int write_fd) {
-    if (CanRead() || CanWrite())
-        return Error("Pipe is already opened");
-    m_fds[READ] = read_fd;
-    m_fds[WRITE] = write_fd;
-    return Error();
-}
-
-Error
 PipePosix::CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl<char>& name)
 {
     llvm::SmallString<PATH_MAX> named_pipe_path;

Modified: lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp?rev=236133&r1=236132&r2=236133&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp Wed Apr 29 12:36:58 2015
@@ -344,11 +344,7 @@ writePortToPipe(const char *const named_
 Error
 writePortToPipe(int unnamed_pipe_fd, const uint16_t port)
 {
-    Pipe port_pipe;
-    // Wait for 10 seconds for pipe to be opened.
-    auto error = port_pipe.CreateWithFD(Pipe::kInvalidDescriptor, unnamed_pipe_fd);
-    if (error.Fail())
-        return error;
+    Pipe port_pipe{Pipe::kInvalidDescriptor, unnamed_pipe_fd};
     return WritePortToPipe(port_pipe, port);
 }
 





More information about the lldb-commits mailing list