[Lldb-commits] [lldb] r190872 - Logging enhancements to ConnectionFileDescriptor

Andrew Kaylor andrew.kaylor at intel.com
Tue Sep 17 10:18:58 PDT 2013


Author: akaylor
Date: Tue Sep 17 12:18:58 2013
New Revision: 190872

URL: http://llvm.org/viewvc/llvm-project?rev=190872&view=rev
Log:
Logging enhancements to ConnectionFileDescriptor

Modified:
    lldb/trunk/source/Core/ConnectionFileDescriptor.cpp

Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=190872&r1=190871&r2=190872&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Tue Sep 17 12:18:58 2013
@@ -152,7 +152,7 @@ ConnectionFileDescriptor::OpenCommandPip
     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::OpenCommandPip
     {
         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 (Er
     {
         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 *ds
         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;





More information about the lldb-commits mailing list