diff options
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/API/SBCommunication.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Core/Communication.cpp | 22 | ||||
-rw-r--r-- | lldb/source/Core/ConnectionFileDescriptor.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Target/Process.cpp | 2 |
6 files changed, 25 insertions, 11 deletions
diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index ac3042fd904..6aa1e244d3c 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -24,8 +24,8 @@ SBCommunication::SBCommunication() : { } -SBCommunication::SBCommunication(const char * broadcaster_name) : - m_opaque (new Communication (broadcaster_name)), +SBCommunication::SBCommunication(const char * broadcaster_name, bool close_on_eof) : + m_opaque (new Communication (broadcaster_name, close_on_eof)), m_opaque_owned (true) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp index 17ed2fd7689..f8de19810b1 100644 --- a/lldb/source/Core/Communication.cpp +++ b/lldb/source/Core/Communication.cpp @@ -25,7 +25,7 @@ using namespace lldb_private; //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -Communication::Communication(const char *name) : +Communication::Communication(const char *name, bool close_on_eof) : Broadcaster (name), m_connection_ap (), m_read_thread (LLDB_INVALID_HOST_THREAD), @@ -33,7 +33,8 @@ Communication::Communication(const char *name) : m_bytes(), m_bytes_mutex (Mutex::eMutexTypeRecursive), m_callback (NULL), - m_callback_baton (NULL) + m_callback_baton (NULL), + m_close_on_eof (close_on_eof) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION, @@ -265,7 +266,8 @@ Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broad lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::AppendBytesToCache (src = %p, src_len = %zu, broadcast = %i)", this, bytes, len, broadcast); - if (bytes == NULL || len == 0) + if ((bytes == NULL || len == 0) + && (status != eConnectionStatusEndOfFile)) return; if (m_callback) { @@ -289,6 +291,11 @@ Communication::ReadFromConnection (void *dst, size_t dst_len, ConnectionStatus & return 0; } +bool +Communication::CloseOnEOF () +{ + return m_close_on_eof; +} bool Communication::ReadThreadIsRunning () @@ -320,14 +327,21 @@ Communication::ReadThread (void *p) size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), status, &error); if (bytes_read > 0) comm->AppendBytesToCache (buf, bytes_read, true, status); + else if ((bytes_read == 0) + && status == eConnectionStatusEndOfFile) + { + if (comm->CloseOnEOF ()) + comm->Disconnect (); + comm->AppendBytesToCache (buf, bytes_read, true, status); + } } switch (status) { case eConnectionStatusSuccess: + case eConnectionStatusEndOfFile: break; - case eConnectionStatusEndOfFile: case eConnectionStatusNoConnection: // No connection case eConnectionStatusLostConnection: // Lost connection while connected to a valid connection done = true; diff --git a/lldb/source/Core/ConnectionFileDescriptor.cpp b/lldb/source/Core/ConnectionFileDescriptor.cpp index 96d70bc1012..c333d06b176 100644 --- a/lldb/source/Core/ConnectionFileDescriptor.cpp +++ b/lldb/source/Core/ConnectionFileDescriptor.cpp @@ -156,8 +156,8 @@ ConnectionFileDescriptor::Read (void *dst, size_t dst_len, ConnectionStatus &sta ssize_t bytes_read = ::read (m_fd, dst, dst_len); if (bytes_read == 0) { - error.SetErrorStringWithFormat("End-of-file.\n"); - status = eConnectionStatusLostConnection; + error.Clear(); // End-of-file. Do not automatically close; pass along for the end-of-file handlers. + status = eConnectionStatusEndOfFile; } else if (bytes_read < 0) { diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index a06095fa80b..8884c3c95b1 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -166,7 +166,7 @@ Debugger::FindTargetWithProcessID (lldb::pid_t pid) Debugger::Debugger () : UserID (g_unique_id++), DebuggerInstanceSettings (*GetSettingsController()), - m_input_comm("debugger.input"), + m_input_comm("debugger.input", false), m_input_file (), m_output_file (), m_error_file (), diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 63fb35783ea..be962727364 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -32,7 +32,7 @@ using namespace lldb_private; // GDBRemoteCommunication constructor //---------------------------------------------------------------------- GDBRemoteCommunication::GDBRemoteCommunication() : - Communication("gdb-remote.packets"), + Communication("gdb-remote.packets", true), m_send_acks (true), m_rx_packet_listener ("gdbremote.rx_packet"), m_sequence_mutex (Mutex::eMutexTypeRecursive), diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index b025970a477..1c269bee525 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -96,7 +96,7 @@ Process::Process(Target &target, Listener &listener) : m_addr_byte_size (0), m_abi_sp (), m_process_input_reader (), - m_stdio_communication ("lldb.process.stdio"), + m_stdio_communication ("lldb.process.stdio", true), m_stdio_communication_mutex (Mutex::eMutexTypeRecursive), m_stdout_data () { |