[Lldb-commits] [lldb] r105806 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Symbol/ lldb.xcodeproj/ source/Core/ source/Host/macosx/ source/Plugins/Disassembler/llvm/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/ObjectFile/ELF/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/MacOSX-User/source/MacOSX/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/

Greg Clayton gclayton at apple.com
Thu Jun 10 20:25:35 PDT 2010


Author: gclayton
Date: Thu Jun 10 22:25:34 2010
New Revision: 105806

URL: http://llvm.org/viewvc/llvm-project?rev=105806&view=rev
Log:
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.


Modified:
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/include/lldb/Symbol/ObjectFile.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Host/macosx/Symbols.cpp
    lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
    lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Thu Jun 10 22:25:34 2010
@@ -28,6 +28,19 @@
 class ArchSpec
 {
 public:
+    // Generic CPU types that each m_type needs to know how to convert 
+    // their m_cpu and m_sub to.
+    typedef enum CPU
+    {
+        eCPU_Unknown,
+        eCPU_arm,
+        eCPU_i386,
+        eCPU_x86_64,
+        eCPU_ppc,
+        eCPU_ppc64,
+        eCPU_sparc
+    };
+
     //------------------------------------------------------------------
     /// Default constructor.
     ///
@@ -42,7 +55,7 @@
     /// Constructor that initializes the object with supplied cpu and
     /// subtypes.
     //------------------------------------------------------------------
-    ArchSpec (uint32_t cpu, uint32_t sub);
+    ArchSpec (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub);
 
     //------------------------------------------------------------------
     /// Construct with architecture name.
@@ -108,7 +121,7 @@
     ///         freed.
     //------------------------------------------------------------------
     static const char *
-    AsCString (uint32_t cpu, uint32_t subtype);
+    AsCString (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t subtype);
 
     //------------------------------------------------------------------
     /// Clears the object state.
@@ -127,6 +140,10 @@
     uint32_t
     GetAddressByteSize () const;
 
+
+    CPU
+    GetGenericCPUType () const;
+
     //------------------------------------------------------------------
     /// CPU subtype get accessor.
     ///
@@ -194,7 +211,7 @@
     ///         String values that are returned do not need to be freed.
     //------------------------------------------------------------------
     static const char *
-    GetRegisterName (uint32_t cpu, uint32_t subtype, uint32_t reg_num, uint32_t flavor);
+    GetRegisterName (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t subtype, uint32_t reg_num, uint32_t flavor);
 
     //------------------------------------------------------------------
     /// Test if the contained architecture is valid.
@@ -271,12 +288,22 @@
     //------------------------------------------------------------------
     lldb::ByteOrder
     GetDefaultEndian () const;
+
+
+    lldb::ArchitectureType
+    GetType() const
+    {
+        return m_type;
+    }
+
 protected:
     //------------------------------------------------------------------
     // Member variables
     //------------------------------------------------------------------
-    uint32_t m_cpu; ///< The cpu type of the architecture
-    uint32_t m_sub; ///< The cpu subtype of the architecture
+    lldb::ArchitectureType m_type;
+    //       m_type =>  eArchTypeMachO      eArchTypeELF
+    uint32_t m_cpu; //  cpu type            ELF header e_machine
+    uint32_t m_sub; //  cpu subtype         nothing
 };
 
 

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Thu Jun 10 22:25:34 2010
@@ -33,15 +33,6 @@
 /// the same file, or archive files that contain multiple objects
 /// (ranlib archives) (possibly for multiple architectures as well).
 ///
-/// It is possible to determine how many architectures an object file
-/// contains by using the ObjectFile::GetNumArchitectures() const
-/// accessor function. The individual architectures can be extracted
-/// using the
-/// ObjectFile::GetArchitectureAtIndex (uint32_t, ArchSpec&) const
-/// function. The object file can also be asked to select one of these
-/// architectures using the
-/// ObjectFile::SetArchitecture (const ArchSpec&) function.
-///
 /// Object archive files (e.g. ranlib archives) can contain 
 /// multiple .o (object) files that must be selected by index or by name. 
 /// The number of objects that an ObjectFile contains can be determined 

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Thu Jun 10 22:25:34 2010
@@ -354,6 +354,15 @@
     eInputReaderDone        // reader was just popped off the stack and is done
 } InputReaderAction;
 
+
+typedef enum ArchitectureType 
+{
+    eArchTypeInvalid,
+    eArchTypeMachO,
+    eArchTypeELF,
+    kNumArchTypes
+} ArchitectureType;
+
 } // namespace lldb
 
 

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jun 10 22:25:34 2010
@@ -527,7 +527,7 @@
 		2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractorGDBRemote.cpp; path = source/Utility/StringExtractorGDBRemote.cpp; sourceTree = "<group>"; };
 		2676A094119C93C8008A98EF /* StringExtractorGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringExtractorGDBRemote.h; path = source/Utility/StringExtractorGDBRemote.h; sourceTree = "<group>"; };
 		2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PseudoTerminal.cpp; path = source/Utility/PseudoTerminal.cpp; sourceTree = "<group>"; };
-		2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PseudoTerminal.h; path = source/Utility/PseudoTerminal.h; sourceTree = "<group>"; };
+		2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PseudoTerminal.h; path = include/lldb/Utility/PseudoTerminal.h; sourceTree = "<group>"; };
 		2682F284115EF3A700CCFF99 /* SBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBError.cpp; path = source/API/SBError.cpp; sourceTree = "<group>"; };
 		2682F286115EF3BD00CCFF99 /* SBError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBError.h; path = include/lldb/API/SBError.h; sourceTree = "<group>"; };
 		2689B0A4113EE3CD00A4AEDB /* Symbols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Symbols.h; path = include/lldb/Host/Symbols.h; sourceTree = "<group>"; };

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Thu Jun 10 22:25:34 2010
@@ -9,43 +9,19 @@
 
 #include "lldb/Core/ArchSpec.h"
 
-#include <mach/mach.h>
-#include <mach-o/nlist.h>
+//#include <mach/mach.h>
+//#include <mach-o/nlist.h>
 
 #include <string>
 
+#include "llvm/Support/ELF.h"
+#include "llvm/Support/MachO.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
 #define ARCH_SPEC_SEPARATOR_CHAR    '-'
 
-#ifndef CPU_TYPE_ARM
-#define CPU_TYPE_ARM            ((cpu_type_t) 12)
-#endif
-
-#ifndef CPU_SUBTYPE_ARM_ALL
-#define CPU_SUBTYPE_ARM_ALL     ((cpu_subtype_t) 0)
-#endif
-
-#ifndef CPU_SUBTYPE_ARM_V4T
-#define CPU_SUBTYPE_ARM_V4T     ((cpu_subtype_t) 5)
-#endif
-
-#ifndef CPU_SUBTYPE_ARM_V6
-#define CPU_SUBTYPE_ARM_V6      ((cpu_subtype_t) 6)
-#endif
-
-#ifndef CPU_SUBTYPE_ARM_V5TEJ
-#define CPU_SUBTYPE_ARM_V5TEJ   ((cpu_subtype_t) 7)
-#endif
-
-#ifndef CPU_SUBTYPE_ARM_XSCALE
-#define CPU_SUBTYPE_ARM_XSCALE  ((cpu_subtype_t) 8)
-#endif
-
-#ifndef CPU_SUBTYPE_ARM_V7
-#define CPU_SUBTYPE_ARM_V7      ((cpu_subtype_t) 9)
-#endif
 
 //----------------------------------------------------------------------
 // A structure that describes all of the information we want to know
@@ -58,6 +34,16 @@
     const char *name;
 };
 
+
+static const char *g_arch_type_strings[] = 
+{
+    "invalid",
+    "mach-o",
+    "elf"
+};
+
+#define CPU_ANY		(UINT32_MAX)
+
 //----------------------------------------------------------------------
 // A table that gets searched linearly for matches. This table is used
 // to convert cpu type and subtypes to architecture names, and to
@@ -65,38 +51,38 @@
 // is important and allows the precedence to be set when the table is
 // built.
 //----------------------------------------------------------------------
-static ArchDefinition g_arch_defs[] =
+static ArchDefinition g_mach_arch_defs[] =
 {
-    { CPU_TYPE_ANY,         CPU_TYPE_ANY                , "all"         },
-    { CPU_TYPE_ARM,         CPU_TYPE_ANY                , "arm"         },
-    { CPU_TYPE_ARM,         CPU_SUBTYPE_ARM_ALL         , "arm"         },
-    { CPU_TYPE_ARM,         CPU_SUBTYPE_ARM_V4T         , "armv4"       },
-    { CPU_TYPE_ARM,         CPU_SUBTYPE_ARM_V5TEJ       , "armv5"       },
-    { CPU_TYPE_ARM,         CPU_SUBTYPE_ARM_V6          , "armv6"       },
-    { CPU_TYPE_ARM,         CPU_SUBTYPE_ARM_V7          , "armv7"       },
-    { CPU_TYPE_ARM,         CPU_SUBTYPE_ARM_XSCALE      , "xscale"      },
-    { CPU_TYPE_POWERPC,     CPU_TYPE_ANY                , "ppc"         },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_ALL     , "ppc"         },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_601     , "ppc601"      },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_602     , "ppc602"      },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_603     , "ppc603"      },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_603e    , "ppc603e"     },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_603ev   , "ppc603ev"    },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_604     , "ppc604"      },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_604e    , "ppc604e"     },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_620     , "ppc620"      },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_750     , "ppc750"      },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_7400    , "ppc7400"     },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_7450    , "ppc7450"     },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_970     , "ppc970"      },
-    { CPU_TYPE_POWERPC64,   CPU_SUBTYPE_POWERPC_ALL     , "ppc64"       },
-    { CPU_TYPE_POWERPC64,   CPU_SUBTYPE_POWERPC_970     , "ppc970-64"   },
-    { CPU_TYPE_I386,        CPU_SUBTYPE_I386_ALL        , "i386"        },
-    { CPU_TYPE_I386,        CPU_SUBTYPE_486             , "i486"        },
-    { CPU_TYPE_I386,        CPU_SUBTYPE_486SX           , "i486sx"      },
-    { CPU_TYPE_I386,        CPU_TYPE_ANY                , "i386"        },
-    { CPU_TYPE_X86_64,      CPU_SUBTYPE_X86_64_ALL      , "x86_64"      },
-    { CPU_TYPE_X86_64,      CPU_TYPE_ANY                , "x86_64"      },
+    { CPU_ANY,                          CPU_ANY , "all"         },
+    { llvm::MachO::CPUTypeARM,          CPU_ANY , "arm"         },
+    { llvm::MachO::CPUTypeARM,          0       , "arm"         },
+    { llvm::MachO::CPUTypeARM,          5       , "armv4"       },
+    { llvm::MachO::CPUTypeARM,          6       , "armv6"       },
+    { llvm::MachO::CPUTypeARM,          7       , "armv5"       },
+    { llvm::MachO::CPUTypeARM,          8       , "xscale"      },
+    { llvm::MachO::CPUTypeARM,          9       , "armv7"       },
+    { llvm::MachO::CPUTypePowerPC,      CPU_ANY , "ppc"         },
+    { llvm::MachO::CPUTypePowerPC,      0       , "ppc"         },
+    { llvm::MachO::CPUTypePowerPC,      1       , "ppc601"      },
+    { llvm::MachO::CPUTypePowerPC,      2       , "ppc602"      },
+    { llvm::MachO::CPUTypePowerPC,      3       , "ppc603"      },
+    { llvm::MachO::CPUTypePowerPC,      4       , "ppc603e"     },
+    { llvm::MachO::CPUTypePowerPC,      5       , "ppc603ev"    },
+    { llvm::MachO::CPUTypePowerPC,      6       , "ppc604"      },
+    { llvm::MachO::CPUTypePowerPC,      7       , "ppc604e"     },
+    { llvm::MachO::CPUTypePowerPC,      8       , "ppc620"      },
+    { llvm::MachO::CPUTypePowerPC,      9       , "ppc750"      },
+    { llvm::MachO::CPUTypePowerPC,      10      , "ppc7400"     },
+    { llvm::MachO::CPUTypePowerPC,      11      , "ppc7450"     },
+    { llvm::MachO::CPUTypePowerPC,      100     , "ppc970"      },
+    { llvm::MachO::CPUTypePowerPC64,    0       , "ppc64"       },
+    { llvm::MachO::CPUTypePowerPC64,    100     , "ppc970-64"   },
+    { llvm::MachO::CPUTypeI386,         3       , "i386"        },
+    { llvm::MachO::CPUTypeI386,         4       , "i486"        },
+    { llvm::MachO::CPUTypeI386,         0x84    , "i486sx"      },
+    { llvm::MachO::CPUTypeI386,         CPU_ANY , "i386"        },
+    { llvm::MachO::CPUTypeX86_64,       3       , "x86_64"      },
+    { llvm::MachO::CPUTypeX86_64,       CPU_ANY , "x86_64"      },
 
     // TODO: when we get a platform that knows more about the host OS we should
     // let it call some accessor funcitons to set the default system arch for
@@ -104,29 +90,74 @@
     // table.
 
 #if defined (__i386__) || defined(__x86_64__)
-    { CPU_TYPE_X86_64,      CPU_SUBTYPE_X86_64_ALL      , LLDB_ARCH_DEFAULT         },
-    { CPU_TYPE_I386,        CPU_SUBTYPE_I386_ALL        , LLDB_ARCH_DEFAULT_32BIT   },
-    { CPU_TYPE_X86_64,      CPU_SUBTYPE_X86_64_ALL      , LLDB_ARCH_DEFAULT_64BIT   },
+    { llvm::MachO::CPUTypeX86_64,      3    , LLDB_ARCH_DEFAULT         },
+    { llvm::MachO::CPUTypeI386,        3    , LLDB_ARCH_DEFAULT_32BIT   },
+    { llvm::MachO::CPUTypeX86_64,      3    , LLDB_ARCH_DEFAULT_64BIT   },
 #elif defined (__arm__)
-    { CPU_TYPE_ARM,         CPU_SUBTYPE_ARM_V6          , LLDB_ARCH_DEFAULT         },
-    { CPU_TYPE_ARM,         CPU_SUBTYPE_ARM_V6          , LLDB_ARCH_DEFAULT_32BIT   },
+    { llvm::MachO::CPUTypeARM,         6    , LLDB_ARCH_DEFAULT         },
+    { llvm::MachO::CPUTypeARM,         6    , LLDB_ARCH_DEFAULT_32BIT   },
 #elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_7400    , LLDB_ARCH_DEFAULT         },
-    { CPU_TYPE_POWERPC,     CPU_SUBTYPE_POWERPC_7400    , LLDB_ARCH_DEFAULT_32BIT   },
-    { CPU_TYPE_POWERPC64,   CPU_SUBTYPE_POWERPC_970     , LLDB_ARCH_DEFAULT_64BIT   },
+    { llvm::MachO::CPUTypePowerPC,     10   , LLDB_ARCH_DEFAULT         },
+    { llvm::MachO::CPUTypePowerPC,     10   , LLDB_ARCH_DEFAULT_32BIT   },
+    { llvm::MachO::CPUTypePowerPC64,   100  , LLDB_ARCH_DEFAULT_64BIT   },
 #endif
 };
 
 //----------------------------------------------------------------------
 // Figure out how many architecture definitions we have
 //----------------------------------------------------------------------
-const size_t k_num_arch_defs = sizeof(g_arch_defs)/sizeof(ArchDefinition);
+const size_t k_num_mach_arch_defs = sizeof(g_mach_arch_defs)/sizeof(ArchDefinition);
+
+
+
+//----------------------------------------------------------------------
+// A table that gets searched linearly for matches. This table is used
+// to convert cpu type and subtypes to architecture names, and to
+// convert architecture names to cpu types and subtypes. The ordering
+// is important and allows the precedence to be set when the table is
+// built.
+//----------------------------------------------------------------------
+static ArchDefinition g_elf_arch_defs[] =
+{
+    { llvm::ELF::EM_M32    , 0, "m32"      }, // AT&T WE 32100
+    { llvm::ELF::EM_SPARC  , 0, "sparc"    }, // AT&T WE 32100
+    { llvm::ELF::EM_386    , 0, "i386"     }, // Intel 80386
+    { llvm::ELF::EM_68K    , 0, "68k"      }, // Motorola 68000
+    { llvm::ELF::EM_88K    , 0, "88k"      }, // Motorola 88000
+    { llvm::ELF::EM_486    , 0, "i486"     }, // Intel 486 (deprecated)
+    { llvm::ELF::EM_860    , 0, "860"      }, // Intel 80860
+    { llvm::ELF::EM_MIPS   , 0, "rs3000"   }, // MIPS RS3000
+    { llvm::ELF::EM_PPC    , 0, "ppc"      }, // PowerPC
+    { 21                   , 0, "ppc64"    }, // PowerPC64
+    { llvm::ELF::EM_ARM    , 0, "arm"      }, // ARM
+    { llvm::ELF::EM_ALPHA  , 0, "alpha"    }, // DEC Alpha
+    { llvm::ELF::EM_SPARCV9, 0, "sparc9"   }, // SPARC V9
+    { llvm::ELF::EM_X86_64 , 0, "x86_64"   }, // AMD64
 
+#if defined (__i386__) || defined(__x86_64__)
+    { llvm::ELF::EM_X86_64 , 0, LLDB_ARCH_DEFAULT         },
+    { llvm::ELF::EM_386    , 0, LLDB_ARCH_DEFAULT_32BIT   },
+    { llvm::ELF::EM_X86_64 , 0, LLDB_ARCH_DEFAULT_64BIT   },
+#elif defined (__arm__)
+    { llvm::ELF::EM_ARM    , 0, LLDB_ARCH_DEFAULT         },
+    { llvm::ELF::EM_ARM    , 0, LLDB_ARCH_DEFAULT_32BIT   },
+#elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
+    { llvm::ELF::EM_PPC    , 0, LLDB_ARCH_DEFAULT         },
+    { llvm::ELF::EM_PPC    , 0, LLDB_ARCH_DEFAULT_32BIT   },
+    { llvm::ELF::EM_PPC64  , 0, LLDB_ARCH_DEFAULT_64BIT   },
+#endif
+};
+
+//----------------------------------------------------------------------
+// Figure out how many architecture definitions we have
+//----------------------------------------------------------------------
+const size_t k_num_elf_arch_defs = sizeof(g_elf_arch_defs)/sizeof(ArchDefinition);
 
 //----------------------------------------------------------------------
 // Default constructor
 //----------------------------------------------------------------------
 ArchSpec::ArchSpec() :
+    m_type (eArchTypeMachO),        // Use the most complete arch definition which will always be translatable to any other ArchitectureType values
     m_cpu (LLDB_INVALID_CPUTYPE),
     m_sub (0)
 {
@@ -136,7 +167,8 @@
 // Constructor that initializes the object with supplied cpu and
 // subtypes.
 //----------------------------------------------------------------------
-ArchSpec::ArchSpec(uint32_t cpu, uint32_t sub) :
+ArchSpec::ArchSpec (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub) :
+    m_type (arch_type),
     m_cpu (cpu),
     m_sub (sub)
 {
@@ -156,12 +188,13 @@
 //  liblldb_ARCH_DEFAULT_32BIT
 //      The 64 bit arch the current system defaults to (if any)
 //----------------------------------------------------------------------
-ArchSpec::ArchSpec(const char *arch_name) :
+ArchSpec::ArchSpec (const char *arch_name) :
+    m_type (eArchTypeMachO),        // Use the most complete arch definition which will always be translatable to any other ArchitectureType values
     m_cpu (LLDB_INVALID_CPUTYPE),
     m_sub (0)
 {
     if (arch_name)
-        SetArch(arch_name);
+        SetArch (arch_name);
 }
 
 //----------------------------------------------------------------------
@@ -179,6 +212,7 @@
 {
     if (this != &rhs)
     {
+        m_type = rhs.m_type;
         m_cpu = rhs.m_cpu;
         m_sub = rhs.m_sub;
     }
@@ -191,7 +225,7 @@
 const char *
 ArchSpec::AsCString() const
 {
-    return ArchSpec::AsCString(m_cpu, m_sub);
+    return ArchSpec::AsCString(m_type, m_cpu, m_sub);
 }
 
 //----------------------------------------------------------------------
@@ -199,23 +233,55 @@
 // and subtype.
 //----------------------------------------------------------------------
 const char *
-ArchSpec::AsCString(uint32_t cpu, uint32_t sub)
+ArchSpec::AsCString (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub)
 {
-    for (uint32_t i=0; i<k_num_arch_defs; i++)
+    if (arch_type >= kNumArchTypes)
+        return NULL;
+
+    switch (arch_type)
     {
-        if (cpu == g_arch_defs[i].cpu)
+    case eArchTypeInvalid:
+        break;
+
+    case eArchTypeMachO:
+        for (uint32_t i=0; i<k_num_mach_arch_defs; i++)
         {
-            if (sub == g_arch_defs[i].sub)
-                return g_arch_defs[i].name;
-            else if (sub != CPU_TYPE_ANY && sub != LLDB_INVALID_CPUTYPE)
+            if (cpu == g_mach_arch_defs[i].cpu)
             {
-                if ((sub & ~CPU_SUBTYPE_MASK) == g_arch_defs[i].sub)
-                    return g_arch_defs[i].name;
+                if (sub == g_mach_arch_defs[i].sub)
+                    return g_mach_arch_defs[i].name;
+                else if (sub != CPU_ANY && sub != LLDB_INVALID_CPUTYPE)
+                {
+                    if ((sub & 0x00ffffff) == g_mach_arch_defs[i].sub)
+                        return g_mach_arch_defs[i].name;
+                }
             }
         }
+        break;
+    
+    case eArchTypeELF:
+        for (uint32_t i=0; i<k_num_elf_arch_defs; i++)
+        {
+            if (cpu == g_elf_arch_defs[i].cpu)
+            {
+                if (sub == g_elf_arch_defs[i].sub)
+                    return g_elf_arch_defs[i].name;
+            }
+        }
+        break;
     }
-    static char s_cpu_hex_str[64];
-    ::snprintf(s_cpu_hex_str, sizeof(s_cpu_hex_str), "%u%c%u", cpu, ARCH_SPEC_SEPARATOR_CHAR, sub);
+
+    const char *arch_type_cstr = g_arch_type_strings[arch_type];
+
+    static char s_cpu_hex_str[128];
+    ::snprintf(s_cpu_hex_str, 
+               sizeof(s_cpu_hex_str), 
+               "%s%c%u%c%u", 
+               arch_type_cstr,
+               ARCH_SPEC_SEPARATOR_CHAR, 
+               cpu, 
+               ARCH_SPEC_SEPARATOR_CHAR, 
+               sub);
     return s_cpu_hex_str;
 }
 
@@ -225,20 +291,27 @@
 void
 ArchSpec::Clear()
 {
+    m_type = eArchTypeInvalid;
     m_cpu = LLDB_INVALID_CPUTYPE;
     m_sub = 0;
 }
 
 
+
+
 //----------------------------------------------------------------------
 // CPU subtype get accessor.
 //----------------------------------------------------------------------
 uint32_t
 ArchSpec::GetCPUSubtype() const
 {
-    if (m_sub == CPU_TYPE_ANY || m_sub == LLDB_INVALID_CPUTYPE)
-        return m_sub;
-    return m_sub & ~CPU_SUBTYPE_MASK;
+    if (m_type == eArchTypeMachO)
+    {
+        if (m_sub == CPU_ANY || m_sub == LLDB_INVALID_CPUTYPE)
+            return m_sub;
+        return m_sub & 0xffffff;
+    }
+    return 0;
 }
 
 
@@ -251,6 +324,50 @@
     return m_cpu;
 }
 
+//----------------------------------------------------------------------
+// This function is designed to abstract us from having to know any
+// details about the current m_type, m_cpu, and m_sub values and 
+// translate the result into a generic CPU type so LLDB core code can
+// detect any CPUs that it supports.
+//----------------------------------------------------------------------
+ArchSpec::CPU
+ArchSpec::GetGenericCPUType () const
+{
+    switch (m_type)
+    {
+    case eArchTypeInvalid:
+        break;
+
+    case eArchTypeMachO:
+        switch (m_cpu)
+        {
+        case llvm::MachO::CPUTypeARM:       return eCPU_arm;
+        case llvm::MachO::CPUTypeI386:      return eCPU_i386;
+        case llvm::MachO::CPUTypeX86_64:    return eCPU_x86_64;
+        case llvm::MachO::CPUTypePowerPC:   return eCPU_ppc;
+        case llvm::MachO::CPUTypePowerPC64: return eCPU_ppc64;
+        case llvm::MachO::CPUTypeSPARC:     return eCPU_sparc;
+        }
+        break;
+    
+    case eArchTypeELF:
+        switch (m_cpu)
+        {
+        case llvm::ELF::EM_ARM:     return eCPU_arm;
+        case llvm::ELF::EM_386:     return eCPU_i386;
+        case llvm::ELF::EM_X86_64:  return eCPU_x86_64;
+        case llvm::ELF::EM_PPC:     return eCPU_ppc;
+        case 21:                    return eCPU_ppc64;
+        case llvm::ELF::EM_SPARC: 	return eCPU_sparc;
+        }
+        break;
+    }
+
+    return eCPU_Unknown;
+}
+
+
+
 
 //----------------------------------------------------------------------
 // Feature flags get accessor.
@@ -258,9 +375,13 @@
 uint32_t
 ArchSpec::GetFeatureFlags() const
 {
-    if (m_sub == CPU_TYPE_ANY || m_sub == LLDB_INVALID_CPUTYPE)
-        return 0;
-    return m_sub & CPU_SUBTYPE_MASK;
+    if (m_type == eArchTypeMachO)
+    {
+        if (m_sub == CPU_ANY || m_sub == LLDB_INVALID_CPUTYPE)
+            return 0;
+        return m_sub & 0xff000000;
+    }
+    return 0;
 }
 
 
@@ -897,7 +1018,7 @@
 const char *
 ArchSpec::GetRegisterName(uint32_t reg_num, uint32_t reg_kind) const
 {
-    return ArchSpec::GetRegisterName(m_cpu, m_sub, reg_num, reg_kind);
+    return ArchSpec::GetRegisterName(m_type, m_cpu, m_sub, reg_num, reg_kind);
 }
 
 
@@ -906,9 +1027,10 @@
 // a register number, and a reg_kind for that register number.
 //----------------------------------------------------------------------
 const char *
-ArchSpec::GetRegisterName(uint32_t cpu, uint32_t subtype, uint32_t reg_num, uint32_t reg_kind)
+ArchSpec::GetRegisterName (ArchitectureType arch_type, uint32_t cpu, uint32_t subtype, uint32_t reg_num, uint32_t reg_kind)
 {
-    if (cpu == CPU_TYPE_I386)
+    if ((arch_type == eArchTypeMachO && cpu == llvm::MachO::CPUTypeI386) ||
+        (arch_type == eArchTypeELF   && cpu == llvm::ELF::EM_386))
     {
         switch (reg_kind)
         {
@@ -924,7 +1046,8 @@
             break;
         }
     }
-    else if (cpu == CPU_TYPE_X86_64)
+    else if ((arch_type == eArchTypeMachO && cpu == llvm::MachO::CPUTypeX86_64) ||
+             (arch_type == eArchTypeELF   && cpu == llvm::ELF::EM_X86_64))
     {
         switch (reg_kind)
         {
@@ -937,7 +1060,8 @@
             break;
         }
     }
-    else if (cpu == CPU_TYPE_ARM)
+    else if ((arch_type == eArchTypeMachO && cpu == llvm::MachO::CPUTypeARM) ||
+             (arch_type == eArchTypeELF   && cpu == llvm::ELF::EM_ARM))
     {
         switch (reg_kind)
         {
@@ -1103,7 +1227,8 @@
             break;
         }
     }
-    else if (cpu == CPU_TYPE_POWERPC || cpu == CPU_TYPE_POWERPC64)
+    else if ((arch_type == eArchTypeMachO && (cpu == llvm::MachO::CPUTypePowerPC || cpu == llvm::MachO::CPUTypePowerPC64)) ||
+             (arch_type == eArchTypeELF   && cpu == llvm::ELF::EM_PPC))
     {
         switch (reg_kind)
         {
@@ -1479,9 +1604,41 @@
 uint32_t
 ArchSpec::GetAddressByteSize() const
 {
-    if (GetCPUType() & CPU_ARCH_ABI64)
-        return 8;
-    return 4;
+    switch (m_type)
+    {
+    case eArchTypeInvalid:
+        break;
+
+    case eArchTypeMachO:
+        if (GetCPUType() & CPU_ARCH_ABI64)
+            return 8;
+        else
+            return 4;
+        break;
+    
+    case eArchTypeELF:
+        switch (m_cpu)
+        {
+        case llvm::ELF::EM_M32:
+        case llvm::ELF::EM_SPARC:
+        case llvm::ELF::EM_386:
+        case llvm::ELF::EM_68K:
+        case llvm::ELF::EM_88K:
+        case llvm::ELF::EM_486:
+        case llvm::ELF::EM_860:
+        case llvm::ELF::EM_MIPS:
+        case llvm::ELF::EM_PPC:
+        case llvm::ELF::EM_ARM:
+        case llvm::ELF::EM_ALPHA:
+        case llvm::ELF::EM_SPARCV9:
+            return 4;
+        case llvm::ELF::EM_X86_64:
+            return 8;
+        }
+        break;
+    }
+
+    return 0;
 }
 
 //----------------------------------------------------------------------
@@ -1513,73 +1670,104 @@
 // Change the CPU type and subtype given an architecture name.
 //----------------------------------------------------------------------
 bool
-ArchSpec::SetArch(const char *arch_name)
+ArchSpec::SetArch (const char *arch_name)
 {
     if (arch_name && arch_name[0] != '\0')
     {
         size_t i;
-        // Search for ARCH_NAME in our architecture definitions structure
-        for (i=0; i<k_num_arch_defs; ++i)
+
+        switch (m_type)
         {
-            if (strcasecmp(arch_name, g_arch_defs[i].name) == 0)
+        case eArchTypeInvalid:
+        case eArchTypeMachO:
+            for (i=0; i<k_num_mach_arch_defs; i++)
             {
-                // we found a match
-                m_cpu = g_arch_defs[i].cpu;
-                m_sub = g_arch_defs[i].sub;
-                return true;
+                if (strcasecmp(arch_name, g_mach_arch_defs[i].name) == 0)
+                {
+                    m_type = eArchTypeMachO;
+                    m_cpu = g_mach_arch_defs[i].cpu;
+                    m_sub = g_mach_arch_defs[i].sub;
+                    return true;
+                }
+            }
+            break;
+        
+        case eArchTypeELF:
+            for (i=0; i<k_num_elf_arch_defs; i++)
+            {
+                if (strcasecmp(arch_name, g_elf_arch_defs[i].name) == 0)
+                {
+                    m_cpu = g_elf_arch_defs[i].cpu;
+                    m_sub = g_elf_arch_defs[i].sub;
+                    return true;
+                }
             }
+            break;
         }
 
-
         const char *str = arch_name;
-        char *end = NULL;
-        // Check for a numeric cpu followed by an optional '.' and numeric subtype.
+        // Check for a numeric cpu followed by an optional separator char and numeric subtype.
         // This allows for support of new cpu type/subtypes without having to have
         // a recompiled debug core.
         // Examples:
         //  "12.6" is armv6
-        //  "0x0000000c.0x00000006" is also armv6
-        m_cpu = strtoul(str, &end, 0);
-        if (str != end)
+        //  "0x0000000c-0x00000006" is also armv6
+        
+        m_type = eArchTypeInvalid;
+        for (i=1; i<kNumArchTypes; ++i)
+        {
+            const char *arch_type_cstr = g_arch_type_strings[i];
+            if (strstr(str, arch_type_cstr))
+            {
+                m_type = (ArchitectureType)i;
+                str += strlen(arch_type_cstr) + 1; // Also skip separator char
+            }
+        }
+        
+        if (m_type != eArchTypeInvalid)
         {
-            if (*end == '.')
+            char *end = NULL;
+            m_cpu = ::strtoul (str, &end, 0);
+            if (str != end)
             {
-                // We have a cputype.cpusubtype format
-                str = end + 1;
-                if (*str != '\0')
+                if (*end == ARCH_SPEC_SEPARATOR_CHAR)
                 {
-                    m_sub = strtoul(str, &end, 0);
-                    if (*end == '\0')
+                    // We have a cputype.cpusubtype format
+                    str = end + 1;
+                    if (*str != '\0')
                     {
-                        // We consumed the entire string and got a cpu type and subtype
-                        return true;
+                        m_sub = strtoul(str, &end, 0);
+                        if (*end == '\0')
+                        {
+                            // We consumed the entire string and got a cpu type and subtype
+                            return true;
+                        }
                     }
                 }
-            }
 
-            // If we reach this point we have a valid cpu type, but no cpu subtype.
-            // Search for the first matching cpu type and use the corresponding cpu
-            // subtype. This setting should typically be the _ALL variant and should
-            // appear first in the list for each cpu type in the g_arch_defs
-            // structure.
-            for (i=0; i<k_num_arch_defs; ++i)
-            {
-                if (m_cpu == g_arch_defs[i].cpu)
+                // If we reach this point we have a valid cpu type, but no cpu subtype.
+                // Search for the first matching cpu type and use the corresponding cpu
+                // subtype. This setting should typically be the _ALL variant and should
+                // appear first in the list for each cpu type in the g_mach_arch_defs
+                // structure.
+                for (i=0; i<k_num_mach_arch_defs; ++i)
                 {
-                    m_sub = g_arch_defs[i].sub;
-                    return true;
+                    if (m_cpu == g_mach_arch_defs[i].cpu)
+                    {
+                        m_sub = g_mach_arch_defs[i].sub;
+                        return true;
+                    }
                 }
-            }
 
-            // Default the cpu subtype to zero when we don't have a matching
-            // cpu type in our architecture defs structure (g_arch_defs).
-            m_sub = 0;
-            return true;
+                // Default the cpu subtype to zero when we don't have a matching
+                // cpu type in our architecture defs structure (g_mach_arch_defs).
+                m_sub = 0;
+                return true;
 
+            }
         }
     }
-    m_cpu = LLDB_INVALID_CPUTYPE;
-    m_sub = 0;
+    Clear();
     return false;
 }
 
@@ -1616,13 +1804,13 @@
 {
     switch (m_cpu)
     {
-    case CPU_TYPE_POWERPC:
-    case CPU_TYPE_POWERPC64:
+    case llvm::MachO::CPUTypePowerPC:
+    case llvm::MachO::CPUTypePowerPC64:
         return eByteOrderBig;
 
-    case CPU_TYPE_ARM:
-    case CPU_TYPE_I386:
-    case CPU_TYPE_X86_64:
+    case llvm::MachO::CPUTypeARM:
+    case llvm::MachO::CPUTypeI386:
+    case llvm::MachO::CPUTypeX86_64:
         return eByteOrderLittle;
 
     default:
@@ -1640,14 +1828,14 @@
     uint32_t lhs_cpu = lhs.GetCPUType();
     uint32_t rhs_cpu = rhs.GetCPUType();
 
-    if (lhs_cpu == CPU_TYPE_ANY || rhs_cpu == CPU_TYPE_ANY)
+    if (lhs_cpu == CPU_ANY || rhs_cpu == CPU_ANY)
         return true;
 
     else if (lhs_cpu == rhs_cpu)
     {
         uint32_t lhs_subtype = lhs.GetCPUSubtype();
         uint32_t rhs_subtype = rhs.GetCPUSubtype();
-        if (lhs_subtype == CPU_TYPE_ANY || rhs_subtype == CPU_TYPE_ANY)
+        if (lhs_subtype == CPU_ANY || rhs_subtype == CPU_ANY)
             return true;
         return lhs_subtype == rhs_subtype;
     }

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Thu Jun 10 22:25:34 2010
@@ -65,7 +65,7 @@
     // Check the architecture if we have a valid arch pointer
     if (arch)
     {
-        ArchSpec file_arch(cputype, cpusubtype);
+        ArchSpec file_arch(eArchTypeMachO, cputype, cpusubtype);
 
         if (file_arch != *arch)
             return false;
@@ -150,7 +150,7 @@
         // Only process this slice if the cpu type/subtype matches
         if (arch)
         {
-            ArchSpec fat_arch(arch_cputype, arch_cpusubtype);
+            ArchSpec fat_arch(eArchTypeMachO, arch_cputype, arch_cpusubtype);
             if (fat_arch != *arch)
                 continue;
         }

Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Thu Jun 10 22:25:34 2010
@@ -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()

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Thu Jun 10 22:25:34 2010
@@ -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())
         {

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Jun 10 22:25:34 2010
@@ -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
 //------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Jun 10 22:25:34 2010
@@ -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";
 

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp Thu Jun 10 22:25:34 2010
@@ -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);
 }

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h Thu Jun 10 22:25:34 2010
@@ -46,9 +46,6 @@
     virtual void
     RefreshStateAfterStop ();
 
-    static uint32_t
-    GetCPUType ();
-
 protected:
     kern_return_t
     EnableHardwareSingleStep (bool enable);

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp Thu Jun 10 22:25:34 2010
@@ -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()
 {

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h Thu Jun 10 22:25:34 2010
@@ -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);

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp Thu Jun 10 22:25:34 2010
@@ -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()
 {

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h Thu Jun 10 22:25:34 2010
@@ -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;

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Thu Jun 10 22:25:34 2010
@@ -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

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp Thu Jun 10 22:25:34 2010
@@ -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

Modified: lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp Thu Jun 10 22:25:34 2010
@@ -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;

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=105806&r1=105805&r2=105806&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Jun 10 22:25:34 2010
@@ -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 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;
+    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;
+
+    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)





More information about the lldb-commits mailing list