Properly handle when commands are not unsupported in the GDB remote clients.
Prior to this fix we would often call SendPacketAndWaitForResponse() which
returns the number of bytes in the response. The UNSUPPORTED response in the
GDB remote protocol is zero bytes and we were checking for it inside an if
statement:

if (SendPacketAndWaitForResponse(...))
{
    if (response.IsUnsupportedResponse())
    {
        // UNSUPPORTED...
        // This will never happen...
    }
}

We now handle is properly as:

if (SendPacketAndWaitForResponse(...))
{
}
else
{
    // UNSUPPORTED...
}



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131393 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index fdd3fe2..f4e6702 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -810,11 +810,7 @@
         StringExtractorGDBRemote response;
         if (SendPacketAndWaitForResponse ("qHostInfo", response, false))
         {
-            if (response.IsUnsupportedResponse())
-            {
-                return false;
-            }
-            else if (response.IsNormalResponse())
+            if (response.IsNormalResponse())
             {
                 std::string name;
                 std::string value;
@@ -1031,11 +1027,13 @@
         StringExtractorGDBRemote response;
         if (SendPacketAndWaitForResponse (packet, packet_len, response, false))
         {
-            if (response.IsUnsupportedResponse())
-                m_supports_alloc_dealloc_memory = eLazyBoolNo;
-            else if (!response.IsErrorResponse())
+            if (!response.IsErrorResponse())
                 return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS);
         }
+        else
+        {
+            m_supports_alloc_dealloc_memory = eLazyBoolNo;
+        }
     }
     return LLDB_INVALID_ADDRESS;
 }
@@ -1054,8 +1052,10 @@
         {
             if (response.IsOKResponse())
                 return true;
-            else if (response.IsUnsupportedResponse())
-                m_supports_alloc_dealloc_memory = eLazyBoolNo;
+        }
+        else
+        {
+            m_supports_alloc_dealloc_memory = eLazyBoolNo;
         }
     }
     return false;
@@ -1241,14 +1241,13 @@
         StringExtractorGDBRemote response;
         if (SendPacketAndWaitForResponse (packet, packet_len, response, false))
         {
-            if (response.IsUnsupportedResponse())
-            {
-                m_supports_qProcessInfoPID = false;
-                return false;
-            }
-
             return DecodeProcessInfoResponse (response, process_info);
         }
+        else
+        {
+            m_supports_qProcessInfoPID = false;
+            return false;
+        }
     }
     return false;
 }
@@ -1332,12 +1331,6 @@
         StringExtractorGDBRemote response;
         if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false))
         {
-            if (response.IsUnsupportedResponse())
-            {
-                m_supports_qfProcessInfo = false;
-                return 0;
-            }
-
             do
             {
                 ProcessInstanceInfo process_info;
@@ -1348,6 +1341,11 @@
                 response.SetFilePos(0);
             } while (SendPacketAndWaitForResponse ("qsProcessInfo", strlen ("qsProcessInfo"), response, false));
         }
+        else
+        {
+            m_supports_qfProcessInfo = false;
+            return 0;
+        }
     }
     return process_infos.GetSize();
     
@@ -1364,12 +1362,6 @@
         StringExtractorGDBRemote response;
         if (SendPacketAndWaitForResponse (packet, packet_len, response, false))
         {
-            if (response.IsUnsupportedResponse())
-            {
-                m_supports_qUserName = false;
-                return false;
-            }
-                
             if (response.IsNormalResponse())
             {
                 // Make sure we parsed the right number of characters. The response is
@@ -1379,6 +1371,11 @@
                     return true;
             }
         }
+        else
+        {
+            m_supports_qUserName = false;
+            return false;
+        }        
     }
     return false;
 
@@ -1395,12 +1392,6 @@
         StringExtractorGDBRemote response;
         if (SendPacketAndWaitForResponse (packet, packet_len, response, false))
         {
-            if (response.IsUnsupportedResponse())
-            {
-                m_supports_qGroupName = false;
-                return false;
-            }
-            
             if (response.IsNormalResponse())
             {
                 // Make sure we parsed the right number of characters. The response is
@@ -1410,6 +1401,11 @@
                     return true;
             }
         }
+        else
+        {
+            m_supports_qGroupName = false;
+            return false;
+        }
     }
     return false;
 }
@@ -1488,12 +1484,7 @@
     }
 
     StringExtractorGDBRemote response;
-    if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false))
-    {
-        if (response.IsUnsupportedResponse())
-            return false;
-        return true;
-    }
+    return SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false) > 0;
     return false;
 }
 
@@ -1588,13 +1579,15 @@
         assert (packet_len < sizeof(packet));
         if (SendPacketAndWaitForResponse(packet, packet_len, response, false))
         {
-            if (response.IsUnsupportedResponse())
-                m_supports_qThreadStopInfo = false;
-            else if (response.IsNormalResponse())
+            if (response.IsNormalResponse())
                 return true;
             else
                 return false;
         }
+        else
+        {
+            m_supports_qThreadStopInfo = false;
+        }
     }
     if (SetCurrentThread (tid))
         return GetStopReply (response);
@@ -1630,20 +1623,21 @@
     {
         if (response.IsOKResponse())
             return 0;
-        if (response.IsUnsupportedResponse())
-        {
-            switch (type)
-            {
-                case eBreakpointSoftware:   m_supports_z0 = false; break;
-                case eBreakpointHardware:   m_supports_z1 = false; break;
-                case eWatchpointWrite:      m_supports_z2 = false; break;
-                case eWatchpointRead:       m_supports_z3 = false; break;
-                case eWatchpointReadWrite:  m_supports_z4 = false; break;
-                default:                    break;
-            }
-        }
         else if (response.IsErrorResponse())
             return response.GetError();
     }
+    else
+    {
+        switch (type)
+        {
+            case eBreakpointSoftware:   m_supports_z0 = false; break;
+            case eBreakpointHardware:   m_supports_z1 = false; break;
+            case eWatchpointWrite:      m_supports_z2 = false; break;
+            case eWatchpointRead:       m_supports_z3 = false; break;
+            case eWatchpointReadWrite:  m_supports_z4 = false; break;
+            default:                    break;
+        }
+    }
+
     return UINT8_MAX;
 }