Made lldb_private::ArchSpec more generic so that it can take a mach-o cpu
type and sub-type, or an ELF e_machine value. Also added a generic CPU type
to the arch spec class so we can have a single arch definition that the LLDB
core code can use. Previously a lot of places in the code were using the
mach-o definitions from a macosx header file. 

Switches over to using "llvm/Support/MachO.h" for the llvm::MachO::XXX for the
CPU types and sub types for mach-o ArchSpecs. Added "llvm/Support/ELF.h" so 
we can use the "llvm::ELF::XXX" defines for the ELF ArchSpecs.

Got rid of all CPU_TYPE_ and CPU_SUBTYPE_ defines that were previously being
used in LLDB.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@105806 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index db2d561..510f55b 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -313,54 +313,50 @@
 }
 
 static inline const char *
-TripleForCPU(cpu_type_t cpuType)
+TripleForArchSpec (const ArchSpec &arch, char *triple, size_t triple_len)
 {
-    switch (cpuType)
+    const char *arch_name = arch.AsCString();
+
+    if (arch_name)
     {
-    default:
-        return NULL;
-    case CPU_TYPE_X86:
-        return "i386-unknown-unknown";
-    case CPU_TYPE_X86_64:
-        return "x86_64-unknown-unknown";
+        snprintf(triple, triple_len, "%s-unknown-unknown", arch_name);
+        return triple;
     }
+    return NULL;
 }
 
 static inline EDAssemblySyntax_t
-SyntaxForCPU(cpu_type_t cpuType)
+SyntaxForArchSpec (const ArchSpec &arch)
 {
-    switch (cpuType)
-    {
-    default:
-        return (EDAssemblySyntax_t)0;   // default
-    case CPU_TYPE_X86:
-    case CPU_TYPE_X86_64:
+    const char *arch_name = arch.AsCString();
+
+    if (arch_name != NULL && 
+       ((strcasestr (arch_name, "i386") == arch_name) || 
+        (strcasestr (arch_name, "x86_64") == arch_name)))
         return kEDAssemblySyntaxX86ATT;
-    }
+    
+    return (EDAssemblySyntax_t)0;   // default
 }
 
 Disassembler *
 DisassemblerLLVM::CreateInstance(const ArchSpec &arch)
 {
-    cpu_type_t cpuType = arch.GetCPUType();
+    char triple[256];
 
-    if (TripleForCPU(cpuType))
-        return new DisassemblerLLVM(arch);
-    else
-        return NULL;
+    if (TripleForArchSpec (arch, triple, sizeof(triple)))
+        return new DisassemblerLLVM(triple);
+    return NULL;
 }
 
 DisassemblerLLVM::DisassemblerLLVM(const ArchSpec &arch) :
     Disassembler(arch)
 {
-    cpu_type_t cpuType = arch.GetCPUType();
-
-    const char *triple = TripleForCPU(cpuType);
-    assert(triple && "Unhandled CPU type!");
-
-    EDAssemblySyntax_t syntax = SyntaxForCPU(cpuType);
-
-    assert(!EDGetDisassembler(&m_disassembler, triple, syntax) && "No disassembler created!");
+    char triple[256];
+    if (TripleForArchSpec (arch, triple, sizeof(triple)))
+    {
+        EDAssemblySyntax_t syntax = SyntaxForArchSpec (arch);
+        assert(!EDGetDisassembler(&m_disassembler, triple, syntax) && "No disassembler created!");
+    }
 }
 
 DisassemblerLLVM::~DisassemblerLLVM()
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index b55aeb9..3166887 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -199,7 +199,7 @@
             {
                 if (m_dyld.file_spec)
                 {
-                    ArchSpec dyld_arch(m_dyld.header.cputype, m_dyld.header.cpusubtype);
+                    ArchSpec dyld_arch(eArchTypeMachO, m_dyld.header.cputype, m_dyld.header.cpusubtype);
                     dyld_module_sp = m_process->GetTarget().GetImages().FindFirstModuleForFileSpec (m_dyld.file_spec);
 
                     if (dyld_module_sp.get() == NULL || dyld_module_sp->GetArchitecture() != dyld_arch)
@@ -591,7 +591,7 @@
         ModuleList loaded_module_list;
         for (uint32_t idx = 0; idx<num_dylibs; ++idx)
         {
-            ArchSpec arch_spec(m_dyld_image_infos[idx].header.cputype, m_dyld_image_infos[idx].header.cpusubtype);
+            ArchSpec arch_spec(eArchTypeMachO, m_dyld_image_infos[idx].header.cputype, m_dyld_image_infos[idx].header.cpusubtype);
             ModuleSP image_module_sp(m_process->GetTarget().GetImages().FindFirstModuleForFileSpec (m_dyld_image_infos[idx].file_spec));
             if (image_module_sp.get() == NULL || image_module_sp->GetArchitecture() != arch_spec)
             {
@@ -829,7 +829,7 @@
     if (exe_idx < m_dyld_image_infos.size())
     {
         bool set_executable = false;
-        ArchSpec dyld_exe_arch_spec(m_dyld_image_infos[exe_idx].header.cputype, m_dyld_image_infos[exe_idx].header.cpusubtype);
+        ArchSpec dyld_exe_arch_spec(eArchTypeMachO, m_dyld_image_infos[exe_idx].header.cputype, m_dyld_image_infos[exe_idx].header.cpusubtype);
         ModuleSP exe_module_sp(m_process->GetTarget().GetExecutableModule());
         if (exe_module_sp.get())
         {
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index b34dd3d..6a5b5f3 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -25,8 +25,6 @@
 
 #define CASE_AND_STREAM(s, def, width)  case def: s->Printf("%-*s", width, #def); break;
 
-static uint32_t ELFMachineToMachCPU(Elf32_Half machine);
-
 using namespace lldb;
 using namespace lldb_private;
 using namespace std;
@@ -824,24 +822,6 @@
     }
 }
 
-static uint32_t
-ELFMachineToMachCPU(Elf32_Half machine)
-{
-    switch (machine)
-    {
-    case EM_SPARC:  return CPU_TYPE_SPARC;
-    case EM_386:    return CPU_TYPE_I386;
-    case EM_68K:    return CPU_TYPE_MC680x0;
-    case EM_88K:    return CPU_TYPE_MC88000;
-    case EM_860:    return CPU_TYPE_I860;
-    case EM_MIPS:   return 8;   // commented out in mach/machine.h
-    case EM_PPC:    return CPU_TYPE_POWERPC;
-    case EM_PPC64:  return CPU_TYPE_POWERPC64;
-    case EM_ARM:    return 12;  // commented out in mach/machine.h
-    }
-    return 0;
-}
-
 bool
 ObjectFileELF::GetTargetTriple (ConstString &target_triple)
 {
@@ -866,10 +846,10 @@
         case EM_PPC64:  triple.assign("powerpc64-"); break;
         case EM_ARM:    triple.assign("arm-"); break;
         }
-        // TODO: determine if there is a vendor in the ELF? Default to "apple" for now
-        triple += "apple-";
-        // TODO: determine if there is an OS in the ELF? Default to "darwin" for now
-        triple += "darwin10";
+        // TODO: determine if there is a vendor in the ELF? Default to "linux" for now
+        triple += "linux-";
+        // TODO: determine if there is an OS in the ELF? Default to "gnu" for now
+        triple += "gnu";
         g_target_triple.SetCString(triple.c_str());
         target_triple = g_target_triple;
     }
@@ -877,14 +857,6 @@
 }
 
 
-//bool
-//ELF32RuntimeFileParser::GetArch(ArchSpec &arch) const
-//{
-//  arch.SetCPUType(ELFMachineToMachCPU(m_header.e_machine));
-//  arch.SetCPUSubtype(ArchSpec::eAny);
-//  return true;
-//}
-
 //------------------------------------------------------------------
 // PluginInterface protocol
 //------------------------------------------------------------------
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 682a116..21860e1 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -171,7 +171,7 @@
     {
         m_data.GetU32(&offset, &m_header.cputype, 6);
 
-        ArchSpec mach_arch(m_header.cputype, m_header.cpusubtype);
+        ArchSpec mach_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
         if (mach_arch == m_module->GetArchitecture())
         {
             // Read in all only the load command data
@@ -1168,7 +1168,7 @@
     else
         s->PutCString("ObjectFileMachO32");
 
-    ArchSpec header_arch(m_header.cputype, m_header.cpusubtype);
+    ArchSpec header_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
 
     *s << ", file = '" << m_file << "', arch = " << header_arch.AsCString() << "\n";
 
diff --git a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp
index 4f6b17c..28a28c7 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp
@@ -94,13 +94,6 @@
 }
 
 
-
-uint32_t
-MachThreadContext_arm::GetCPUType()
-{
-    return CPU_TYPE_ARM;
-}
-
 void
 MachThreadContext_arm::ThreadWillResume()
 {
@@ -1879,6 +1872,6 @@
 void
 MachThreadContext_arm::Initialize()
 {
-    ArchSpec arch_spec(CPU_TYPE_ARM, CPU_TYPE_ANY);
+    ArchSpec arch_spec(eArchTypeMachO, 12, UINT32_MAX);
     ProcessMacOSX::AddArchCreateCallback(arch_spec, MachThreadContext_arm::Create);
 }
diff --git a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h
index 4ec72df..333efee 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h
+++ b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h
@@ -46,9 +46,6 @@
     virtual void
     RefreshStateAfterStop ();
 
-    static uint32_t
-    GetCPUType ();
-
 protected:
     kern_return_t
     EnableHardwareSingleStep (bool enable);
diff --git a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
index ea148a6..03b5c2a 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
@@ -55,13 +55,6 @@
     m_flags_reg = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
 }
 
-
-uint32_t
-MachThreadContext_i386::GetCPUType()
-{
-    return CPU_TYPE_I386;
-}
-
 void
 MachThreadContext_i386::ThreadWillResume()
 {
diff --git a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h
index 4bee2e7..7da2259 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h
+++ b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h
@@ -40,7 +40,6 @@
 
     virtual bool            NotifyException(MachException::Data& exc);
     virtual size_t          GetStackFrameData(lldb_private::StackFrame *first_frame, std::vector<std::pair<lldb::addr_t, lldb::addr_t> >& fp_pc_pairs);
-    static uint32_t         GetCPUType();
 
 protected:
 //    kern_return_t EnableHardwareSingleStep (bool enable);
diff --git a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
index 3ee9eb4..7eaa8f4 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
@@ -54,12 +54,6 @@
     m_flags_reg = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
 }
 
-uint32_t
-MachThreadContext_x86_64::GetCPUType()
-{
-    return CPU_TYPE_X86_64;
-}
-
 void
 MachThreadContext_x86_64::ThreadWillResume()
 {
diff --git a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h
index 45d5a37..f4fc130 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h
+++ b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h
@@ -54,9 +54,6 @@
     virtual size_t
     GetStackFrameData (lldb_private::StackFrame *first_frame, std::vector<std::pair<lldb::addr_t, lldb::addr_t> >& fp_pc_pairs);
 
-    static uint32_t
-    GetCPUType();
-
 protected:
 //    kern_return_t EnableHardwareSingleStep (bool enable);
     uint32_t m_flags_reg;
diff --git a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index 0116f00..d887b09 100644
--- a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -532,31 +532,32 @@
     static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
     static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
 
-    switch (m_arch_spec.GetCPUType())
+    ArchSpec::CPU arch_cpu = m_arch_spec.GetGenericCPUType();
+    switch (arch_cpu)
     {
-    case CPU_TYPE_ARM:
+    case ArchSpec::eCPU_i386:
+    case ArchSpec::eCPU_x86_64:
+        trap_opcode = g_i386_breakpoint_opcode;
+        trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
+        break;
+    
+    case ArchSpec::eCPU_arm:
         // TODO: fill this in for ARM. We need to dig up the symbol for
         // the address in the breakpoint locaiton and figure out if it is
         // an ARM or Thumb breakpoint.
         trap_opcode = g_arm_breakpoint_opcode;
         trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
         break;
-
-    case CPU_TYPE_POWERPC:
-    case CPU_TYPE_POWERPC64:
+    
+    case ArchSpec::eCPU_ppc:
+    case ArchSpec::eCPU_ppc64:
         trap_opcode = g_ppc_breakpoint_opcode;
         trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
         break;
 
-    case CPU_TYPE_I386:
-    case CPU_TYPE_X86_64:
-        trap_opcode = g_i386_breakpoint_opcode;
-        trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
-        break;
-
     default:
         assert(!"Unhandled architecture in ProcessMacOSX::GetSoftwareBreakpointTrapOpcode()");
-        return 0;
+        break;
     }
 
     if (trap_opcode && trap_opcode_size)
@@ -1721,16 +1722,19 @@
     // We don't need to do this for ARM, and we really shouldn't now that we
     // have multiple CPU subtypes and no posix_spawnattr call that allows us
     // to set which CPU subtype to launch...
-    cpu_type_t cpu = arch_spec.GetCPUType();
-    if (cpu != 0 && cpu != CPU_TYPE_ANY && cpu != LLDB_INVALID_CPUTYPE)
+    if (arch_spec.GetType() == eArchTypeMachO)
     {
-        size_t ocount = 0;
-        err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
-        if (err.Fail() || log)
-            err.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
+        cpu_type_t cpu = arch_spec.GetCPUType();
+        if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE)
+        {
+            size_t ocount = 0;
+            err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
+            if (err.Fail() || log)
+                err.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
 
-        if (err.Fail() != 0 || ocount != 1)
-            return LLDB_INVALID_PROCESS_ID;
+            if (err.Fail() != 0 || ocount != 1)
+                return LLDB_INVALID_PROCESS_ID;
+        }
     }
 
 #endif
diff --git a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
index 3747254..5909bc4 100644
--- a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
@@ -1153,38 +1153,14 @@
         // Set this to zero in case we can't tell if there are any HW breakpoints
         g_num_supported_hw_breakpoints = 0;
 
-        // Read the DBGDIDR to get the number of available hardware breakpoints
-        // However, in some of our current armv7 processors, hardware
-        // breakpoints/watchpoints were not properly connected. So detect those
-        // cases using a field in a sysctl. For now we are using "hw.cpusubtype"
-        // field to distinguish CPU architectures. This is a hack until we can
-        // get <rdar://problem/6372672> fixed, at which point we will switch to
-        // using a different sysctl string that will tell us how many BRPs
-        // are available to us directly without having to read DBGDIDR.
         uint32_t register_DBGDIDR;
 
         asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR));
-        uint32_t numBRPs = bits(register_DBGDIDR, 27, 24);
+        g_num_supported_hw_breakpoints = bits(register_DBGDIDR, 27, 24);
         // Zero is reserved for the BRP count, so don't increment it if it is zero
-        if (numBRPs > 0)
-            numBRPs++;
-        ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, numBRPs);
-
-        if (numBRPs > 0)
-        {
-            uint32_t cpu_subtype;
-            size_t len;
-            len = sizeof(cpusubtype);
-            // TODO: remove this hack and change to using hw.optional.xx when implmented
-            if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
-            {
-                ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "hw.cpusubtype=0x%d", cpusubtype);
-                if (cpusubtype == CPU_SUBTYPE_ARM_V7)
-                    ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "Hardware breakpoints disabled for armv7 (rdar://problem/6372672)");
-                else
-                    g_num_supported_hw_breakpoints = numBRPs;
-            }
-        }
+        if (g_num_supported_hw_breakpoints > 0)
+            g_num_supported_hw_breakpoints++;
+        ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_breakpoints);
 
     }
     return g_num_supported_hw_breakpoints;
@@ -1306,37 +1282,11 @@
     {
         // Set this to zero in case we can't tell if there are any HW breakpoints
         g_num_supported_hw_watchpoints = 0;
-        // Read the DBGDIDR to get the number of available hardware breakpoints
-        // However, in some of our current armv7 processors, hardware
-        // breakpoints/watchpoints were not properly connected. So detect those
-        // cases using a field in a sysctl. For now we are using "hw.cpusubtype"
-        // field to distinguish CPU architectures. This is a hack until we can
-        // get <rdar://problem/6372672> fixed, at which point we will switch to
-        // using a different sysctl string that will tell us how many WRPs
-        // are available to us directly without having to read DBGDIDR.
 
         uint32_t register_DBGDIDR;
         asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR));
-        uint32_t numWRPs = bits(register_DBGDIDR, 31, 28) + 1;
-        ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, numWRPs);
-
-        if (numWRPs > 0)
-        {
-            uint32_t cpusubtype;
-            size_t len;
-            len = sizeof(cpusubtype);
-            // TODO: remove this hack and change to using hw.optional.xx when implmented
-            if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
-            {
-                ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "hw.cpusubtype=0x%d", cpusubtype);
-
-                if (cpusubtype == CPU_SUBTYPE_ARM_V7)
-                    ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "Hardware watchpoints disabled for armv7 (rdar://problem/6372672)");
-                else
-                    g_num_supported_hw_watchpoints = numWRPs;
-            }
-        }
-
+        g_num_supported_hw_watchpoints = bits(register_DBGDIDR, 31, 28) + 1;
+        ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_watchpoints);
     }
     return g_num_supported_hw_watchpoints;
 #else
diff --git a/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp b/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp
index 58a7ac0..e6c7b35 100644
--- a/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp
+++ b/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp
@@ -250,15 +250,16 @@
     
     if (arg == 0)
         return -1;
-    Thread *th = (Thread *) arg;
-    const ArchSpec target_arch (th->GetProcess().GetTarget().GetArchitecture ());
+    Thread *thread = (Thread *) arg;
     
-    if (target_arch.GetCPUType() == CPU_TYPE_I386)
+    const ArchSpec::CPU arch_cpu = thread->GetProcess().GetTarget().GetArchitecture ().GetGenericCPUType();
+
+    if (arch_cpu == ArchSpec::eCPU_i386)
     {
         if (EDGetDisassembler (&disasm, "i386-apple-darwin", kEDAssemblySyntaxX86ATT) != 0)
             return -1;
     }
-    else if (target_arch.GetCPUType() == CPU_TYPE_X86_64)
+    else if (arch_cpu == ArchSpec::eCPU_x86_64)
     {
         if (EDGetDisassembler (&disasm, "x86_64-apple-darwin", kEDAssemblySyntaxX86ATT) != 0)
             return -1;
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index e8b194e..8bf90c2 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -875,31 +875,32 @@
     static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
     static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
 
-    switch (m_arch_spec.GetCPUType())
+    ArchSpec::CPU arch_cpu = m_arch_spec.GetGenericCPUType();
+    switch (arch_cpu)
     {
-        case CPU_TYPE_ARM:
-            // TODO: fill this in for ARM. We need to dig up the symbol for
-            // the address in the breakpoint locaiton and figure out if it is
-            // an ARM or Thumb breakpoint.
-            trap_opcode = g_arm_breakpoint_opcode;
-            trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
-            break;
+    case ArchSpec::eCPU_i386:
+    case ArchSpec::eCPU_x86_64:
+        trap_opcode = g_i386_breakpoint_opcode;
+        trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
+        break;
+    
+    case ArchSpec::eCPU_arm:
+        // TODO: fill this in for ARM. We need to dig up the symbol for
+        // the address in the breakpoint locaiton and figure out if it is
+        // an ARM or Thumb breakpoint.
+        trap_opcode = g_arm_breakpoint_opcode;
+        trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
+        break;
+    
+    case ArchSpec::eCPU_ppc:
+    case ArchSpec::eCPU_ppc64:
+        trap_opcode = g_ppc_breakpoint_opcode;
+        trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
+        break;
 
-        case CPU_TYPE_POWERPC:
-        case CPU_TYPE_POWERPC64:
-            trap_opcode = g_ppc_breakpoint_opcode;
-            trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
-            break;
-
-        case CPU_TYPE_I386:
-        case CPU_TYPE_X86_64:
-            trap_opcode = g_i386_breakpoint_opcode;
-            trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
-            break;
-
-        default:
-            assert(!"Unhandled architecture in ProcessGDBRemote::GetSoftwareBreakpointTrapOpcode()");
-            return 0;
+    default:
+        assert(!"Unhandled architecture in ProcessMacOSX::GetSoftwareBreakpointTrapOpcode()");
+        break;
     }
 
     if (trap_opcode && trap_opcode_size)
@@ -1719,16 +1720,19 @@
             // We don't need to do this for ARM, and we really shouldn't now that we
             // have multiple CPU subtypes and no posix_spawnattr call that allows us
             // to set which CPU subtype to launch...
-            cpu_type_t cpu = inferior_arch.GetCPUType();
-            if (cpu != 0 && cpu != CPU_TYPE_ANY && cpu != LLDB_INVALID_CPUTYPE)
+            if (inferior_arch.GetType() == eArchTypeMachO)
             {
-                size_t ocount = 0;
-                error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
-                if (error.Fail() || log)
-                    error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
+                cpu_type_t cpu = inferior_arch.GetCPUType();
+                if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE)
+                {
+                    size_t ocount = 0;
+                    error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
+                    if (error.Fail() || log)
+                        error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
 
-                if (error.Fail() != 0 || ocount != 1)
-                    return error;
+                    if (error.Fail() != 0 || ocount != 1)
+                        return error;
+                }
             }
 
 #endif
@@ -2175,9 +2179,11 @@
 ProcessGDBRemote::GetLibUnwindAddressSpace ()
 {
     unw_targettype_t target_type = UNW_TARGET_UNSPECIFIED;
-    if (m_target.GetArchitecture().GetCPUType() == CPU_TYPE_I386)
+
+    ArchSpec::CPU arch_cpu = m_target.GetArchitecture().GetGenericCPUType();
+    if (arch_cpu == ArchSpec::eCPU_i386)
         target_type = UNW_TARGET_I386;
-    if (m_target.GetArchitecture().GetCPUType() == CPU_TYPE_X86_64)
+    else if (arch_cpu == ArchSpec::eCPU_x86_64)
         target_type = UNW_TARGET_X86_64;
 
     if (m_libunwind_addr_space)