summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/MacOSX-User
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/Process/MacOSX-User
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/Process/MacOSX-User')
-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
3 files changed, 30 insertions, 21 deletions
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
OpenPOWER on IntegriCloud