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
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 0739b97..445518d 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 @@
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 ac536c5..deac894 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1351,7 +1351,7 @@
ArchSpec header_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
- *s << ", file = '" << m_file << "', arch = " << header_arch.AsCString() << "\n";
+ *s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n";
if (m_sections_ap.get())
m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
@@ -1439,7 +1439,7 @@
ObjectFileMachO::GetArchitecture (ArchSpec &arch)
{
lldb_private::Mutex::Locker locker(m_mutex);
- arch.SetMachOArch(m_header.cputype, m_header.cpusubtype);
+ arch.SetArchitecture (lldb::eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
return true;
}