From f0066ad07fadc7c1386c65572e6d988dfd26610d Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 2 May 2014 00:45:31 +0000 Subject: Fixed CTRL+C related issues: - CTRL+C wasn't clearing the command in lldb - CTRL+C doesn't work in python macros in lldb - Ctrl+C no longer interrupts the running process that you attach to llvm-svn: 207816 --- lldb/source/Core/ConnectionFileDescriptor.cpp | 31 +++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'lldb/source/Core/ConnectionFileDescriptor.cpp') diff --git a/lldb/source/Core/ConnectionFileDescriptor.cpp b/lldb/source/Core/ConnectionFileDescriptor.cpp index fc1e9f2b535..31761d8864a 100644 --- a/lldb/source/Core/ConnectionFileDescriptor.cpp +++ b/lldb/source/Core/ConnectionFileDescriptor.cpp @@ -361,6 +361,14 @@ ConnectionFileDescriptor::Connect (const char *s, Error *error_ptr) return eConnectionStatusError; } +bool +ConnectionFileDescriptor::InterruptRead() +{ + if (m_pipe_write != -1 ) + return write (m_pipe_write, "i", 1) == 1; + return false; +} + ConnectionStatus ConnectionFileDescriptor::Disconnect (Error *error_ptr) { @@ -390,7 +398,7 @@ ConnectionFileDescriptor::Disconnect (Error *error_ptr) m_shutting_down = true; Mutex::Locker locker; - bool got_lock= locker.TryLock (m_mutex); + bool got_lock = locker.TryLock (m_mutex); if (!got_lock) { @@ -839,14 +847,19 @@ ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_pt { bytes_read = ::read (pipe_fd, buffer, sizeof(buffer)); } while (bytes_read < 0 && errno == EINTR); - assert (bytes_read == 1 && buffer[0] == 'q'); - - if (log) - log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.", - static_cast(this), - static_cast(bytes_read), buffer); - - return eConnectionStatusEndOfFile; + + switch (buffer[0]) + { + case 'q': + if (log) + log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.", + static_cast(this), + static_cast(bytes_read), buffer); + return eConnectionStatusEndOfFile; + case 'i': + // Interrupt the current read + return eConnectionStatusInterrupted; + } } } } -- cgit v1.2.3