If we haven't gotten the architecture of the process we're attaching
to by the time we get to the AttachCompletionHandler, do it before
completing the attach.

llvm-svn: 139679
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 52fd857..5da9a9f 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2167,6 +2167,25 @@
             // lldb_private::Process subclasses must set the process must set
             // the new process ID.
             assert (m_process->GetID() != LLDB_INVALID_PROCESS_ID);
+            // We just attached, if we haven't gotten a valid architecture at this point we should do so now.
+            Target &target = m_process->GetTarget();
+            if (!target.GetArchitecture().IsValid())
+            {
+                // FIXME: We shouldn't be getting the Selected Platform, there should
+                // be a platform for the target, and we should get that.
+                PlatformSP platform_sp (target.GetDebugger().GetPlatformList().GetSelectedPlatform ());
+                if (platform_sp)
+                {
+                    ProcessInstanceInfo process_info;
+                    platform_sp->GetProcessInfo (m_process->GetID(), process_info);
+                    const ArchSpec &process_arch = process_info.GetArchitecture();
+                    if (process_arch.IsValid())
+                    {
+                        // Set the architecture on the target.
+                        target.SetArchitecture (process_arch);
+                    }
+                }
+            }
             m_process->CompleteAttach ();
             return eEventActionSuccess;
         }