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/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