Made lldb_private::ArchSpec contain much more than just an architecture. It
now, in addition to cpu type/subtype and architecture flavor, contains:
- byte order (big endian, little endian)
- address size in bytes
- llvm::Triple for true target triple support and for more powerful plug-in
selection.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125602 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index 2a3d415..3b59960 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -371,7 +371,7 @@
{
uint32_t size = 0;
if (m_opaque_sp)
- size = m_opaque_sp->GetAddressByteSize();
+ size = m_opaque_sp->GetTarget().GetArchitecture().GetAddressByteSize();
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
diff --git a/source/Commands/CommandObjectImage.cpp b/source/Commands/CommandObjectImage.cpp
index cef305f..4843e4f 100644
--- a/source/Commands/CommandObjectImage.cpp
+++ b/source/Commands/CommandObjectImage.cpp
@@ -342,7 +342,7 @@
int addr_size = sizeof (addr_t);
Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process)
- addr_size = process->GetAddressByteSize();
+ addr_size = process->GetTarget().GetArchitecture().GetAddressByteSize();
if (vm_addr != LLDB_INVALID_ADDRESS)
strm.Address (vm_addr, addr_size);
else
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index 949cadc..4a66dd6 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -260,7 +260,7 @@
if (item_byte_size == 0)
{
if (m_options.m_format == eFormatPointer)
- item_byte_size = process->GetAddressByteSize();
+ item_byte_size = process->GetTarget().GetArchitecture().GetAddressByteSize();
else
item_byte_size = 1;
}
@@ -334,7 +334,9 @@
result.AppendWarningWithFormat("Not all bytes (%u/%u) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr);
result.SetStatus(eReturnStatusSuccessFinishResult);
- DataExtractor data(data_sp, process->GetByteOrder(), process->GetAddressByteSize());
+ DataExtractor data (data_sp,
+ process->GetTarget().GetArchitecture().GetByteOrder(),
+ process->GetTarget().GetArchitecture().GetAddressByteSize());
StreamFile outfile_stream;
Stream *output_stream = NULL;
@@ -616,8 +618,8 @@
}
StreamString buffer (Stream::eBinary,
- process->GetAddressByteSize(),
- process->GetByteOrder());
+ process->GetTarget().GetArchitecture().GetAddressByteSize(),
+ process->GetTarget().GetArchitecture().GetByteOrder());
size_t item_byte_size = m_options.m_byte_size;
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 181012d..7329ccb 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -328,6 +328,10 @@
if (synchronous_execution)
{
state = process->WaitForProcessToStop (NULL);
+ if (!StateIsStoppedState(state));
+ {
+ result.AppendErrorWithFormat ("Process isn't stopped: %s", StateAsCString(state));
+ }
result.SetDidChangeProcessState (true);
result.SetStatus (eReturnStatusSuccessFinishResult);
}
@@ -336,9 +340,24 @@
result.SetStatus (eReturnStatusSuccessContinuingNoResult);
}
}
+ else
+ {
+ result.AppendErrorWithFormat ("Process resume at entry point failed: %s", error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ }
}
+ else
+ {
+ result.AppendErrorWithFormat ("Initial process state wasn't stopped: %s", StateAsCString(state));
+ result.SetStatus (eReturnStatusFailed);
+ }
}
}
+ else
+ {
+ result.AppendErrorWithFormat ("Process launch failed: %s", error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ }
return result.Succeeded();
}
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index d138f02..67d2c2e 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -42,11 +42,11 @@
if (exe_scope == NULL)
return false;
- Process *process = exe_scope->CalculateProcess();
- if (process)
+ Target *target = exe_scope->CalculateTarget();
+ if (target)
{
- byte_order = process->GetByteOrder();
- addr_size = process->GetAddressByteSize();
+ byte_order = target->GetArchitecture().GetByteOrder();
+ addr_size = target->GetArchitecture().GetAddressByteSize();
}
if (byte_order == eByteOrderInvalid || addr_size == 0)
@@ -54,7 +54,7 @@
Module *module = address.GetModule();
if (module)
{
- byte_order = module->GetArchitecture().GetDefaultEndian();
+ byte_order = module->GetArchitecture().GetByteOrder();
addr_size = module->GetArchitecture().GetAddressByteSize();
}
}
@@ -313,7 +313,7 @@
if (addr_size == UINT32_MAX)
{
if (process)
- addr_size = process->GetAddressByteSize ();
+ addr_size = target->GetArchitecture().GetAddressByteSize ();
else
addr_size = sizeof(addr_t);
}
@@ -387,8 +387,8 @@
uint32_t pointer_size = 4;
Module *module = GetModule();
- if (process)
- pointer_size = process->GetAddressByteSize();
+ if (target)
+ pointer_size = target->GetArchitecture().GetAddressByteSize();
else if (module)
pointer_size = module->GetArchitecture().GetAddressByteSize();
diff --git a/source/Core/AddressRange.cpp b/source/Core/AddressRange.cpp
index b5ed92d..42b1b20 100644
--- a/source/Core/AddressRange.cpp
+++ b/source/Core/AddressRange.cpp
@@ -143,8 +143,8 @@
{
addr_t vmaddr = LLDB_INVALID_ADDRESS;
int addr_size = sizeof (addr_t);
- if (target && target->GetProcessSP())
- addr_size = target->GetProcessSP()->GetAddressByteSize ();
+ if (target)
+ addr_size = target->GetArchitecture().GetAddressByteSize ();
bool show_module = false;
switch (style)
diff --git a/source/Core/ArchSpec.cpp b/source/Core/ArchSpec.cpp
index caecf02..a17c0aa 100644
--- a/source/Core/ArchSpec.cpp
+++ b/source/Core/ArchSpec.cpp
@@ -15,6 +15,8 @@
#include "llvm/Support/ELF.h"
#include "llvm/Support/MachO.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Host/Host.h"
using namespace lldb;
using namespace lldb_private;
@@ -28,6 +30,8 @@
//----------------------------------------------------------------------
struct ArchDefinition
{
+ ByteOrder byte_order;
+ uint32_t addr_byte_size;
uint32_t cpu;
uint32_t sub;
const char *name;
@@ -52,54 +56,36 @@
//----------------------------------------------------------------------
static ArchDefinition g_mach_arch_defs[] =
{
- { 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
- // the default, 32 and 64 bit cases instead of hard coding it in this
- // table.
-
-#if defined (__i386__) || defined(__x86_64__)
- { 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__)
- { llvm::MachO::CPUTypeARM, 6 , LLDB_ARCH_DEFAULT },
- { llvm::MachO::CPUTypeARM, 6 , LLDB_ARCH_DEFAULT_32BIT },
-#elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
- { llvm::MachO::CPUTypePowerPC, 10 , LLDB_ARCH_DEFAULT },
- { llvm::MachO::CPUTypePowerPC, 10 , LLDB_ARCH_DEFAULT_32BIT },
- { llvm::MachO::CPUTypePowerPC64, 100 , LLDB_ARCH_DEFAULT_64BIT },
-#endif
+ { eByteOrderInvalid, 0, CPU_ANY, CPU_ANY , "all" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, CPU_ANY , "arm" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 0 , "arm" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 5 , "armv4" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 6 , "armv6" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 7 , "armv5" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 8 , "xscale" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 9 , "armv7" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, CPU_ANY , "ppc" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 0 , "ppc" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 1 , "ppc601" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 2 , "ppc602" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 3 , "ppc603" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 4 , "ppc603e" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 5 , "ppc603ev" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 6 , "ppc604" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 7 , "ppc604e" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 8 , "ppc620" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 9 , "ppc750" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 10 , "ppc7400" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 11 , "ppc7450" },
+ { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 100 , "ppc970" },
+ { eByteOrderBig, 8, llvm::MachO::CPUTypePowerPC64, 0 , "ppc64" },
+ { eByteOrderBig, 8, llvm::MachO::CPUTypePowerPC64, 100 , "ppc970-64" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 3 , "i386" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 4 , "i486" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 0x84 , "i486sx" },
+ { eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, CPU_ANY , "i386" },
+ { eByteOrderLittle, 8, llvm::MachO::CPUTypeX86_64, 3 , "x86_64" },
+ { eByteOrderLittle, 8, llvm::MachO::CPUTypeX86_64, CPU_ANY , "x86_64" },
};
//----------------------------------------------------------------------
@@ -118,33 +104,20 @@
//----------------------------------------------------------------------
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
+ { eByteOrderInvalid, 0, llvm::ELF::EM_M32 , 0, "m32" }, // AT&T WE 32100
+ { eByteOrderBig, 4, llvm::ELF::EM_SPARC , 0, "sparc" }, // Sparc
+ { eByteOrderLittle, 4, llvm::ELF::EM_386 , 0, "i386" }, // Intel 80386
+ { eByteOrderBig, 4, llvm::ELF::EM_68K , 0, "68k" }, // Motorola 68000
+ { eByteOrderBig, 4, llvm::ELF::EM_88K , 0, "88k" }, // Motorola 88000
+ { eByteOrderLittle, 4, llvm::ELF::EM_486 , 0, "i486" }, // Intel 486 (deprecated)
+ { eByteOrderLittle, 4, llvm::ELF::EM_860 , 0, "860" }, // Intel 80860
+ { eByteOrderBig, 4, llvm::ELF::EM_MIPS , 0, "rs3000" }, // MIPS RS3000
+ { eByteOrderBig, 4, llvm::ELF::EM_PPC , 0, "ppc" }, // PowerPC
+ { eByteOrderBig, 8, 21 , 0, "ppc64" }, // PowerPC64
+ { eByteOrderLittle, 4, llvm::ELF::EM_ARM , 0, "arm" }, // ARM
+ { eByteOrderLittle, 4, llvm::ELF::EM_ALPHA , 0, "alpha" }, // DEC Alpha
+ { eByteOrderLittle, 4, llvm::ELF::EM_SPARCV9, 0, "sparc9" }, // SPARC V9
+ { eByteOrderLittle, 8, llvm::ELF::EM_X86_64 , 0, "x86_64" }, // AMD64
};
//----------------------------------------------------------------------
@@ -158,7 +131,10 @@
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)
+ m_sub (0),
+ m_triple (),
+ m_byte_order (lldb::endian::InlHostByteOrder()),
+ m_addr_byte_size (0)
{
}
@@ -169,31 +145,38 @@
ArchSpec::ArchSpec (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub) :
m_type (arch_type),
m_cpu (cpu),
- m_sub (sub)
+ m_sub (sub),
+ m_triple (),
+ m_byte_order (lldb::endian::InlHostByteOrder()),
+ m_addr_byte_size (0)
{
+ if (m_type == eArchTypeMachO)
+ MachOArchUpdated ();
}
//----------------------------------------------------------------------
// Constructor that initializes the object with supplied
// architecture name. There are also predefined values in
// Defines.h:
-// liblldb_ARCH_DEFAULT
+// LLDB_ARCH_DEFAULT
// The arch the current system defaults to when a program is
// launched without any extra attributes or settings.
//
-// liblldb_ARCH_DEFAULT_32BIT
+// LLDB_ARCH_DEFAULT_32BIT
// The 32 bit arch the current system defaults to (if any)
//
-// liblldb_ARCH_DEFAULT_32BIT
+// LLDB_ARCH_DEFAULT_32BIT
// The 64 bit arch the current system defaults to (if any)
//----------------------------------------------------------------------
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)
+ m_sub (0),
+ m_triple (),
+ m_byte_order (lldb::endian::InlHostByteOrder()),
+ m_addr_byte_size (0)
{
- if (arch_name)
- SetArch (arch_name);
+ SetArch (arch_name);
}
//----------------------------------------------------------------------
@@ -214,6 +197,9 @@
m_type = rhs.m_type;
m_cpu = rhs.m_cpu;
m_sub = rhs.m_sub;
+ m_triple = rhs.m_triple;
+ m_byte_order = rhs.m_byte_order;
+ m_addr_byte_size = rhs.m_addr_byte_size;
}
return *this;
}
@@ -294,6 +280,9 @@
m_type = eArchTypeInvalid;
m_cpu = LLDB_INVALID_CPUTYPE;
m_sub = 0;
+ m_triple = llvm::Triple();
+ m_byte_order = lldb::endian::InlHostByteOrder();
+ m_addr_byte_size = 0;
}
@@ -1605,6 +1594,9 @@
uint32_t
ArchSpec::GetAddressByteSize() const
{
+ if (m_addr_byte_size > 0)
+ return m_addr_byte_size;
+
switch (m_type)
{
case kNumArchTypes:
@@ -1639,7 +1631,6 @@
}
break;
}
-
return 0;
}
@@ -1667,6 +1658,105 @@
}
return SetArch (target_triple);
}
+void
+ArchSpec::SetMachOArch (uint32_t cpu, uint32_t sub)
+{
+ m_type = lldb::eArchTypeMachO;
+ m_cpu = cpu;
+ m_sub = sub;
+ MachOArchUpdated ();
+}
+
+void
+ArchSpec::MachOArchUpdated (size_t idx)
+{
+ // m_type, m_cpu, and m_sub have been updated, fixup everything else
+ if (idx >= k_num_mach_arch_defs)
+ {
+ for (size_t i=0; i<k_num_mach_arch_defs; i++)
+ {
+ if (m_cpu == g_mach_arch_defs[i].cpu)
+ {
+ if (m_sub == CPU_ANY || m_sub == LLDB_INVALID_CPUTYPE)
+ {
+ if (m_sub == g_mach_arch_defs[i].sub)
+ {
+ idx = i;
+ break;
+ }
+ }
+ else if ((m_sub & 0x00ffffff) == g_mach_arch_defs[i].sub)
+ {
+ idx = i;
+ break;
+ }
+ }
+ }
+ }
+
+ if (idx < k_num_mach_arch_defs)
+ {
+ m_byte_order = g_mach_arch_defs[idx].byte_order;
+ m_addr_byte_size = g_mach_arch_defs[idx].addr_byte_size;
+ char triple_cstr[1024];
+ int triple_cstr_len = ::snprintf (triple_cstr,
+ sizeof(triple_cstr),
+ "%s-apple-darwin",
+ g_mach_arch_defs[idx].name);
+ std::string triple_sstr (llvm::Triple::normalize (llvm::StringRef (triple_cstr, triple_cstr_len)));
+ llvm::StringRef triple_sref (triple_sstr.c_str(), triple_sstr.size());
+ llvm::Triple triple (triple_sref);
+ m_triple = triple;
+ }
+ else
+ {
+ assert (!"Unknown mach-o architecture");
+ m_byte_order = lldb::endian::InlHostByteOrder();
+ // We weren't able to find our CPU type in out known list of mach architectures...
+ if (GetCPUType() & llvm::MachO::CPUArchABI64)
+ m_addr_byte_size = 8;
+ else
+ m_addr_byte_size = 4;
+ m_triple = llvm::Triple();
+ }
+}
+
+void
+ArchSpec::ELFArchUpdated (size_t idx)
+{
+ if (idx >= k_num_elf_arch_defs)
+ {
+ for (size_t i=0; i<k_num_elf_arch_defs; i++)
+ {
+ if (g_elf_arch_defs[i].cpu == m_cpu)
+ {
+ idx = i;
+ break;
+ }
+ }
+ }
+ if (idx < k_num_elf_arch_defs)
+ {
+ m_byte_order = g_elf_arch_defs[idx].byte_order;
+ m_addr_byte_size = g_elf_arch_defs[idx].addr_byte_size;
+ char triple_cstr[1024];
+ int triple_cstr_len = ::snprintf (triple_cstr,
+ sizeof(triple_cstr),
+ "%s-unknown-unknown",
+ g_elf_arch_defs[idx].name);
+ std::string triple_sstr (llvm::Triple::normalize (llvm::StringRef (triple_cstr, triple_cstr_len)));
+ llvm::StringRef triple_sref (triple_sstr.c_str(), triple_sstr.size());
+ llvm::Triple triple (triple_sref);
+ m_triple = triple;
+ }
+ else
+ {
+ assert (!"Unknown ELF architecture");
+ m_byte_order = lldb::endian::InlHostByteOrder();
+ m_addr_byte_size = sizeof(void *);
+ m_triple = llvm::Triple();
+ }
+}
//----------------------------------------------------------------------
// Change the CPU type and subtype given an architecture name.
@@ -1676,8 +1766,22 @@
{
if (arch_name && arch_name[0] != '\0')
{
- size_t i;
+ // All system default architecture string values start with LLDB_ARCH_DEFAULT
+ if (::strncmp (arch_name, LLDB_ARCH_DEFAULT, strlen(LLDB_ARCH_DEFAULT)) == 0)
+ {
+ // Special case for the current host default architectures...
+ if (::strcmp (arch_name, LLDB_ARCH_DEFAULT_32BIT) == 0)
+ *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
+ else if (::strcmp (arch_name, LLDB_ARCH_DEFAULT_64BIT) == 0)
+ *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture64);
+ else
+ *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
+
+ return IsValid();
+ }
+
+ size_t i;
switch (m_type)
{
case eArchTypeInvalid:
@@ -1689,6 +1793,7 @@
m_type = eArchTypeMachO;
m_cpu = g_mach_arch_defs[i].cpu;
m_sub = g_mach_arch_defs[i].sub;
+ MachOArchUpdated (i);
return true;
}
}
@@ -1701,6 +1806,7 @@
{
m_cpu = g_elf_arch_defs[i].cpu;
m_sub = g_elf_arch_defs[i].sub;
+ ELFArchUpdated (i);
return true;
}
}
@@ -1731,6 +1837,7 @@
if (m_type != eArchTypeInvalid)
{
+ m_type = eArchTypeMachO;
char *end = NULL;
m_cpu = ::strtoul (str, &end, 0);
if (str != end)
@@ -1744,6 +1851,7 @@
m_sub = strtoul(str, &end, 0);
if (*end == '\0')
{
+ MachOArchUpdated ();
// We consumed the entire string and got a cpu type and subtype
return true;
}
@@ -1760,6 +1868,9 @@
if (m_cpu == g_mach_arch_defs[i].cpu)
{
m_sub = g_mach_arch_defs[i].sub;
+ m_byte_order = g_mach_arch_defs[i].byte_order;
+ m_addr_byte_size = g_mach_arch_defs[i].addr_byte_size;
+ MachOArchUpdated (i);
return true;
}
}
@@ -1767,8 +1878,8 @@
// 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;
+ MachOArchUpdated ();
return true;
-
}
}
}
@@ -1781,17 +1892,17 @@
{
switch (GetGenericCPUType ())
{
- case eCPU_ppc:
- case eCPU_ppc64:
- return eByteOrderBig;
-
- case eCPU_arm:
- case eCPU_i386:
- case eCPU_x86_64:
- return eByteOrderLittle;
-
- default:
- break;
+ case eCPU_ppc:
+ case eCPU_ppc64:
+ return eByteOrderBig;
+
+ case eCPU_arm:
+ case eCPU_i386:
+ case eCPU_x86_64:
+ return eByteOrderLittle;
+
+ default:
+ break;
}
return eByteOrderInvalid;
}
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index f699489..fbbab5b 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -1208,9 +1208,7 @@
if (vaddr != LLDB_INVALID_ADDRESS)
{
- int addr_width = 0;
- if (exe_ctx && exe_ctx->process)
- addr_width = exe_ctx->process->GetAddressByteSize() * 2;
+ int addr_width = target->GetArchitecture().GetAddressByteSize() * 2;
if (addr_width == 0)
addr_width = 16;
s.Printf("0x%*.*llx", addr_width, addr_width, vaddr);
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index 64a4c2c..994e510 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -436,16 +436,8 @@
heap_buffer->SetByteSize (bytes_read);
data.SetData(data_sp);
- if (exe_ctx->process)
- {
- data.SetByteOrder(exe_ctx->process->GetByteOrder());
- data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize());
- }
- else
- {
- data.SetByteOrder(target->GetArchitecture().GetDefaultEndian());
- data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
- }
+ data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+ data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX);
}
diff --git a/source/Core/EmulateInstruction.cpp b/source/Core/EmulateInstruction.cpp
index 0faace6..d596cdd 100644
--- a/source/Core/EmulateInstruction.cpp
+++ b/source/Core/EmulateInstruction.cpp
@@ -17,7 +17,7 @@
using namespace lldb_private;
EmulateInstruction*
-EmulateInstruction::FindPlugin (const ConstString &triple, const char *plugin_name)
+EmulateInstruction::FindPlugin (const ArchSpec &arch, const char *plugin_name)
{
EmulateInstructionCreateInstance create_callback = NULL;
if (plugin_name)
@@ -25,7 +25,7 @@
create_callback = PluginManager::GetEmulateInstructionCreateCallbackForPluginName (plugin_name);
if (create_callback)
{
- std::auto_ptr<EmulateInstruction> instance_ap(create_callback(triple));
+ std::auto_ptr<EmulateInstruction> instance_ap(create_callback(arch));
if (instance_ap.get())
return instance_ap.release();
}
@@ -34,7 +34,7 @@
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetEmulateInstructionCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- std::auto_ptr<EmulateInstruction> instance_ap(create_callback(triple));
+ std::auto_ptr<EmulateInstruction> instance_ap(create_callback(arch));
if (instance_ap.get())
return instance_ap.release();
}
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 8346938..96cc4d7 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -102,11 +102,11 @@
if (m_did_init_ast == false)
{
ObjectFile * objfile = GetObjectFile();
- ConstString target_triple;
- if (objfile && objfile->GetTargetTriple(target_triple))
+ ArchSpec object_arch;
+ if (objfile && objfile->GetArchitecture(object_arch))
{
m_did_init_ast = true;
- m_ast.SetTargetTriple (target_triple.AsCString());
+ m_ast.SetArchitecture (object_arch);
}
}
return m_ast;
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp
index 7a9733d..2dea4bc 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -25,6 +25,7 @@
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -542,8 +543,8 @@
{
address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
address_type = eAddressTypeLoad;
- data.SetByteOrder(exe_ctx->process->GetByteOrder());
- data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize());
+ data.SetByteOrder(exe_ctx->process->GetTarget().GetArchitecture().GetByteOrder());
+ data.SetAddressByteSize(exe_ctx->process->GetTarget().GetArchitecture().GetAddressByteSize());
}
break;
@@ -570,8 +571,8 @@
if (address != LLDB_INVALID_ADDRESS)
{
address_type = eAddressTypeLoad;
- data.SetByteOrder(exe_ctx->process->GetByteOrder());
- data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize());
+ data.SetByteOrder(exe_ctx->target->GetArchitecture().GetByteOrder());
+ data.SetAddressByteSize(exe_ctx->target->GetArchitecture().GetAddressByteSize());
}
else
{
diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index f73ce64..c85f558 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -104,10 +104,10 @@
lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS;
ExecutionContext exe_ctx (exe_scope);
- if (exe_ctx.process)
+ if (exe_ctx.target)
{
- m_data.SetByteOrder(exe_ctx.process->GetByteOrder());
- m_data.SetAddressByteSize(exe_ctx.process->GetAddressByteSize());
+ m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder());
+ m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize());
}
if (expr.IsLocationList())
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 29d3c3e..8f27c59 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -178,11 +178,9 @@
// Implementation of ClangExpressionParser
//===----------------------------------------------------------------------===//
-ClangExpressionParser::ClangExpressionParser(const char *target_triple,
- Process *process,
- ClangExpression &expr) :
- m_expr(expr),
- m_target_triple (),
+ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
+ ClangExpression &expr) :
+ m_expr (expr),
m_compiler (),
m_code_generator (NULL),
m_execution_engine (),
@@ -195,12 +193,7 @@
llvm::InitializeAllAsmPrinters();
}
} InitializeLLVM;
-
- if (target_triple && target_triple[0])
- m_target_triple = target_triple;
- else
- m_target_triple = llvm::sys::getHostTriple();
-
+
// 1. Create a new compiler instance.
m_compiler.reset(new CompilerInstance());
m_compiler->setLLVMContext(new LLVMContext());
@@ -215,6 +208,10 @@
m_compiler->getLangOpts().ObjC1 = true;
m_compiler->getLangOpts().ObjC2 = true;
+ Process *process = NULL;
+ if (exe_scope)
+ process = exe_scope->CalculateProcess();
+
if (process)
{
if (process->GetObjCLanguageRuntime())
@@ -239,7 +236,19 @@
m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value");
// Set the target triple.
- m_compiler->getTargetOpts().Triple = m_target_triple;
+ Target *target = NULL;
+ if (exe_scope)
+ target = exe_scope->CalculateTarget();
+
+ // TODO: figure out what to really do when we don't have a valid target.
+ // Sometimes this will be ok to just use the host target triple (when we
+ // evaluate say "2+3", but other expressions like breakpoint conditions
+ // and other things that _are_ target specific really shouldn't just be
+ // using the host triple. This needs to be fixed in a better way.
+ if (target && target->GetArchitecture().IsValid())
+ m_compiler->getTargetOpts().Triple = target->GetArchitecture().GetTriple().str();
+ else
+ m_compiler->getTargetOpts().Triple = llvm::sys::getHostTriple();
// 3. Set up various important bits of infrastructure.
m_compiler->createDiagnostics(0, 0);
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index 31b74c6..9ccb4fb 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -17,6 +17,7 @@
#include "clang/CodeGen/ModuleBuilder.h"
#include "clang/Frontend/CompilerInstance.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/Module.h"
@@ -36,6 +37,7 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
@@ -48,13 +50,13 @@
//----------------------------------------------------------------------
ClangFunction::ClangFunction
(
- const char *target_triple,
+ ExecutionContextScope *exe_scope,
ClangASTContext *ast_context,
void *return_qualtype,
const Address& functionAddress,
const ValueList &arg_value_list
) :
- m_target_triple (target_triple),
+ m_arch (),
m_function_ptr (NULL),
m_function_addr (functionAddress),
m_function_return_qual_type(return_qualtype),
@@ -66,16 +68,22 @@
m_compiled (false),
m_JITted (false)
{
+ if (exe_scope)
+ {
+ Target *target = exe_scope->CalculateTarget();
+ if (target)
+ m_arch = target->GetArchitecture();
+ }
}
ClangFunction::ClangFunction
(
- const char *target_triple,
+ ExecutionContextScope *exe_scope,
Function &function,
ClangASTContext *ast_context,
const ValueList &arg_value_list
) :
- m_target_triple (target_triple),
+ m_arch (),
m_function_ptr (&function),
m_function_addr (),
m_function_return_qual_type (),
@@ -87,6 +95,13 @@
m_compiled (false),
m_JITted (false)
{
+ if (exe_scope)
+ {
+ Target *target = exe_scope->CalculateTarget();
+ if (target)
+ m_arch = target->GetArchitecture();
+ }
+
m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress();
m_function_return_qual_type = m_function_ptr->GetReturnType().GetClangType();
}
@@ -212,7 +227,7 @@
// Okay, now compile this expression
- m_parser.reset(new ClangExpressionParser(m_target_triple.c_str(), NULL, *this));
+ m_parser.reset(new ClangExpressionParser(NULL, *this));
num_errors = m_parser->Parse (errors);
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index f64448a..5f9784e 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -234,19 +234,6 @@
return false;
}
- ConstString target_triple;
-
- target->GetTargetTriple (target_triple);
-
- if (!target_triple)
- target_triple = Host::GetTargetTriple ();
-
- if (!target_triple)
- {
- error_stream.PutCString ("error: invalid target triple\n");
- return false;
- }
-
//////////////////////////
// Parse the expression
//
@@ -257,7 +244,7 @@
m_expr_decl_map->WillParse(exe_ctx);
- ClangExpressionParser parser(target_triple.GetCString(), exe_ctx.process, *this);
+ ClangExpressionParser parser(exe_ctx.process, *this);
unsigned num_errors = parser.Parse (error_stream);
diff --git a/source/Expression/ClangUtilityFunction.cpp b/source/Expression/ClangUtilityFunction.cpp
index 03b15d1..9d9b3d1 100644
--- a/source/Expression/ClangUtilityFunction.cpp
+++ b/source/Expression/ClangUtilityFunction.cpp
@@ -81,20 +81,7 @@
error_stream.PutCString ("error: invalid target\n");
return false;
}
-
- ConstString target_triple;
-
- target->GetTargetTriple (target_triple);
-
- if (!target_triple)
- target_triple = Host::GetTargetTriple ();
-
- if (!target_triple)
- {
- error_stream.PutCString ("error: invalid target triple\n");
- return false;
- }
-
+
//////////////////////////
// Parse the expression
//
@@ -105,7 +92,7 @@
m_expr_decl_map->WillParse(exe_ctx);
- ClangExpressionParser parser(target_triple.GetCString(), exe_ctx.process, *this);
+ ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this);
unsigned num_errors = parser.Parse (error_stream);
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index ae0537b..64d1235 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -222,38 +222,122 @@
}
const ArchSpec &
-Host::GetArchitecture ()
+Host::GetArchitecture (SystemDefaultArchitecture arch_kind)
{
- static ArchSpec g_host_arch;
- if (!g_host_arch.IsValid())
- {
+ static bool g_supports_32 = false;
+ static bool g_supports_64 = false;
+ static ArchSpec g_host_arch_32;
+ static ArchSpec g_host_arch_64;
+
#if defined (__APPLE__)
+
+ // Apple is different in that it can support both 32 and 64 bit executables
+ // in the same operating system running concurrently. Here we detect the
+ // correct host architectures for both 32 and 64 bit including if 64 bit
+ // executables are supported on the system.
+
+ if (g_supports_32 == false && g_supports_64 == false)
+ {
+ // All apple systems support 32 bit execution.
+ g_supports_32 = true;
uint32_t cputype, cpusubtype;
- uint32_t is_64_bit_capable;
+ uint32_t is_64_bit_capable = false;
size_t len = sizeof(cputype);
+ ArchSpec host_arch;
+ // These will tell us about the kernel architecture, which even on a 64
+ // bit machine can be 32 bit...
if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0)
{
- len = sizeof(cpusubtype);
- if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
- g_host_arch.SetMachOArch (cputype, cpusubtype);
-
+ len = sizeof (cpusubtype);
+ if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0)
+ cpusubtype = CPU_TYPE_ANY;
+
len = sizeof (is_64_bit_capable);
if (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0)
{
if (is_64_bit_capable)
+ g_supports_64 = true;
+ }
+
+ if (is_64_bit_capable)
+ {
+ if (cputype & CPU_ARCH_ABI64)
{
- if (cputype == CPU_TYPE_I386 && cpusubtype == CPU_SUBTYPE_486)
+ // We have a 64 bit kernel on a 64 bit system
+ g_host_arch_32.SetMachOArch (CPU_TYPE_I386, CPU_SUBTYPE_386);
+ g_host_arch_64.SetMachOArch (cputype, cpusubtype);
+ }
+ else
+ {
+ // We have a 32 bit kernel on a 64 bit system
+ g_host_arch_32.SetMachOArch (cputype, cpusubtype);
+#if defined (__i386__) || defined (__x86_64__)
+ if (cpusubtype == CPU_SUBTYPE_486)
cpusubtype = CPU_SUBTYPE_I386_ALL;
-
+#endif
cputype |= CPU_ARCH_ABI64;
+ g_host_arch_64.SetMachOArch (cputype, cpusubtype);
}
}
+ else
+ {
+ g_host_arch_32.SetMachOArch (cputype, cpusubtype);
+ g_host_arch_64.Clear();
+ }
}
-#elif defined (__linux__)
- g_host_arch.SetElfArch(7u, 144u);
+ }
+
+#else // #if defined (__APPLE__)
+
+ if (g_supports_32 == false && g_supports_64 == false)
+ {
+#if defined (__x86_64__)
+
+ g_host_arch_64.SetArch ("x86_64");
+ g_supports_32 = false;
+ g_supports_64 = true;
+
+#elif defined (__i386__)
+
+ g_host_arch.SetArch ("i386");
+ g_supports_32 = true;
+ g_supports_64 = false;
+
+#elif defined (__arm__)
+
+ g_host_arch.SetArch ("arm");
+ g_supports_32 = true;
+ g_supports_64 = false;
+
+#elif defined (__ppc64__)
+
+ g_host_arch.SetArch ("ppc64");
+ g_supports_32 = false;
+ g_supports_64 = true;
+
+#elif defined (__powerpc__) || defined (__ppc__)
+ g_host_arch.SetArch ("ppc");
+ g_supports_32 = true;
+ g_supports_64 = false;
+
+#else
+
+#error undefined architecture, define your architecture here
+
#endif
}
- return g_host_arch;
+
+#endif // #else for #if defined (__APPLE__)
+
+ if (arch_kind == eSystemDefaultArchitecture32)
+ return g_host_arch_32;
+ else if (arch_kind == eSystemDefaultArchitecture64)
+ return g_host_arch_64;
+
+ if (g_supports_64)
+ return g_host_arch_64;
+
+ return g_host_arch_32;
}
const ConstString &
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index 2c69af6..4fb96ce 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -41,15 +41,12 @@
// Static Functions
//------------------------------------------------------------------
lldb_private::ABI *
-ABIMacOSX_i386::CreateInstance (const ConstString &triple)
+ABIMacOSX_i386::CreateInstance (const ArchSpec &arch)
{
- llvm::StringRef tripleStr(triple.GetCString());
- llvm::Triple llvmTriple(tripleStr);
-
- if (llvmTriple.getArch() != llvm::Triple::x86)
- return NULL;
-
- return new ABIMacOSX_i386;
+ if (arch.GetTriple().getArch() == llvm::Triple::x86)
+ return new ABIMacOSX_i386;
+
+ return NULL;
}
bool
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
index d451436..140b8af 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
@@ -63,7 +63,7 @@
Terminate();
static lldb_private::ABI *
- CreateInstance (const ConstString &triple);
+ CreateInstance (const ArchSpec &arch);
//------------------------------------------------------------------
// PluginInterface protocol
diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index 3dd0527..93537cf 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -42,15 +42,11 @@
// Static Functions
//------------------------------------------------------------------
lldb_private::ABI *
-ABISysV_x86_64::CreateInstance (const ConstString &triple)
+ABISysV_x86_64::CreateInstance (const ArchSpec &arch)
{
- llvm::StringRef tripleStr(triple.GetCString());
- llvm::Triple llvmTriple(tripleStr);
-
- if (llvmTriple.getArch() != llvm::Triple::x86_64)
- return NULL;
-
- return new ABISysV_x86_64;
+ if (arch.GetTriple().getArch() == llvm::Triple::x86_64)
+ return new ABISysV_x86_64;
+ return NULL;
}
bool
@@ -227,7 +223,9 @@
uint8_t arg_data[sizeof(arg_contents)];
Error error;
thread.GetProcess().ReadMemory(current_stack_argument, arg_data, sizeof(arg_contents), error);
- DataExtractor arg_data_extractor(arg_data, sizeof(arg_contents), thread.GetProcess().GetByteOrder(), thread.GetProcess().GetAddressByteSize());
+ DataExtractor arg_data_extractor (arg_data, sizeof(arg_contents),
+ thread.GetProcess().GetTarget().GetArchitecture().GetByteOrder(),
+ thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
uint32_t offset = 0;
arg_contents = arg_data_extractor.GetMaxU64(&offset, bit_width / 8);
if (!offset)
diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
index f4e58e4..fa2e924 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
@@ -62,7 +62,7 @@
Terminate();
static lldb_private::ABI *
- CreateInstance (const ConstString &triple);
+ CreateInstance (const ArchSpec &arch);
//------------------------------------------------------------------
// PluginInterface protocol
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index d650ee6..003ed9a 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -424,7 +424,7 @@
m_dyld_all_image_infos.Clear();
if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS)
{
- ByteOrder byte_order = m_process->GetByteOrder();
+ ByteOrder byte_order = m_process->GetTarget().GetArchitecture().GetByteOrder();
uint32_t addr_size = 4;
if (m_dyld_all_image_infos_addr > UINT32_MAX)
addr_size = 8;
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 7b58731..b604592 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include "EmulateInstructionARM.h"
+#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ConstString.h"
#include "Plugins/Process/Utility/ARMDefines.h"
@@ -3620,38 +3621,22 @@
}
bool
-EmulateInstructionARM::SetTargetTriple (const ConstString &triple)
+EmulateInstructionARM::SetArchitecture (const ArchSpec &arch)
{
m_arm_isa = 0;
- const char *triple_cstr = triple.GetCString();
- if (triple_cstr)
+ const char *arch_cstr = arch.AsCString ();
+ if (arch_cstr)
{
- const char *dash = ::strchr (triple_cstr, '-');
- if (dash)
- {
- std::string arch (triple_cstr, dash);
- const char *arch_cstr = arch.c_str();
- if (strcasecmp(arch_cstr, "armv4t") == 0)
- m_arm_isa = ARMv4T;
- else if (strcasecmp(arch_cstr, "armv4") == 0)
- m_arm_isa = ARMv4;
- else if (strcasecmp(arch_cstr, "armv5tej") == 0)
- m_arm_isa = ARMv5TEJ;
- else if (strcasecmp(arch_cstr, "armv5te") == 0)
- m_arm_isa = ARMv5TE;
- else if (strcasecmp(arch_cstr, "armv5t") == 0)
- m_arm_isa = ARMv5T;
- else if (strcasecmp(arch_cstr, "armv6k") == 0)
- m_arm_isa = ARMv6K;
- else if (strcasecmp(arch_cstr, "armv6") == 0)
- m_arm_isa = ARMv6;
- else if (strcasecmp(arch_cstr, "armv6t2") == 0)
- m_arm_isa = ARMv6T2;
- else if (strcasecmp(arch_cstr, "armv7") == 0)
- m_arm_isa = ARMv7;
- else if (strcasecmp(arch_cstr, "armv8") == 0)
- m_arm_isa = ARMv8;
- }
+ if (0 == ::strcasecmp(arch_cstr, "armv4t")) m_arm_isa = ARMv4T;
+ else if (0 == ::strcasecmp(arch_cstr, "armv4")) m_arm_isa = ARMv4;
+ else if (0 == ::strcasecmp(arch_cstr, "armv5tej")) m_arm_isa = ARMv5TEJ;
+ else if (0 == ::strcasecmp(arch_cstr, "armv5te")) m_arm_isa = ARMv5TE;
+ else if (0 == ::strcasecmp(arch_cstr, "armv5t")) m_arm_isa = ARMv5T;
+ else if (0 == ::strcasecmp(arch_cstr, "armv6k")) m_arm_isa = ARMv6K;
+ else if (0 == ::strcasecmp(arch_cstr, "armv6")) m_arm_isa = ARMv6;
+ else if (0 == ::strcasecmp(arch_cstr, "armv6t2")) m_arm_isa = ARMv6T2;
+ else if (0 == ::strcasecmp(arch_cstr, "armv7")) m_arm_isa = ARMv7;
+ else if (0 == ::strcasecmp(arch_cstr, "armv8")) m_arm_isa = ARMv8;
}
return m_arm_isa != 0;
}
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
index f029672..6a6105d 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
@@ -131,7 +131,7 @@
virtual bool
- SetTargetTriple (const ConstString &triple);
+ SetArchitecture (const ArchSpec &arch);
virtual bool
ReadInstruction ();
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index dff1e37..892b4bd 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -104,7 +104,6 @@
arg_value_list.PushValue(value);
// This is the return value:
- const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString();
ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
void *return_qualtype = ast_context->GetCStringType(true);
@@ -112,7 +111,12 @@
ret.SetContext(Value::eContextTypeClangType, return_qualtype);
// Now we're ready to call the function:
- ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list);
+ ClangFunction func (exe_ctx.GetBestExecutionContextScope(),
+ ast_context,
+ return_qualtype,
+ *function_address,
+ arg_value_list);
+
StreamString error_stream;
lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index 27e7211..93a9b8d 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -819,11 +819,11 @@
// Next make the runner function for our implementation utility function.
if (!m_impl_function.get())
{
- m_impl_function.reset(new ClangFunction(process->GetTargetTriple().GetCString(),
- clang_ast_context,
- clang_void_ptr_type,
- impl_code_address,
- dispatch_values));
+ m_impl_function.reset(new ClangFunction (&thread,
+ clang_ast_context,
+ clang_void_ptr_type,
+ impl_code_address,
+ dispatch_values));
errors.Clear();
unsigned num_errors = m_impl_function->CompileFunction(errors);
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index e02f49c..a16e486 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1043,40 +1043,28 @@
}
bool
-ObjectFileELF::GetTargetTriple(ConstString &target_triple)
+ObjectFileELF::GetArchitecture (ArchSpec &arch)
{
- static ConstString g_target_triple;
-
- if (g_target_triple)
- {
- target_triple = g_target_triple;
- return true;
- }
-
- std::string triple;
switch (m_header.e_machine)
{
default:
assert(false && "Unexpected machine type.");
break;
- case EM_SPARC: triple.assign("sparc-"); break;
- case EM_386: triple.assign("i386-"); break;
- case EM_68K: triple.assign("68k-"); break;
- case EM_88K: triple.assign("88k-"); break;
- case EM_860: triple.assign("i860-"); break;
- case EM_MIPS: triple.assign("mips-"); break;
- case EM_PPC: triple.assign("powerpc-"); break;
- case EM_PPC64: triple.assign("powerpc64-"); break;
- case EM_ARM: triple.assign("arm-"); break;
- case EM_X86_64: triple.assign("x86_64-"); 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
- triple += "linux-";
+ arch.GetTriple().setOSName ("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;
-
+ arch.GetTriple().setVendorName("gnu");
return true;
}
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
index ef13ca4..ad97165 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -105,7 +105,7 @@
Dump(lldb_private::Stream *s);
virtual bool
- GetTargetTriple(lldb_private::ConstString &target_triple);
+ GetArchitecture (lldb_private::ArchSpec &arch);
virtual bool
GetUUID(lldb_private::UUID* uuid);
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index bfd6eb8..ac536c5 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1436,15 +1436,11 @@
}
bool
-ObjectFileMachO::GetTargetTriple (ConstString &target_triple)
+ObjectFileMachO::GetArchitecture (ArchSpec &arch)
{
lldb_private::Mutex::Locker locker(m_mutex);
- std::string triple(GetModule()->GetArchitecture().AsCString());
- triple += "-apple-darwin";
- target_triple.SetCString(triple.c_str());
- if (target_triple)
- return true;
- return false;
+ arch.SetMachOArch(m_header.cputype, m_header.cpusubtype);
+ return true;
}
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index 46d628e..c20ff1e 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -83,7 +83,7 @@
Dump (lldb_private::Stream *s);
virtual bool
- GetTargetTriple (lldb_private::ConstString &target_triple);
+ GetArchitecture (lldb_private::ArchSpec &arch);
virtual bool
GetUUID (lldb_private::UUID* uuid);
diff --git a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index 26841dc..5318014 100644
--- a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -443,39 +443,10 @@
Module * exe_module = GetTarget().GetExecutableModule ().get();
assert (exe_module);
- m_arch_spec = exe_module->GetArchitecture();
- assert (m_arch_spec.IsValid());
-
- ObjectFile *exe_objfile = exe_module->GetObjectFile();
- assert (exe_objfile);
-
- m_byte_order = exe_objfile->GetByteOrder();
- assert (m_byte_order != eByteOrderInvalid);
// Install a signal handler so we can catch when our child process
// dies and set the exit status correctly.
m_monitor_thread = Host::StartMonitoringChildProcess (Process::SetProcessExitStatus, NULL, GetID(), false);
-
- if (m_arch_spec == ArchSpec("arm"))
- {
- // On ARM we want the actual target triple of the OS to get the
- // most capable ARM slice for the process. Since this plug-in is
- // only used for doing native debugging this will work.
- m_target_triple = Host::GetTargetTriple();
- }
- else
- {
- // We want the arch of the process, and the vendor and OS from the
- // host OS.
- StreamString triple;
-
- triple.Printf("%s-%s-%s",
- m_arch_spec.AsCString(),
- Host::GetVendorString().AsCString("apple"),
- Host::GetOSString().AsCString("darwin"));
-
- m_target_triple.SetCString(triple.GetString().c_str());
- }
}
}
@@ -883,12 +854,6 @@
return error;
}
-ByteOrder
-ProcessMacOSX::GetByteOrder () const
-{
- return m_byte_order;
-}
-
//------------------------------------------------------------------
// Process Queries
//------------------------------------------------------------------
diff --git a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
index c3df2f3..c0a80c5 100644
--- a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
+++ b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
@@ -222,9 +222,6 @@
virtual lldb_private::Error
DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc);
- virtual lldb::ByteOrder
- GetByteOrder () const;
-
virtual lldb_private::DynamicLoader *
GetDynamicLoader ();
diff --git a/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp b/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
index 7a91903..ac1623e 100644
--- a/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
@@ -107,7 +107,9 @@
uint8_t memory_buffer[8];
addr_t dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS;
- DataExtractor data(memory_buffer, sizeof(memory_buffer), m_process.GetByteOrder(), m_process.GetAddressByteSize());
+ DataExtractor data (memory_buffer, sizeof(memory_buffer),
+ m_process.GetTarget().GetArchitecture().GetByteOrder(),
+ m_process.GetTarget().GetArchitecture().GetAddressByteSize());
static ConstString g_dispatch_queue_offsets_symbol_name ("dispatch_queue_offsets");
const Symbol *dispatch_queue_offsets_symbol = NULL;
ModuleSP module_sp(m_process.GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libSystem.B.dylib", false)));
@@ -477,6 +479,8 @@
case eStateStepping:
Resume();
break;
+ default:
+ break;
}
m_context->ThreadWillResume();
}
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 9ebb143..1f14a6e 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -13,6 +13,7 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/Triple.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/ConnectionFileDescriptor.h"
#include "lldb/Core/Log.h"
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index cee2d3d..cba0ca1 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -638,7 +638,7 @@
BuildDynamicRegisterInfo (false);
- m_byte_order = m_gdb_comm.GetByteOrder();
+ m_target.GetArchitecture().SetByteOrder (m_gdb_comm.GetByteOrder());
StreamString strm;
@@ -656,33 +656,16 @@
// defacto architecture in this case.
if (gdb_remote_arch == ArchSpec ("arm") &&
- vendor != NULL &&
- strcmp(vendor, "apple") == 0)
+ vendor && ::strcmp(vendor, "apple") == 0)
{
GetTarget().SetArchitecture (gdb_remote_arch);
target_arch = gdb_remote_arch;
}
- if (!target_arch.IsValid())
- target_arch = gdb_remote_arch;
-
- if (target_arch.IsValid())
- {
- if (vendor == NULL)
- vendor = Host::GetVendorString().AsCString("apple");
-
- if (os_type == NULL)
- os_type = Host::GetOSString().AsCString("darwin");
-
- strm.Printf ("%s-%s-%s", target_arch.AsCString(), vendor, os_type);
-
- std::transform (strm.GetString().begin(),
- strm.GetString().end(),
- strm.GetString().begin(),
- ::tolower);
-
- m_target_triple.SetCString(strm.GetString().c_str());
- }
+ if (vendor)
+ m_target.GetArchitecture().GetTriple().setVendorName(vendor);
+ if (os_type)
+ m_target.GetArchitecture().GetTriple().setOSName(os_type);
}
}
@@ -2557,7 +2540,10 @@
}
uint8_t memory_buffer[8];
- DataExtractor data(memory_buffer, sizeof(memory_buffer), GetByteOrder(), GetAddressByteSize());
+ DataExtractor data (memory_buffer,
+ sizeof(memory_buffer),
+ m_target.GetArchitecture().GetByteOrder(),
+ m_target.GetArchitecture().GetAddressByteSize());
// Excerpt from src/queue_private.h
struct dispatch_queue_offsets_s
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 229045b..dcaedbe 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -54,6 +54,7 @@
#include <assert.h>
#endif
+#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/Log.h"
@@ -395,6 +396,13 @@
m_target_triple.assign(target_triple);
}
+void
+ClangASTContext::SetArchitecture (const ArchSpec &arch)
+{
+ Clear();
+ m_target_triple.assign(arch.GetTriple().str());
+}
+
bool
ClangASTContext::HasExternalSource ()
{
diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index b22ddbf..c0cd8ed 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -25,6 +25,7 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -355,7 +356,8 @@
if (address != LLDB_INVALID_ADDRESS)
{
DataExtractor data;
- data.SetByteOrder (exe_ctx->process->GetByteOrder());
+ if (exe_ctx->target)
+ data.SetByteOrder (exe_ctx->target->GetArchitecture().GetByteOrder());
if (ReadFromMemory (exe_ctx, address, address_type, data))
{
DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose);
diff --git a/source/Symbol/UnwindTable.cpp b/source/Symbol/UnwindTable.cpp
index 697098d..4b30980 100644
--- a/source/Symbol/UnwindTable.cpp
+++ b/source/Symbol/UnwindTable.cpp
@@ -58,12 +58,11 @@
}
ArchSpec arch;
- ConstString str;
- m_object_file.GetTargetTriple (str);
- arch.SetArchFromTargetTriple (str.GetCString());
- m_assembly_profiler = UnwindAssemblyProfiler::FindPlugin (arch);
-
- m_initialized = true;
+ if (m_object_file.GetArchitecture (arch))
+ {
+ m_assembly_profiler = UnwindAssemblyProfiler::FindPlugin (arch);
+ m_initialized = true;
+ }
}
UnwindTable::~UnwindTable ()
diff --git a/source/Target/ABI.cpp b/source/Target/ABI.cpp
index 20d35e3..21ac550 100644
--- a/source/Target/ABI.cpp
+++ b/source/Target/ABI.cpp
@@ -14,7 +14,7 @@
using namespace lldb_private;
ABI*
-ABI::FindPlugin (const ConstString &triple)
+ABI::FindPlugin (const ArchSpec &arch)
{
std::auto_ptr<ABI> abi_ap;
ABICreateInstance create_callback;
@@ -23,7 +23,7 @@
(create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) != NULL;
++idx)
{
- abi_ap.reset (create_callback(triple));
+ abi_ap.reset (create_callback(arch));
if (abi_ap.get())
return abi_ap.release();
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 9d58fb0..cf019e6 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -229,9 +229,6 @@
m_breakpoint_site_list (),
m_dynamic_checkers_ap (),
m_unix_signals (),
- m_target_triple (),
- m_byte_order (lldb::endian::InlHostByteOrder()),
- m_addr_byte_size (0),
m_abi_sp (),
m_process_input_reader (),
m_stdio_communication ("process.stdio"),
@@ -857,15 +854,8 @@
const ABI *
Process::GetABI()
{
- ConstString& triple = m_target_triple;
-
- if (triple.IsEmpty())
- return NULL;
-
if (m_abi_sp.get() == NULL)
- {
- m_abi_sp.reset(ABI::FindPlugin(triple));
- }
+ m_abi_sp.reset(ABI::FindPlugin(m_target.GetArchitecture()));
return m_abi_sp.get();
}
@@ -1317,7 +1307,10 @@
else
{
uint8_t tmp[sizeof(uint64_t)];
- DataExtractor data (tmp, integer_byte_size, GetByteOrder(), GetAddressByteSize());
+ DataExtractor data (tmp,
+ integer_byte_size,
+ m_target.GetArchitecture().GetByteOrder(),
+ m_target.GetArchitecture().GetAddressByteSize());
if (ReadMemory (vm_addr, tmp, integer_byte_size, error) == integer_byte_size)
{
uint32_t offset = 0;
@@ -1509,7 +1502,6 @@
)
{
Error error;
- m_target_triple.Clear();
m_abi_sp.reset();
m_process_input_reader.reset();
@@ -1666,7 +1658,6 @@
Process::Attach (lldb::pid_t attach_pid)
{
- m_target_triple.Clear();
m_abi_sp.reset();
m_process_input_reader.reset();
@@ -1710,7 +1701,6 @@
Error
Process::Attach (const char *process_name, bool wait_for_launch)
{
- m_target_triple.Clear();
m_abi_sp.reset();
m_process_input_reader.reset();
@@ -1756,7 +1746,6 @@
Error
Process::ConnectRemote (const char *remote_url)
{
- m_target_triple.Clear();
m_abi_sp.reset();
m_process_input_reader.reset();
@@ -1975,32 +1964,19 @@
return error;
}
-UnixSignals &
-Process::GetUnixSignals ()
+lldb::ByteOrder
+Process::GetByteOrder () const
{
- return m_unix_signals;
-}
-
-Target &
-Process::GetTarget ()
-{
- return m_target;
-}
-
-const Target &
-Process::GetTarget () const
-{
- return m_target;
+ return m_target.GetArchitecture().GetByteOrder();
}
uint32_t
-Process::GetAddressByteSize()
+Process::GetAddressByteSize () const
{
- if (m_addr_byte_size == 0)
- return m_target.GetArchitecture().GetAddressByteSize();
- return m_addr_byte_size;
+ return m_target.GetArchitecture().GetAddressByteSize();
}
+
bool
Process::ShouldBroadcastEvent (Event *event_ptr)
{
@@ -2111,22 +2087,6 @@
return return_value;
}
-//------------------------------------------------------------------
-// Thread Queries
-//------------------------------------------------------------------
-
-ThreadList &
-Process::GetThreadList ()
-{
- return m_thread_list;
-}
-
-const ThreadList &
-Process::GetThreadList () const
-{
- return m_thread_list;
-}
-
bool
Process::StartPrivateStateThread ()
@@ -2517,30 +2477,6 @@
return false;
}
-Target *
-Process::CalculateTarget ()
-{
- return &m_target;
-}
-
-Process *
-Process::CalculateProcess ()
-{
- return this;
-}
-
-Thread *
-Process::CalculateThread ()
-{
- return NULL;
-}
-
-StackFrame *
-Process::CalculateStackFrame ()
-{
- return NULL;
-}
-
void
Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 32917b7..7aec5b8 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -910,7 +910,7 @@
if (show_frame_index)
strm->Printf("frame #%u: ", m_frame_index);
- strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()));
+ strm->Printf("0x%0*llx ", m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()));
GetSymbolContext(eSymbolContextEverything);
const bool show_module = true;
const bool show_inline = true;
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 7a39958..b76f9f6 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -45,7 +45,6 @@
m_breakpoint_list (false),
m_internal_breakpoint_list (true),
m_process_sp(),
- m_triple(),
m_search_filter_sp(),
m_image_search_paths (ImageSearchPathsChanged, this),
m_scratch_ast_context_ap (NULL),
@@ -447,10 +446,9 @@
}
// Now see if we know the target triple, and if so, create our scratch AST context:
- ConstString target_triple;
- if (GetTargetTriple(target_triple))
+ if (m_arch_spec.IsValid())
{
- m_scratch_ast_context_ap.reset (new ClangASTContext(target_triple.GetCString()));
+ m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch_spec.GetTriple().str().c_str()));
}
}
@@ -458,18 +456,6 @@
}
-ModuleList&
-Target::GetImages ()
-{
- return m_images;
-}
-
-ArchSpec
-Target::GetArchitecture () const
-{
- return m_arch_spec;
-}
-
bool
Target::SetArchitecture (const ArchSpec &arch_spec)
{
@@ -492,7 +478,6 @@
ModuleSP executable_sp = GetExecutableModule ();
m_images.Clear();
m_scratch_ast_context_ap.reset();
- m_triple.Clear();
// Need to do something about unsetting breakpoints.
if (executable_sp)
@@ -524,31 +509,6 @@
}
}
-bool
-Target::GetTargetTriple(ConstString &triple)
-{
- triple.Clear();
-
- if (m_triple)
- {
- triple = m_triple;
- }
- else
- {
- Module *exe_module = GetExecutableModule().get();
- if (exe_module)
- {
- ObjectFile *objfile = exe_module->GetObjectFile();
- if (objfile)
- {
- objfile->GetTargetTriple(m_triple);
- triple = m_triple;
- }
- }
- }
- return !triple.IsEmpty();
-}
-
void
Target::ModuleAdded (ModuleSP &module_sp)
{
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index 2930d3d..28cd8b8 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -21,6 +21,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepThrough.h"
@@ -75,7 +76,8 @@
if (log)
{
StreamString s;
- s.Address (m_thread.GetRegisterContext()->GetPC(), m_thread.GetProcess().GetAddressByteSize());
+ s.Address (m_thread.GetRegisterContext()->GetPC(),
+ m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
log->Printf("ThreadPlanStepInRange reached %s.", s.GetData());
}
diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp
index 5d744c4..de23c22 100644
--- a/source/Target/ThreadPlanStepInstruction.cpp
+++ b/source/Target/ThreadPlanStepInstruction.cpp
@@ -123,10 +123,10 @@
StreamString s;
s.PutCString ("Stepped in to: ");
addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
- s.Address (stop_addr, m_thread.GetProcess().GetAddressByteSize());
+ s.Address (stop_addr, m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
s.PutCString (" stepping out to: ");
addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
- s.Address (return_addr, m_thread.GetProcess().GetAddressByteSize());
+ s.Address (return_addr, m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
log->Printf("%s.", s.GetData());
}
m_thread.QueueThreadPlanForStepOut(false, NULL, true, m_stop_other_threads, eVoteNo, eVoteNoOpinion, 0);
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index 2d6f030..c7bffb9 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepThrough.h"
@@ -69,7 +70,8 @@
if (log)
{
StreamString s;
- s.Address (m_thread.GetRegisterContext()->GetPC(), m_thread.GetProcess().GetAddressByteSize());
+ s.Address (m_thread.GetRegisterContext()->GetPC(),
+ m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData());
}