Abtracted all mach-o and ELF out of ArchSpec. This patch is a modified form
of Stephen Wilson's idea (thanks for the input Stephen!). What I ended up
doing was:
- Got rid of ArchSpec::CPU (which was a generic CPU enumeration that mimics
the contents of llvm::Triple::ArchType). We now rely upon the llvm::Triple
to give us the machine type from llvm::Triple::ArchType.
- There is a new ArchSpec::Core definition which further qualifies the CPU
core we are dealing with into a single enumeration. If you need support for
a new Core and want to debug it in LLDB, it must be added to this list. In
the future we can allow for dynamic core registration, but for now it is
hard coded.
- The ArchSpec can now be initialized with a llvm::Triple or with a C string
that represents the triple (it can just be an arch still like "i386").
- The ArchSpec can still initialize itself with a architecture type -- mach-o
with cpu type and subtype, or ELF with e_machine + e_flags -- and this will
then get translated into the internal llvm::Triple::ArchSpec + ArchSpec::Core.
The mach-o cpu type and subtype can be accessed using the getter functions:
uint32_t
ArchSpec::GetMachOCPUType () const;
uint32_t
ArchSpec::GetMachOCPUSubType () const;
But these functions are just converting out internal llvm::Triple::ArchSpec
+ ArchSpec::Core back into mach-o. Same goes for ELF.
All code has been updated to deal with the changes.
This should abstract us until later when the llvm::TargetSpec stuff gets
finalized and we can then adopt it.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@126278 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index bc6bfd1..edecaa1 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -345,16 +345,12 @@
static inline EDAssemblySyntax_t
SyntaxForArchSpec (const ArchSpec &arch)
{
- switch (arch.GetGenericCPUType())
+ switch (arch.GetMachine ())
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
return kEDAssemblySyntaxX86ATT;
- case ArchSpec::eCPU_arm:
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
- case ArchSpec::eCPU_sparc:
default:
break;
}
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 491cdad..76a74bd 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -6814,7 +6814,7 @@
EmulateInstructionARM::SetArchitecture (const ArchSpec &arch)
{
m_arm_isa = 0;
- const char *arch_cstr = arch.AsCString ();
+ const char *arch_cstr = arch.GetArchitectureName ();
if (arch_cstr)
{
if (0 == ::strcasecmp(arch_cstr, "armv4t")) m_arm_isa = ARMv4T;
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index fb73083..7ff54c7 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -360,7 +360,7 @@
{
s->Indent();
GetArchitectureAtIndex(i, arch);
- s->Printf("arch[%u] = %s\n", arch.AsCString());
+ s->Printf("arch[%u] = %s\n", arch.GetArchitectureName());
}
for (i=0; i<num_objects; i++)
{
diff --git a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
index c2f8edc..7ff1943 100644
--- a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
+++ b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
@@ -168,7 +168,7 @@
{
s->Indent();
GetArchitectureAtIndex(i, arch);
- s->Printf("arch[%u] = %s\n", arch.AsCString());
+ s->Printf("arch[%u] = %s\n", arch.GetArchitectureName());
}
for (i=0; i<num_objects; i++)
{
@@ -190,7 +190,7 @@
{
if (idx < m_header.nfat_arch)
{
- arch.SetMachOArch (m_fat_archs[idx].cputype, m_fat_archs[idx].cpusubtype);
+ arch.SetArchitecture (lldb::eArchTypeMachO, m_fat_archs[idx].cputype, m_fat_archs[idx].cpusubtype);
return true;
}
return false;
@@ -207,7 +207,7 @@
{
arch = Target::GetDefaultArchitecture ();
if (!arch.IsValid())
- arch = LLDB_ARCH_DEFAULT;
+ arch.SetTriple (LLDB_ARCH_DEFAULT);
}
else
arch = m_module->GetArchitecture();
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 0739b97..445518d 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/Stream.h"
+#include "lldb/Host/Host.h"
#define CASE_AND_STREAM(s, def, width) \
case def: s->Printf("%-*s", width, #def); break;
@@ -1045,28 +1046,9 @@
bool
ObjectFileELF::GetArchitecture (ArchSpec &arch)
{
- switch (m_header.e_machine)
- {
- default:
- assert(false && "Unexpected machine type.");
- break;
- case EM_SPARC: arch.GetTriple().setArchName("sparc"); break;
- case EM_386: arch.GetTriple().setArchName("i386"); break;
- case EM_68K: arch.GetTriple().setArchName("68k"); break;
- case EM_88K: arch.GetTriple().setArchName("88k"); break;
- case EM_860: arch.GetTriple().setArchName("i860"); break;
- case EM_MIPS: arch.GetTriple().setArchName("mips"); break;
- case EM_PPC: arch.GetTriple().setArchName("powerpc"); break;
- case EM_PPC64: arch.GetTriple().setArchName("powerpc64"); break;
- case EM_ARM: arch.GetTriple().setArchName("arm"); break;
- case EM_X86_64: arch.GetTriple().setArchName("x86_64"); break;
- }
- // TODO: determine if there is a vendor in the ELF? Default to "linux" for now
- arch.GetTriple().setOSName ("linux");
- // TODO: determine if there is an OS in the ELF? Default to "gnu" for now
- arch.GetTriple().setVendorName("gnu");
-
- arch.SetElfArch(m_header.e_machine, m_header.e_flags);
+ arch.SetArchitecture (lldb::eArchTypeELF, m_header.e_machine, m_header.e_flags);
+ arch.GetTriple().setOSName (Host::GetOSString().GetCString());
+ arch.GetTriple().setVendorName(Host::GetVendorString().GetCString());
return true;
}
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index ac536c5..deac894 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1351,7 +1351,7 @@
ArchSpec header_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
- *s << ", file = '" << m_file << "', arch = " << header_arch.AsCString() << "\n";
+ *s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n";
if (m_sections_ap.get())
m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
@@ -1439,7 +1439,7 @@
ObjectFileMachO::GetArchitecture (ArchSpec &arch)
{
lldb_private::Mutex::Locker locker(m_mutex);
- arch.SetMachOArch(m_header.cputype, m_header.cpusubtype);
+ arch.SetArchitecture (lldb::eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
return true;
}
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 a218c1d..5141e4b 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
@@ -42,7 +42,11 @@
void
MachThreadContext_i386::Initialize()
{
- ArchSpec arch_spec("i386");
+ llvm::Triple triple;
+ triple.setArch (llvm::Triple::x86);
+ triple.setVendor (llvm::Triple::Apple);
+ triple.setOS (llvm::Triple::Darwin);
+ ArchSpec arch_spec (triple);
ProcessMacOSX::AddArchCreateCallback(arch_spec, MachThreadContext_i386::Create);
}
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 706f63a..a31713e 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
@@ -11,6 +11,8 @@
#include <sys/cdefs.h>
+#include "llvm/ADT/Triple.h"
+
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
@@ -41,7 +43,11 @@
void
MachThreadContext_x86_64::Initialize()
{
- ArchSpec arch_spec("x86_64");
+ llvm::Triple triple;
+ triple.setArch (llvm::Triple::x86_64);
+ triple.setVendor (llvm::Triple::Apple);
+ triple.setOS (llvm::Triple::Darwin);
+ ArchSpec arch_spec (triple);
ProcessMacOSX::AddArchCreateCallback(arch_spec, MachThreadContext_x86_64::Create);
}
diff --git a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index e4be273..464500c 100644
--- a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -337,7 +337,9 @@
// Set our user ID to an invalid process ID.
SetID (LLDB_INVALID_PROCESS_ID);
error.SetErrorToGenericError ();
- error.SetErrorStringWithFormat("Failed to get object file from '%s' for arch %s.\n", module->GetFileSpec().GetFilename().AsCString(), module->GetArchitecture().AsCString());
+ error.SetErrorStringWithFormat("Failed to get object file from '%s' for arch %s.\n",
+ module->GetFileSpec().GetFilename().AsCString(),
+ module->GetArchitecture().GetArchitectureName());
}
// Return the process ID we have
@@ -498,16 +500,16 @@
static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
- ArchSpec::CPU arch_cpu = m_arch_spec.GetGenericCPUType();
- switch (arch_cpu)
+ llvm::Triple::ArchType machine = m_arch_spec.GetMachine();
+ switch (machine)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
trap_opcode = g_i386_breakpoint_opcode;
trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::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.
@@ -515,8 +517,8 @@
trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
trap_opcode = g_ppc_breakpoint_opcode;
trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
break;
@@ -1672,19 +1674,16 @@
// 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...
- if (arch_spec.GetType() == eArchTypeMachO)
+ cpu_type_t cpu = arch_spec.GetMachOCPUType();
+ if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE)
{
- 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.get(), "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
+ size_t ocount = 0;
+ err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
+ if (err.Fail() || log)
+ err.PutToLog(log.get(), "::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/Utility/ArchDefaultUnwindPlan-x86.cpp b/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
index 6824b79..20e3ef7 100644
--- a/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
+++ b/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
@@ -18,7 +18,7 @@
lldb_private::ArchDefaultUnwindPlan *
ArchDefaultUnwindPlan_x86_64::CreateInstance (const lldb_private::ArchSpec &arch)
{
- if (arch.GetGenericCPUType () == ArchSpec::eCPU_x86_64)
+ if (arch.GetMachine () == llvm::Triple::x86_64)
return new ArchDefaultUnwindPlan_x86_64 ();
return NULL;
}
@@ -126,7 +126,7 @@
lldb_private::ArchDefaultUnwindPlan *
ArchDefaultUnwindPlan_i386::CreateInstance (const lldb_private::ArchSpec &arch)
{
- if (arch.GetGenericCPUType () == ArchSpec::eCPU_i386)
+ if (arch.GetMachine () == llvm::Triple::x86)
return new ArchDefaultUnwindPlan_i386 ();
return NULL;
}
diff --git a/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp b/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
index 35a4bf9..19eda66 100644
--- a/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
+++ b/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
@@ -34,22 +34,20 @@
lldb_private::ArchVolatileRegs *
ArchVolatileRegs_x86::CreateInstance (const lldb_private::ArchSpec &arch)
{
- uint32_t cpu = arch.GetCPUType ();
- if (cpu != llvm::MachO::CPUTypeX86_64 && cpu != llvm::MachO::CPUTypeI386)
- return NULL;
-
- return new ArchVolatileRegs_x86 (cpu);
+ llvm::Triple::ArchType cpu = arch.GetMachine ();
+ if (cpu == llvm::Triple::x86 || cpu == llvm::Triple::x86_64)
+ return new ArchVolatileRegs_x86 (cpu);
+ return NULL;
}
-ArchVolatileRegs_x86::ArchVolatileRegs_x86(int cpu) :
- lldb_private::ArchVolatileRegs(),
- m_cpu(cpu),
- m_non_volatile_regs()
+ArchVolatileRegs_x86::ArchVolatileRegs_x86(llvm::Triple::ArchType cpu) :
+ lldb_private::ArchVolatileRegs(),
+ m_cpu(cpu),
+ m_non_volatile_regs()
{
}
void
-
ArchVolatileRegs_x86::initialize_regset(Thread& thread)
{
if (m_non_volatile_regs.size() > 0)
@@ -78,13 +76,14 @@
const char **names;
int namecount;
- if (m_cpu == llvm::MachO::CPUTypeX86_64)
+ if (m_cpu == llvm::Triple::x86_64)
{
names = x86_64_regnames;
namecount = sizeof (x86_64_regnames) / sizeof (char *);
}
else
{
+ assert (m_cpu == llvm::Triple::x86);
names = i386_regnames;
namecount = sizeof (i386_regnames) / sizeof (char *);
}
diff --git a/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h b/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h
index 97714b9..516f126 100644
--- a/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h
+++ b/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h
@@ -11,6 +11,7 @@
#define liblldb_ArchVolatileRegs_x86_h_
#include "lldb/lldb-private.h"
+#include "lldb/Core/ArchSpec.h"
#include "lldb/Utility/ArchVolatileRegs.h"
#include <set>
@@ -62,11 +63,11 @@
EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command);
private:
- ArchVolatileRegs_x86(int cpu); // Call CreateInstance instead.
+ ArchVolatileRegs_x86(llvm::Triple::ArchType cpu); // Call CreateInstance instead.
void initialize_regset(lldb_private::Thread& thread);
- int m_cpu;
+ llvm::Triple::ArchType m_cpu;
std::set<int> m_non_volatile_regs;
};
diff --git a/source/Plugins/Process/Utility/StopInfoMachException.cpp b/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 2a47640..79cbde4 100644
--- a/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -30,7 +30,7 @@
{
if (m_description.empty() && m_value != 0)
{
- ArchSpec::CPU cpu = m_thread.GetProcess().GetTarget().GetArchitecture().GetGenericCPUType();
+ const llvm::Triple::ArchType cpu = m_thread.GetProcess().GetTarget().GetArchitecture().GetMachine();
const char *exc_desc = NULL;
const char *code_label = "code";
@@ -44,7 +44,7 @@
subcode_label = "address";
switch (cpu)
{
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
switch (m_exc_code)
{
case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
@@ -52,8 +52,8 @@
}
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (m_exc_code)
{
case 0x101: code_desc = "EXC_PPC_VM_PROT_READ"; break;
@@ -71,14 +71,14 @@
exc_desc = "EXC_BAD_INSTRUCTION";
switch (cpu)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
if (m_exc_code == 1)
code_desc = "EXC_I386_INVOP";
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (m_exc_code)
{
case 1: code_desc = "EXC_PPC_INVALID_SYSCALL"; break;
@@ -90,7 +90,7 @@
}
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
if (m_exc_code == 1)
code_desc = "EXC_ARM_UNDEFINED";
break;
@@ -104,8 +104,8 @@
exc_desc = "EXC_ARITHMETIC";
switch (cpu)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
switch (m_exc_code)
{
case 1: code_desc = "EXC_I386_DIV"; break;
@@ -119,8 +119,8 @@
}
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (m_exc_code)
{
case 1: code_desc = "EXC_PPC_OVERFLOW"; break;
@@ -157,8 +157,8 @@
exc_desc = "EXC_BREAKPOINT";
switch (cpu)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
switch (m_exc_code)
{
case 1: subcode_desc = "EXC_I386_SGL"; break;
@@ -166,15 +166,15 @@
}
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (m_exc_code)
{
case 1: subcode_desc = "EXC_PPC_BREAKPOINT"; break;
}
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
switch (m_exc_code)
{
case 1: subcode_desc = "EXC_ARM_BREAKPOINT"; break;
@@ -248,7 +248,7 @@
{
if (exc_type != 0)
{
- ArchSpec::CPU cpu = thread.GetProcess().GetTarget().GetArchitecture().GetGenericCPUType();
+ const llvm::Triple::ArchType cpu = thread.GetProcess().GetTarget().GetArchitecture().GetMachine();
switch (exc_type)
{
@@ -258,8 +258,8 @@
case 2: // EXC_BAD_INSTRUCTION
switch (cpu)
{
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (exc_code)
{
case 1: // EXC_PPC_INVALID_SYSCALL
@@ -293,8 +293,8 @@
bool is_software_breakpoint = false;
switch (cpu)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
if (exc_code == 1) // EXC_I386_SGL
{
return StopInfo::CreateStopReasonToTrace(thread);
@@ -305,12 +305,12 @@
}
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
is_software_breakpoint = exc_code == 1; // EXC_PPC_BREAKPOINT
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
is_software_breakpoint = exc_code == 1; // EXC_ARM_BREAKPOINT
break;
diff --git a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
index 94b3ae1..8f0f7d4 100644
--- a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
+++ b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
@@ -847,11 +847,12 @@
UnwindAssemblyProfiler *
UnwindAssemblyProfiler_x86::CreateInstance (const ArchSpec &arch)
{
- ArchSpec::CPU cpu = arch.GetGenericCPUType ();
- if (cpu != ArchSpec::eCPU_x86_64 && cpu != ArchSpec::eCPU_i386)
- return NULL;
-
- return new UnwindAssemblyProfiler_x86 (cpu == ArchSpec::eCPU_x86_64 ? k_x86_64 : k_i386);
+ const llvm::Triple::ArchType cpu = arch.GetMachine ();
+ if (cpu == llvm::Triple::x86)
+ return new UnwindAssemblyProfiler_x86 (k_i386);
+ else if (cpu == llvm::Triple::x86_64)
+ return new UnwindAssemblyProfiler_x86 (k_x86_64);
+ return NULL;
}
diff --git a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
index 2d9e021..f712fd9 100644
--- a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
+++ b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
@@ -32,12 +32,12 @@
{
if (m_cursors.empty())
{
- const ArchSpec target_arch (m_thread.GetProcess().GetTarget().GetArchitecture ());
+ const ArchSpec& target_arch = m_thread.GetProcess().GetTarget().GetArchitecture ();
// Frame zero should always be supplied by the thread...
StackFrameSP frame_sp (m_thread.GetStackFrameAtIndex (0));
- if (target_arch == ArchSpec("x86_64"))
+ if (target_arch.GetMachine() == llvm::Triple::x86_64)
GetStackFrameData_x86_64 (frame_sp.get());
- else if (target_arch == ArchSpec("i386"))
+ else if (target_arch.GetMachine() == llvm::Triple::x86)
GetStackFrameData_i386 (frame_sp.get());
}
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index e23be43..126b60f 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1001,7 +1001,7 @@
}
if (cpu != LLDB_INVALID_CPUTYPE)
- m_arch.SetMachOArch (cpu, sub);
+ m_arch.SetArchitecture (lldb::eArchTypeMachO, cpu, sub);
}
}
return m_supports_qHostInfo == eLazyBoolYes;
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index df3e09a..34eca44 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -328,8 +328,7 @@
// We didn't get anything. See if we are debugging ARM and fill with
// a hard coded register set until we can get an updated debugserver
// down on the devices.
- ArchSpec arm_arch ("arm");
- if (GetTarget().GetArchitecture() == arm_arch)
+ if (GetTarget().GetArchitecture().GetMachine() == llvm::Triple::arm)
m_register_info.HardcodeARMRegisters();
}
m_register_info.Finalize ();
@@ -553,7 +552,9 @@
{
// Set our user ID to an invalid process ID.
SetID(LLDB_INVALID_PROCESS_ID);
- error.SetErrorStringWithFormat("Failed to get object file from '%s' for arch %s.\n", module->GetFileSpec().GetFilename().AsCString(), module->GetArchitecture().AsCString());
+ error.SetErrorStringWithFormat("Failed to get object file from '%s' for arch %s.\n",
+ module->GetFileSpec().GetFilename().AsCString(),
+ module->GetArchitecture().GetArchitectureName());
}
return error;
@@ -642,8 +643,8 @@
// it has, so we really need to take the remote host architecture as our
// defacto architecture in this case.
- if (gdb_remote_arch == ArchSpec ("arm") &&
- vendor && ::strcmp(vendor, "apple") == 0)
+ if (gdb_remote_arch.GetMachine() == llvm::Triple::arm &&
+ gdb_remote_arch.GetTriple().getVendor() == llvm::Triple::Apple)
{
GetTarget().SetArchitecture (gdb_remote_arch);
target_arch = gdb_remote_arch;
@@ -1044,16 +1045,16 @@
static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
- ArchSpec::CPU arch_cpu = GetTarget().GetArchitecture().GetGenericCPUType();
- switch (arch_cpu)
+ const llvm::Triple::ArchType machine = GetTarget().GetArchitecture().GetMachine();
+ switch (machine)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
trap_opcode = g_i386_breakpoint_opcode;
trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::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.
@@ -1061,8 +1062,8 @@
trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
trap_opcode = g_ppc_breakpoint_opcode;
trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
break;
@@ -1955,31 +1956,33 @@
Error local_err; // Errors that don't affect the spawning.
if (log)
- log->Printf ("%s ( path='%s', argv=%p, envp=%p, arch=%s )", __FUNCTION__, debugserver_path, inferior_argv, inferior_envp, inferior_arch.AsCString());
+ log->Printf ("%s ( path='%s', argv=%p, envp=%p, arch=%s )",
+ __FUNCTION__,
+ debugserver_path,
+ inferior_argv,
+ inferior_envp,
+ inferior_arch.GetArchitectureName());
error.SetError( ::posix_spawnattr_init (&attr), eErrorTypePOSIX);
if (error.Fail() || log)
error.PutToLog(log.get(), "::posix_spawnattr_init ( &attr )");
if (error.Fail())
- return error;;
+ return error;
#if !defined (__arm__)
// 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...
- if (inferior_arch.GetType() == eArchTypeMachO)
+ cpu_type_t cpu = inferior_arch.GetMachOCPUType();
+ if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE)
{
- 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.get(), "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
-
- if (error.Fail() != 0 || ocount != 1)
- return error;
- }
+ size_t ocount = 0;
+ error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
+ if (error.Fail() || log)
+ error.PutToLog(log.get(), "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
+
+ if (error.Fail() != 0 || ocount != 1)
+ return error;
}
#endif
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 635c00c..99ce588 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -142,7 +142,8 @@
if (m_unwinder_ap.get() == NULL)
{
const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ());
- if (target_arch == ArchSpec("x86_64") || target_arch == ArchSpec("i386"))
+ const llvm::Triple::ArchType machine = target_arch.GetMachine();
+ if (machine == llvm::Triple::x86_64 || machine == llvm::Triple::x86)
{
m_unwinder_ap.reset (new UnwindLLDB (*this));
}