summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
authorChaoren Lin <chaorenl@google.com>2015-05-01 16:49:23 +0000
committerChaoren Lin <chaorenl@google.com>2015-05-01 16:49:23 +0000
commitec53482aeff13b47672f2a19e499e43daf272f77 (patch)
treeb0df680280684569e184dee74d49b46f3f246402 /lldb
parentde036eb170cc12e5cb91ab219ae623c0c9f710ef (diff)
downloadbcm5719-llvm-ec53482aeff13b47672f2a19e499e43daf272f77.tar.gz
bcm5719-llvm-ec53482aeff13b47672f2a19e499e43daf272f77.zip
PosixPipes should not be copyable but should be movable.
Summary: This addresses Oleksiy's comment in D9307. Reviewers: clayborg, ovyalov Reviewed By: clayborg, ovyalov Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9405 llvm-svn: 236320
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/Host/posix/PipePosix.h4
-rw-r--r--lldb/source/Host/posix/PipePosix.cpp20
-rw-r--r--lldb/tools/lldb-server/lldb-gdbserver.cpp2
3 files changed, 24 insertions, 2 deletions
diff --git a/lldb/include/lldb/Host/posix/PipePosix.h b/lldb/include/lldb/Host/posix/PipePosix.h
index 04e83fd6552..710b77d34bd 100644
--- a/lldb/include/lldb/Host/posix/PipePosix.h
+++ b/lldb/include/lldb/Host/posix/PipePosix.h
@@ -29,6 +29,10 @@ public:
PipePosix();
PipePosix(int read_fd, int write_fd);
+ PipePosix(const PipePosix &) = delete;
+ PipePosix(PipePosix &&pipe_posix);
+ PipePosix &operator=(const PipePosix &) = delete;
+ PipePosix &operator=(PipePosix &&pipe_posix);
~PipePosix() override;
diff --git a/lldb/source/Host/posix/PipePosix.cpp b/lldb/source/Host/posix/PipePosix.cpp
index 5976ec60f6d..7f73f9b16f1 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -129,11 +129,29 @@ SelectIO(int handle, bool is_read, const std::function<Error(bool&)> &io_handler
}
PipePosix::PipePosix()
- : m_fds{PipePosix::kInvalidDescriptor, PipePosix::kInvalidDescriptor} {}
+ : m_fds{
+ PipePosix::kInvalidDescriptor,
+ PipePosix::kInvalidDescriptor
+ } {}
PipePosix::PipePosix(int read_fd, int write_fd)
: m_fds{read_fd, write_fd} {}
+PipePosix::PipePosix(PipePosix &&pipe_posix)
+ : PipeBase{std::move(pipe_posix)},
+ m_fds{
+ pipe_posix.ReleaseReadFileDescriptor(),
+ pipe_posix.ReleaseWriteFileDescriptor()
+ } {}
+
+PipePosix &PipePosix::operator=(PipePosix &&pipe_posix)
+{
+ PipeBase::operator=(std::move(pipe_posix));
+ m_fds[READ] = pipe_posix.ReleaseReadFileDescriptor();
+ m_fds[WRITE] = pipe_posix.ReleaseWriteFileDescriptor();
+ return *this;
+}
+
PipePosix::~PipePosix()
{
Close();
diff --git a/lldb/tools/lldb-server/lldb-gdbserver.cpp b/lldb/tools/lldb-server/lldb-gdbserver.cpp
index 0cf3ab1e97e..a691337f1a9 100644
--- a/lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ b/lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -319,7 +319,7 @@ JoinListenThread ()
}
Error
-WritePortToPipe(Pipe port_pipe, const uint16_t port)
+WritePortToPipe(Pipe &port_pipe, const uint16_t port)
{
char port_str[64];
const auto port_str_len = ::snprintf(port_str, sizeof(port_str), "%u", port);
OpenPOWER on IntegriCloud