In ProcessGDBRemote::DoConnectRemote(), if the remote system informed
us of its architecture, use that to set the Target's arch if it
doesn't already have one set.

In Process::CompleteAttach(), if the Target has a valid arch make
sure that the Platform we pick up is compatible with that arch; if
not, find a Platform that is compatible.  Don't let the the default
platform override the Target's arch.

<rdar://problem/11185420>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156116 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index ffb165d..5b59289 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -457,6 +457,14 @@
         else
             error.SetErrorStringWithFormat ("Process %llu was reported after connecting to '%s', but no stop reply packet was received", pid, remote_url);
     }
+
+    if (error.Success() 
+        && !GetTarget().GetArchitecture().IsValid()
+        && m_gdb_comm.GetHostArchitecture().IsValid())
+    {
+        GetTarget().SetArchitecture(m_gdb_comm.GetHostArchitecture());
+    }
+
     return error;
 }