When we use the "fd://%u" for file descriptors, we need to detect if this is
a file or socket. We now make a getsockopt call to check if the fd is a socket.

Also, the previous logic in the GDB communication needs to watch for success
with an error so we can deal with EAGAIN and other normal "retry" error codes.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@134359 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 4525bc8..69f97f1 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -194,7 +194,8 @@
     if (CheckForPacket (NULL, 0, packet))
         return packet.GetStringRef().size();
 
-    while (IsConnected())
+    bool timed_out = false;
+    while (IsConnected() && !timed_out)
     {
         lldb::ConnectionStatus status;
         size_t bytes_read = Read (buffer, sizeof(buffer), timeout_usec, status, &error);
@@ -207,8 +208,11 @@
         {
             switch (status)
             {
-            case eConnectionStatusSuccess:
             case eConnectionStatusTimedOut:
+                timed_out = true;
+                break;
+            case eConnectionStatusSuccess:
+                //printf ("status = success but error = %s\n", error.AsCString("<invalid>"));
                 break;
                 
             case eConnectionStatusEndOfFile:
@@ -218,9 +222,6 @@
                 Disconnect();
                 break;
             }
-            
-            // Get out of the while loop we we finally timeout without getting any data
-            break;
         }
     }
     packet.Clear ();    
@@ -237,10 +238,14 @@
 
     if (src && src_len > 0)
     {
-        if (log)
+        if (log && log->GetVerbose())
         {
             StreamString s;
-            log->Printf ("GDBRemoteCommunication::%s adding %zu bytes: %s\n",__FUNCTION__, src_len, src);
+            log->Printf ("GDBRemoteCommunication::%s adding %u bytes: %.*s",
+                         __FUNCTION__, 
+                         (uint32_t)src_len, 
+                         (uint32_t)src_len, 
+                         src);
         }
         m_bytes.append ((const char *)src, src_len);
     }