From bac7af21da68a7d9c9f80fa304ae0b6f78e060a5 Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Tue, 17 Sep 2013 17:18:58 +0000 Subject: [PATCH] Logging enhancements to ConnectionFileDescriptor llvm-svn: 190872 --- lldb/source/Core/ConnectionFileDescriptor.cpp | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lldb/source/Core/ConnectionFileDescriptor.cpp b/lldb/source/Core/ConnectionFileDescriptor.cpp index e61f744dba92..eb949de3c649 100644 --- a/lldb/source/Core/ConnectionFileDescriptor.cpp +++ b/lldb/source/Core/ConnectionFileDescriptor.cpp @@ -152,7 +152,7 @@ ConnectionFileDescriptor::OpenCommandPipe () if (result != 0) { if (log) - log->Printf ("%p ConnectionFileDescriptor::ConnectionFileDescriptor () - could not make pipe: %s", + log->Printf ("%p ConnectionFileDescriptor::OpenCommandPipe () - could not make pipe: %s", this, strerror(errno)); } @@ -160,12 +160,22 @@ ConnectionFileDescriptor::OpenCommandPipe () { m_pipe_read = filedes[0]; m_pipe_write = filedes[1]; + if (log) + log->Printf ("%p ConnectionFileDescriptor::OpenCommandPipe() - success readfd=%d writefd=%d", + this, + m_pipe_read, + m_pipe_write); } } void ConnectionFileDescriptor::CloseCommandPipe () { + Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION)); + if (log) + log->Printf ("%p ConnectionFileDescriptor::CloseCommandPipe()", + this); + if (m_pipe_read != -1) { close (m_pipe_read); @@ -365,13 +375,16 @@ ConnectionFileDescriptor::Disconnect (Error *error_ptr) { if (m_pipe_write != -1 ) { - write (m_pipe_write, "q", 1); - close (m_pipe_write); - m_pipe_write = -1; + int result; + result = write (m_pipe_write, "q", 1); + if (log) + log->Printf ("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, sent 'q' to %d, result = %d.", this, m_pipe_write, result); } + else if (log) + log->Printf ("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, but no command pipe is available.", this); locker.Lock (m_mutex); } - + if (m_should_close_fd == true) { if (m_fd_send == m_fd_recv) @@ -529,6 +542,13 @@ ConnectionFileDescriptor::Read (void *dst, case ETIMEDOUT: // A transmission timeout occurs during a read attempt on a socket. status = eConnectionStatusTimedOut; return 0; + + default: + if (log) + log->Printf("%p ConnectionFileDescriptor::Read (), unexpected error: %s", this, strerror(error_value)); + status = eConnectionStatusError; + break; // Break to close.... + } return 0;