summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-02-23 00:35:02 +0000
committerGreg Clayton <gclayton@apple.com>2011-02-23 00:35:02 +0000
commit64195a2c8bd8166e2e70dcac6d5b3a88fbb1f910 (patch)
tree4371f2a424bba44b326674edd497630e91e89f00 /lldb/source/Plugins
parent37de3235e5a85c4d3cff8edc71e214a1a18aa21f (diff)
downloadbcm5719-llvm-64195a2c8bd8166e2e70dcac6d5b3a88fbb1f910.tar.gz
bcm5719-llvm-64195a2c8bd8166e2e70dcac6d5b3a88fbb1f910.zip
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. llvm-svn: 126278
Diffstat (limited to 'lldb/source/Plugins')
-rw-r--r--lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp10
-rw-r--r--lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp2
-rw-r--r--lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp2
-rw-r--r--lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp6
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp26
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp4
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp6
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp8
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp37
-rw-r--r--lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp4
-rw-r--r--lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp21
-rw-r--r--lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h5
-rw-r--r--lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp52
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp11
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp55
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp3
18 files changed, 126 insertions, 134 deletions
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index bc6bfd16ccc..edecaa17486 100644
--- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -345,16 +345,12 @@ DisassemblerLLVM::InstructionLLVM::Extract(const DataExtractor &data, uint32_t d
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/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 491cdada4c0..76a74bda68a 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -6814,7 +6814,7 @@ bool
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/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index fb73083afc4..7ff54c7ed8e 100644
--- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -360,7 +360,7 @@ ObjectContainerBSDArchive::Dump (Stream *s) const
{
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/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
index c2f8edc415b..7ff1943532c 100644
--- a/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
+++ b/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
@@ -168,7 +168,7 @@ ObjectContainerUniversalMachO::Dump (Stream *s) const
{
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 @@ ObjectContainerUniversalMachO::GetArchitectureAtIndex (uint32_t idx, ArchSpec& a
{
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 @@ ObjectContainerUniversalMachO::GetObjectFile (const FileSpec *file)
{
arch = Target::GetDefaultArchitecture ();
if (!arch.IsValid())
- arch = LLDB_ARCH_DEFAULT;
+ arch.SetTriple (LLDB_ARCH_DEFAULT);
}
else
arch = m_module->GetArchitecture();
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 0739b978aa3..445518d9e64 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/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 @@ ObjectFileELF::DumpDependentModules(lldb_private::Stream *s)
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/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index ac536c56617..deac8947521 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1351,7 +1351,7 @@ ObjectFileMachO::Dump (Stream *s)
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 @@ bool
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/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
index a218c1dd041..5141e4b67eb 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
@@ -42,7 +42,11 @@ MachThreadContext_i386::Create (const ArchSpec &arch_spec, ThreadMacOSX &thread)
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/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
index 706f63a53b6..a31713edd85 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
+++ b/lldb/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 @@ MachThreadContext_x86_64::Create(const ArchSpec &arch_spec, ThreadMacOSX &thread
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/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index e4be2730584..464500cf6b3 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -337,7 +337,9 @@ ProcessMacOSX::DoLaunch
// 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 @@ ProcessMacOSX::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
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 @@ ProcessMacOSX::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
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 @@ ProcessMacOSX::PosixSpawnChildForPTraceDebugging
// 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/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp b/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
index 6824b799dd7..20e3ef76021 100644
--- a/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
+++ b/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
@@ -18,7 +18,7 @@ using namespace lldb_private;
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 @@ ArchDefaultUnwindPlan_x86_64::GetArchDefaultUnwindPlan (Thread& thread, Address
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/lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp b/lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
index 35a4bf9204f..19eda664db1 100644
--- a/lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
+++ b/lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
@@ -34,22 +34,20 @@ ArchVolatileRegs_x86::RegisterIsVolatile (Thread& thread, uint32_t regnum)
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 @@ ArchVolatileRegs_x86::initialize_regset(Thread& thread)
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/lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h b/lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h
index 97714b99da4..516f126e91b 100644
--- a/lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h
+++ b/lldb/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 @@ public:
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/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 2a47640f6d9..79cbde4de1c 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -30,7 +30,7 @@ StopInfoMachException::GetDescription ()
{
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 @@ StopInfoMachException::GetDescription ()
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 @@ StopInfoMachException::GetDescription ()
}
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 @@ StopInfoMachException::GetDescription ()
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 @@ StopInfoMachException::GetDescription ()
}
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
if (m_exc_code == 1)
code_desc = "EXC_ARM_UNDEFINED";
break;
@@ -104,8 +104,8 @@ StopInfoMachException::GetDescription ()
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 @@ StopInfoMachException::GetDescription ()
}
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 @@ StopInfoMachException::GetDescription ()
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 @@ StopInfoMachException::GetDescription ()
}
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 @@ StopInfoMachException::CreateStopReasonWithMachException
{
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 @@ StopInfoMachException::CreateStopReasonWithMachException
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 @@ StopInfoMachException::CreateStopReasonWithMachException
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 @@ StopInfoMachException::CreateStopReasonWithMachException
}
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/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp b/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
index 94b3ae1c8bb..8f0f7d47578 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
+++ b/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
@@ -847,11 +847,12 @@ UnwindAssemblyProfiler_x86::FirstNonPrologueInsn (AddressRange& func, Target& ta
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/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
index 2d9e0210929..f712fd92c54 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
+++ b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
@@ -32,12 +32,12 @@ UnwindMacOSXFrameBackchain::GetFrameCount()
{
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/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index e23be430b2e..126b60f2f70 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1001,7 +1001,7 @@ GDBRemoteCommunication::GetHostInfo ()
}
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/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index df3e09a9988..34eca44081a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -328,8 +328,7 @@ ProcessGDBRemote::BuildDynamicRegisterInfo (bool force)
// 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 @@ ProcessGDBRemote::DoLaunch
{
// 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 @@ ProcessGDBRemote::DidLaunchOrAttach ()
// 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 @@ ProcessGDBRemote::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
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 @@ ProcessGDBRemote::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
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 @@ ProcessGDBRemote::StartDebugserverProcess
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/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 635c00c7438..99ce588a30d 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -142,7 +142,8 @@ ThreadGDBRemote::GetUnwinder ()
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));
}
OpenPOWER on IntegriCloud