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.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@126278 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h
index 93f79dd..a479f47 100644
--- a/include/lldb/Core/ArchSpec.h
+++ b/include/lldb/Core/ArchSpec.h
@@ -13,37 +13,86 @@
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
namespace lldb_private {
+struct CoreDefinition;
+
//----------------------------------------------------------------------
/// @class ArchSpec ArchSpec.h "lldb/Core/ArchSpec.h"
/// @brief An architecture specification class.
///
-/// A class designed to be created from a cpu type and subtype, or a
-/// string representation. Keeping all of the conversions of strings
-/// to architecture enumeration values confined to this class allows
-/// new architecture support to be added easily.
+/// A class designed to be created from a cpu type and subtype, a
+/// string representation, or an llvm::Triple. Keeping all of the
+/// conversions of strings to architecture enumeration values confined
+/// to this class allows new architecture support to be added easily.
//----------------------------------------------------------------------
class ArchSpec
{
public:
- // Generic CPU types that each m_type needs to know how to convert
- // their m_cpu and m_sub to.
- enum CPU
+ enum Core
{
- eCPU_Unknown,
- eCPU_arm,
- eCPU_i386,
- eCPU_x86_64,
- eCPU_ppc,
- eCPU_ppc64,
- eCPU_sparc
+ eCore_alpha_generic,
+
+ eCore_arm_generic,
+ eCore_arm_armv4,
+ eCore_arm_armv4t,
+ eCore_arm_armv5,
+ eCore_arm_armv5t,
+ eCore_arm_armv6,
+ eCore_arm_armv7,
+ eCore_arm_xscale,
+
+ eCore_ppc_generic,
+ eCore_ppc_ppc601,
+ eCore_ppc_ppc602,
+ eCore_ppc_ppc603,
+ eCore_ppc_ppc603e,
+ eCore_ppc_ppc603ev,
+ eCore_ppc_ppc604,
+ eCore_ppc_ppc604e,
+ eCore_ppc_ppc620,
+ eCore_ppc_ppc750,
+ eCore_ppc_ppc7400,
+ eCore_ppc_ppc7450,
+ eCore_ppc_ppc970,
+
+ eCore_ppc64_generic,
+ eCore_ppc64_ppc970_64,
+
+ eCore_sparc_generic,
+
+ eCore_sparc9_generic,
+
+ eCore_x86_32_i386,
+ eCore_x86_32_i486,
+ eCore_x86_32_i486sx,
+
+ eCore_x86_64_x86_64,
+ kNumCores,
+
+ kCore_invalid,
+ // The following constants are used for wildcard matching only
+ kCore_any,
+
+ kCore_arm_any,
+ kCore_arm_first = eCore_arm_generic,
+ kCore_arm_last = eCore_arm_xscale,
+
+ kCore_ppc_any,
+ kCore_ppc_first = eCore_ppc_generic,
+ kCore_ppc_last = eCore_ppc_ppc970,
+
+ kCore_ppc64_any,
+ kCore_ppc64_first = eCore_ppc64_generic,
+ kCore_ppc64_last = eCore_ppc64_ppc970_64,
+
+ kCore_x86_32_any,
+ kCore_x86_32_first = eCore_x86_32_i386,
+ kCore_x86_32_last = eCore_x86_32_i486sx
};
-
- static void
- Initialize();
//------------------------------------------------------------------
/// Default constructor.
@@ -54,30 +103,22 @@
ArchSpec ();
//------------------------------------------------------------------
- /// Constructor with cpu type and subtype.
+ /// Constructor over triple.
///
- /// Constructor that initializes the object with supplied cpu and
- /// subtypes.
+ /// Constructs an ArchSpec with properties consistent with the given
+ /// Triple.
//------------------------------------------------------------------
- ArchSpec (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub);
-
+ ArchSpec (const llvm::Triple &triple);
+ ArchSpec (const char *triple_cstr);
//------------------------------------------------------------------
- /// Construct with architecture name.
+ /// Constructor over architecture name.
///
- /// Constructor that initializes the object with supplied
- /// architecture name. There are also predefined values in
- /// Defines.h:
- /// @li \c LLDB_ARCH_DEFAULT
- /// The arch the current system defaults to when a program is
- /// launched without any extra attributes or settings.
- ///
- /// @li \c LLDB_ARCH_DEFAULT_32BIT
- /// The 32 bit arch the current system defaults to (if any)
- ///
- /// @li \c LLDB_ARCH_DEFAULT_32BIT
- /// The 64 bit arch the current system defaults to (if any)
+ /// Constructs an ArchSpec with properties consistent with the given
+ /// object type and architecture name.
//------------------------------------------------------------------
- ArchSpec (const char *arch_name);
+ ArchSpec (lldb::ArchitectureType arch_type,
+ uint32_t cpu_type,
+ uint32_t cpu_subtype);
//------------------------------------------------------------------
/// Destructor.
@@ -92,40 +133,19 @@
///
/// @param[in] rhs another ArchSpec object to copy.
///
- /// @return a const reference to this object
+ /// @return A const reference to this object.
//------------------------------------------------------------------
const ArchSpec&
operator= (const ArchSpec& rhs);
//------------------------------------------------------------------
- /// Get a string representation of the contained architecture.
+ /// Returns a static string representing the current architecture.
///
- /// Gets a C string representation of the current architecture.
- /// If the returned string is a valid architecture name, the string
- /// came from a constant string values that do not need to be freed.
- /// If the returned string uses the "N.M" format, the string comes
- /// from a static buffer that should be copied.
- ///
- /// @return a NULL terminated C string that does not need to be
- /// freed.
+ /// @return A static string correcponding to the current
+ /// architecture.
//------------------------------------------------------------------
const char *
- AsCString () const;
-
- //------------------------------------------------------------------
- /// Returns a string representation of the supplied architecture.
- ///
- /// Class function to get a C string representation given a CPU type
- /// and subtype.
- ///
- /// @param[in] cpu The cpu type of the architecture.
- /// @param[in] subtype The cpu subtype of the architecture.
- ///
- /// @return a NULL terminated C string that does not need to be
- /// freed.
- //------------------------------------------------------------------
- static const char *
- AsCString (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t subtype);
+ GetArchitectureName () const;
//------------------------------------------------------------------
/// Clears the object state.
@@ -144,107 +164,33 @@
uint32_t
GetAddressByteSize () const;
- void
- SetAddressByteSize (uint32_t byte_size)
- {
- m_addr_byte_size = byte_size;
- }
-
- CPU
- GetGenericCPUType () const;
+ //------------------------------------------------------------------
+ /// Returns a machine family for the current architecture.
+ ///
+ /// @return An LLVM arch type.
+ //------------------------------------------------------------------
+ llvm::Triple::ArchType
+ GetMachine () const;
//------------------------------------------------------------------
- /// CPU subtype get accessor.
+ /// Tests if this ArchSpec is valid.
///
- /// @return The current value of the CPU subtype.
- //------------------------------------------------------------------
- uint32_t
- GetCPUSubtype () const;
-
- //------------------------------------------------------------------
- /// CPU type get accessor.
- ///
- /// @return The current value of the CPU type.
- //------------------------------------------------------------------
- uint32_t
- GetCPUType () const;
-
- //------------------------------------------------------------------
- /// Feature flags get accessor.
- ///
- /// @return The current value of the CPU feature flags.
- //------------------------------------------------------------------
- uint32_t
- GetFeatureFlags () const;
-
- //------------------------------------------------------------------
- /// Get register names of the current architecture.
- ///
- /// Get register names of the current architecture given
- /// a register number, and a flavor for that register number.
- /// There are many different register numbering schemes used
- /// on a host:
- /// @li \c eRegisterKindGCC - gcc compiler register numbering
- /// @li \c eRegisterKindDWARF - DWARF register numbering
- ///
- /// @param[in] reg_num The register number to decode.
- /// @param[in] flavor The flavor of the \a reg_num.
- ///
- /// @return the name of the register as a NULL terminated C string,
- /// or /c NULL if the \a reg_num is invalid for \a flavor.
- /// String values that are returned do not need to be freed.
- //------------------------------------------------------------------
- const char *
- GetRegisterName (uint32_t reg_num, uint32_t flavor) const;
-
- //------------------------------------------------------------------
- /// Get register names for a specified architecture.
- ///
- /// Get register names of the specified architecture given
- /// a register number, and a flavor for that register number.
- /// There are many different register numbering schemes used
- /// on a host:
- ///
- /// @li compiler register numbers (@see eRegisterKindGCC)
- /// @li DWARF register numbers (@see eRegisterKindDWARF)
- ///
- /// @param[in] cpu The cpu type of the architecture specific
- /// register
- /// @param[in] subtype The cpu subtype of the architecture specific
- /// register
- /// @param[in] reg_num The register number to decode.
- /// @param[in] flavor The flavor of the \a reg_num.
- ///
- /// @return the name of the register as a NULL terminated C string,
- /// or /c NULL if the \a reg_num is invalid for \a flavor.
- /// String values that are returned do not need to be freed.
- //------------------------------------------------------------------
- static const char *
- GetRegisterName (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t subtype, uint32_t reg_num, uint32_t flavor);
-
- //------------------------------------------------------------------
- /// Test if the contained architecture is valid.
- ///
- /// @return true if the current architecture is valid, false
+ /// @return True if the current architecture is valid, false
/// otherwise.
//------------------------------------------------------------------
bool
- IsValid () const;
+ IsValid () const
+ {
+ return m_core >= eCore_alpha_generic && m_core < kNumCores;
+ }
+
//------------------------------------------------------------------
- /// Get the memory cost of this object.
+ /// Sets this ArchSpec according to the given architecture name.
///
- /// @return
- /// The number of bytes that this object occupies in memory.
- //------------------------------------------------------------------
- size_t
- MemorySize() const;
-
- //------------------------------------------------------------------
- /// Change the CPU type and subtype given an architecture name.
+ /// The architecture name can be one of the generic system default
+ /// values:
///
- /// The architecture name supplied can also by one of the generic
- /// system default values:
/// @li \c LLDB_ARCH_DEFAULT - The arch the current system defaults
/// to when a program is launched without any extra
/// attributes or settings.
@@ -253,25 +199,43 @@
/// @li \c LLDB_ARCH_DEFAULT_64BIT - The default host architecture
/// for 64 bit (if any).
///
+ /// Alternatively, if the object type of this ArchSpec has been
+ /// configured, a concrete architecture can be specified to set
+ /// the CPU type ("x86_64" for example).
+ ///
+ /// Finally, an encoded object and archetecture format is accepted.
+ /// The format contains an object type (like "macho" or "elf"),
+ /// followed by a platform dependent encoding of CPU type and
+ /// subtype. For example:
+ ///
+ /// "macho" : Specifies an object type of MachO.
+ /// "macho-16-6" : MachO specific encoding for ARMv6.
+ /// "elf-43 : ELF specific encoding for Sparc V9.
+ ///
/// @param[in] arch_name The name of an architecture.
///
- /// @return true if \a arch_name was successfully transformed into
- /// a valid cpu type and subtype.
+ /// @return True if @p arch_name was successfully translated, false
+ /// otherwise.
//------------------------------------------------------------------
- bool
- SetArch (const char *arch_name);
-
- bool
- SetArchFromTargetTriple (const char *arch_name);
+// bool
+// SetArchitecture (const llvm::StringRef& arch_name);
+//
+// bool
+// SetArchitecture (const char *arch_name);
+
//------------------------------------------------------------------
- /// Change the CPU type and subtype given new values of the cpu
- /// type and subtype.
+ /// Change the architecture object type and CPU type.
///
- /// @param[in] cpu The new CPU type
- /// @param[in] subtype The new CPU subtype
+ /// @param[in] arch_type The object type of this ArchSpec.
+ ///
+ /// @param[in] cpu The required CPU type.
+ ///
+ /// @return True if the object and CPU type were sucessfully set.
//------------------------------------------------------------------
- void
- SetMachOArch (uint32_t cpu, uint32_t sub);
+ bool
+ SetArchitecture (lldb::ArchitectureType arch_type,
+ uint32_t cpu,
+ uint32_t sub);
//------------------------------------------------------------------
/// Returns the byte order for the architecture specification.
@@ -280,78 +244,88 @@
/// the architecture specification
//------------------------------------------------------------------
lldb::ByteOrder
- GetByteOrder () const
- {
- return m_byte_order;
- }
+ GetByteOrder () const;
+ //------------------------------------------------------------------
+ /// Sets this ArchSpec's byte order.
+ ///
+ /// In the common case there is no need to call this method as the
+ /// byte order can almost always be determined by the architecture.
+ /// However, many CPU's are bi-endian (ARM, Alpha, PowerPC, etc)
+ /// and the default/assumed byte order may be incorrect.
+ //------------------------------------------------------------------
void
- SetByteOrder (lldb::ByteOrder b)
+ SetByteOrder (lldb::ByteOrder byteorder);
+
+ Core
+ GetCore () const
{
- m_byte_order = b;
+ return m_core;
}
+ uint32_t
+ GetMachOCPUType () const;
+
+ uint32_t
+ GetMachOCPUSubType () const;
+
+ //------------------------------------------------------------------
+ /// Architecture tripple accessor.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
llvm::Triple &
GetTriple ()
{
return m_triple;
}
-
+
+ //------------------------------------------------------------------
+ /// Architecture tripple accessor.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
const llvm::Triple &
GetTriple () const
{
return m_triple;
}
+
+ //------------------------------------------------------------------
+ /// Architecture tripple setter.
+ ///
+ /// Configures this ArchSpec according to the given triple. At a
+ /// minimum, the given triple must describe a valid operating
+ /// system. If archetecture or environment components are present
+ /// they too will be used to further resolve the CPU type and
+ /// subtype, endian characteristics, etc.
+ ///
+ /// @return A triple describing this ArchSpec.
+ //------------------------------------------------------------------
+ bool
+ SetTriple (const llvm::Triple &triple);
+
+ bool
+ SetTriple (const char *triple_cstr);
- void
- SetTriple (const llvm::Triple &triple)
- {
- m_triple = triple;
- }
-
- void
- SetElfArch (uint32_t cpu, uint32_t sub)
- {
- m_type = lldb::eArchTypeELF;
- m_cpu = cpu;
- m_sub = sub;
- }
-
//------------------------------------------------------------------
/// Returns the default endianness of the architecture.
///
/// @return The endian enumeration for the default endianness of
- /// the architecture.
+ /// the architecture.
//------------------------------------------------------------------
lldb::ByteOrder
GetDefaultEndian () const;
-
- lldb::ArchitectureType
- GetType() const
- {
- return m_type;
- }
-
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::ArchitectureType m_type;
- // m_type => eArchTypeMachO eArchTypeELF
- uint32_t m_cpu; // cpu type ELF header e_machine
- uint32_t m_sub; // cpu subtype nothing
llvm::Triple m_triple;
+ Core m_core;
lldb::ByteOrder m_byte_order;
- uint32_t m_addr_byte_size;
-
-private:
-
+
+ // Called when m_def or m_entry are changed. Fills in all remaining
+ // members with default values.
void
- MachOArchUpdated (size_t macho_idx = ~(size_t)0);
-
- void
- ELFArchUpdated (size_t idx = ~(size_t)0);
+ CoreUpdated (bool update_triple);
};
diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h
index 400777c..1591f66 100644
--- a/include/lldb/Target/Target.h
+++ b/include/lldb/Target/Target.h
@@ -153,7 +153,7 @@
GetDefaultArchitecture ();
static void
- SetDefaultArchitecture (ArchSpec new_arch);
+ SetDefaultArchitecture (const ArchSpec &arch);
void
UpdateInstanceName ();
@@ -534,6 +534,11 @@
static SettingEntry global_settings_table[];
static SettingEntry instance_settings_table[];
+ ArchSpec &
+ GetArchitecture ()
+ {
+ return m_default_architecture;
+ }
protected:
lldb::InstanceSettingsSP
diff --git a/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme b/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
index 62ebd01..455e609 100644
--- a/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
+++ b/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
@@ -72,11 +72,11 @@
</EnvironmentVariables>
</TestAction>
<LaunchAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
displayScaleIsEnabled = "NO"
displayScale = "1.00"
- launchStyle = "1"
+ launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug">
<BuildableProductRunnable>
@@ -88,6 +88,20 @@
ReferencedContainer = "container:lldb.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
+ <CommandLineArguments>
+ <CommandLineArgument
+ argument = "/Volumes/work/gclayton/Documents/src/attach/a.out"
+ isEnabled = "YES">
+ </CommandLineArgument>
+ <CommandLineArgument
+ argument = "/Volumes/work/gclayton/Documents/src/lldb/test/abbreviation_tests/a.out"
+ isEnabled = "NO">
+ </CommandLineArgument>
+ <CommandLineArgument
+ argument = "/Volumes/work/gclayton/Documents/src/lldb/test/alias_tests/a.out"
+ isEnabled = "NO">
+ </CommandLineArgument>
+ </CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "LLDB_LAUNCH_FLAG_DISABLE_ASLR"
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index 430700d..2adf796 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -341,7 +341,7 @@
if (default_arch.IsValid())
{
- ::snprintf (arch_name, arch_name_len, "%s", default_arch.AsCString());
+ ::snprintf (arch_name, arch_name_len, "%s", default_arch.GetArchitectureName());
return true;
}
}
@@ -423,7 +423,7 @@
{
ArchSpec arch;
FileSpec file_spec (filename, true);
- arch.SetArchFromTargetTriple(target_triple);
+ arch.SetTriple (target_triple);
TargetSP target_sp;
Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file_spec, arch, NULL, true, target_sp));
target.reset (target_sp);
@@ -440,7 +440,7 @@
}
SBTarget
-SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *archname)
+SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *arch_cstr)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -448,31 +448,28 @@
if (m_opaque_sp)
{
FileSpec file (filename, true);
- ArchSpec arch = lldb_private::Target::GetDefaultArchitecture ();
+ ArchSpec arch;
TargetSP target_sp;
Error error;
- if (archname != NULL)
- {
- ArchSpec arch2 (archname);
- error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch2, NULL, true, target_sp);
- }
+ if (arch_cstr)
+ arch.SetTriple (arch_cstr);
else
+ arch = lldb_private::Target::GetDefaultArchitecture ();
+
+ if (!arch.IsValid())
+ arch.SetTriple (LLDB_ARCH_DEFAULT);
+
+ error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp);
+
+ if (error.Fail())
{
- if (!arch.IsValid())
- arch = LLDB_ARCH_DEFAULT;
+ if (strcmp (LLDB_ARCH_DEFAULT, LLDB_ARCH_DEFAULT_32BIT) == 0)
+ arch.SetTriple (LLDB_ARCH_DEFAULT_64BIT);
+ else
+ arch.SetTriple (LLDB_ARCH_DEFAULT_32BIT);
error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp);
-
- if (error.Fail())
- {
- if (arch == LLDB_ARCH_DEFAULT_32BIT)
- arch = LLDB_ARCH_DEFAULT_64BIT;
- else
- arch = LLDB_ARCH_DEFAULT_32BIT;
-
- error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp);
- }
}
if (error.Success())
@@ -485,7 +482,7 @@
if (log)
{
log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", arch=%s) => SBTarget(%p)",
- m_opaque_sp.get(), filename, archname, target.get());
+ m_opaque_sp.get(), filename, arch_cstr, target.get());
}
return target;
@@ -503,16 +500,16 @@
Error error;
if (!arch.IsValid())
- arch = LLDB_ARCH_DEFAULT;
+ arch.SetTriple (LLDB_ARCH_DEFAULT);
error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp);
if (error.Fail())
{
- if (arch == LLDB_ARCH_DEFAULT_32BIT)
- arch = LLDB_ARCH_DEFAULT_64BIT;
+ if (strcmp (LLDB_ARCH_DEFAULT, LLDB_ARCH_DEFAULT_32BIT) == 0)
+ arch.SetTriple (LLDB_ARCH_DEFAULT_64BIT);
else
- arch = LLDB_ARCH_DEFAULT_32BIT;
+ arch.SetTriple (LLDB_ARCH_DEFAULT_32BIT);
error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp);
}
@@ -563,9 +560,7 @@
if (m_opaque_sp && filename && filename[0])
{
// No need to lock, the target list is thread safe
- ArchSpec arch;
- if (arch_name)
- arch.SetArch(arch_name);
+ ArchSpec arch (arch_name);
TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename, false), arch_name ? &arch : NULL));
sb_target.reset(target_sp);
}
diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp
index 63d8937..f949030 100644
--- a/source/Commands/CommandObjectDisassemble.cpp
+++ b/source/Commands/CommandObjectDisassemble.cpp
@@ -185,7 +185,7 @@
if (disassembler == NULL)
{
- result.AppendErrorWithFormat ("Unable to find Disassembler plug-in for %s architecture.\n", arch.AsCString());
+ result.AppendErrorWithFormat ("Unable to find Disassembler plug-in for %s architecture.\n", arch.GetArchitectureName());
result.SetStatus (eReturnStatusFailed);
return false;
}
diff --git a/source/Commands/CommandObjectFile.cpp b/source/Commands/CommandObjectFile.cpp
index 45dc2a9..50f3394 100644
--- a/source/Commands/CommandObjectFile.cpp
+++ b/source/Commands/CommandObjectFile.cpp
@@ -145,7 +145,7 @@
if (target_sp)
{
debugger.GetTargetList().SetSelectedTarget(target_sp.get());
- result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, target_sp->GetArchitecture().AsCString());
+ result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, target_sp->GetArchitecture().GetArchitectureName());
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
diff --git a/source/Commands/CommandObjectImage.cpp b/source/Commands/CommandObjectImage.cpp
index 771562a..0092b39 100644
--- a/source/Commands/CommandObjectImage.cpp
+++ b/source/Commands/CommandObjectImage.cpp
@@ -42,9 +42,9 @@
if (module)
{
if (width)
- strm.Printf("%-*s", width, module->GetArchitecture().AsCString());
+ strm.Printf("%-*s", width, module->GetArchitecture().GetArchitectureName());
else
- strm.PutCString(module->GetArchitecture().AsCString());
+ strm.PutCString(module->GetArchitecture().GetArchitectureName());
}
}
@@ -183,7 +183,7 @@
{
strm.PutCString ("Sections for '");
strm << module->GetFileSpec();
- strm.Printf ("' (%s):\n", module->GetArchitecture().AsCString());
+ strm.Printf ("' (%s):\n", module->GetArchitecture().GetArchitectureName());
strm.IndentMore();
section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, true, UINT32_MAX);
strm.IndentLess();
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 22fd6c2..7e18e12 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -310,7 +310,7 @@
if (error.Success())
{
- const char *archname = exe_module->GetArchitecture().AsCString();
+ const char *archname = exe_module->GetArchitecture().GetArchitectureName();
result.AppendMessageWithFormat ("Process %i launched: '%s' (%s)\n", process->GetID(), filename, archname);
result.SetDidChangeProcessState (true);
@@ -328,7 +328,7 @@
if (synchronous_execution)
{
state = process->WaitForProcessToStop (NULL);
- if (!StateIsStoppedState(state));
+ if (!StateIsStoppedState(state))
{
result.AppendErrorWithFormat ("Process isn't stopped: %s", StateAsCString(state));
}
@@ -777,12 +777,12 @@
if (!old_arch_spec.IsValid())
{
- result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().AsCString());
+ result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetArchitectureName());
}
else if (old_arch_spec != target->GetArchitecture())
{
result.AppendWarningWithFormat("Architecture changed from %s to %s.\n",
- old_arch_spec.AsCString(), target->GetArchitecture().AsCString());
+ old_arch_spec.GetArchitectureName(), target->GetArchitecture().GetArchitectureName());
}
}
return result.Succeeded();
diff --git a/source/Core/ArchSpec.cpp b/source/Core/ArchSpec.cpp
index a17c0aa..a5493b3 100644
--- a/source/Core/ArchSpec.cpp
+++ b/source/Core/ArchSpec.cpp
@@ -21,1937 +21,597 @@
using namespace lldb;
using namespace lldb_private;
-#define ARCH_SPEC_SEPARATOR_CHAR '-'
+#define ARCH_SPEC_SEPARATOR_CHAR '-'
+namespace lldb_private {
-//----------------------------------------------------------------------
-// A structure that describes all of the information we want to know
-// about each architecture.
-//----------------------------------------------------------------------
-struct ArchDefinition
+ struct CoreDefinition
+ {
+ ByteOrder default_byte_order;
+ uint32_t addr_byte_size;
+ llvm::Triple::ArchType machine;
+ ArchSpec::Core core;
+ const char *name;
+ };
+
+}
+
+// This core information can be looked using the ArchSpec::Core as the index
+static const CoreDefinition g_core_definitions[ArchSpec::kNumCores] =
{
- ByteOrder byte_order;
- uint32_t addr_byte_size;
+ { eByteOrderLittle, 4, llvm::Triple::alpha , ArchSpec::eCore_alpha_generic , "alpha" },
+
+ { eByteOrderLittle, 4, llvm::Triple::arm , ArchSpec::eCore_arm_generic , "arm" },
+ { eByteOrderLittle, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv4 , "armv4" },
+ { eByteOrderLittle, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv4t , "armv4t" },
+ { eByteOrderLittle, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv5 , "armv5" },
+ { eByteOrderLittle, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv5t , "armv5t" },
+ { eByteOrderLittle, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv6 , "armv6" },
+ { eByteOrderLittle, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7 , "armv7" },
+ { eByteOrderLittle, 4, llvm::Triple::arm , ArchSpec::eCore_arm_xscale , "xscale" },
+
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_generic , "ppc" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc601 , "ppc601" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc602 , "ppc602" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc603 , "ppc603" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc603e , "ppc603e" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc603ev , "ppc603ev" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc604 , "ppc604" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc604e , "ppc604e" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc620 , "ppc620" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc750 , "ppc750" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc7400 , "ppc7400" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc7450 , "ppc7450" },
+ { eByteOrderLittle, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc970 , "ppc970" },
+
+ { eByteOrderLittle, 8, llvm::Triple::ppc64 , ArchSpec::eCore_ppc64_generic , "ppc64" },
+ { eByteOrderLittle, 8, llvm::Triple::ppc64 , ArchSpec::eCore_ppc64_ppc970_64 , "ppc970-64" },
+
+ { eByteOrderLittle, 4, llvm::Triple::sparc , ArchSpec::eCore_sparc_generic , "sparc" },
+ { eByteOrderLittle, 8, llvm::Triple::sparcv9, ArchSpec::eCore_sparc9_generic , "sparcv9" },
+
+ { eByteOrderLittle, 4, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i386 , "i386" },
+ { eByteOrderLittle, 4, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486 , "i486" },
+ { eByteOrderLittle, 4, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486sx , "i486sx" },
+
+ { eByteOrderLittle, 8, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64 , "x86_64" }
+};
+
+struct ArchDefinitionEntry
+{
+ ArchSpec::Core core;
uint32_t cpu;
uint32_t sub;
+};
+
+struct ArchDefinition
+{
+ ArchitectureType type;
+ size_t num_entries;
+ const ArchDefinitionEntry *entries;
+ uint32_t cpu_mask;
+ uint32_t sub_mask;
const char *name;
};
-static const char *g_arch_type_strings[] =
+#define CPU_ANY (UINT32_MAX)
+
+//===----------------------------------------------------------------------===//
+// A table that gets searched linearly for matches. This table is used to
+// convert cpu type and subtypes to architecture names, and to convert
+// architecture names to cpu types and subtypes. The ordering is important and
+// allows the precedence to be set when the table is built.
+static const ArchDefinitionEntry g_macho_arch_entries[] =
{
- "invalid",
- "mach-o",
- "elf"
+ { ArchSpec::eCore_arm_generic , llvm::MachO::CPUTypeARM , CPU_ANY },
+ { ArchSpec::eCore_arm_generic , llvm::MachO::CPUTypeARM , 0 },
+ { ArchSpec::eCore_arm_armv4 , llvm::MachO::CPUTypeARM , 5 },
+ { ArchSpec::eCore_arm_armv6 , llvm::MachO::CPUTypeARM , 6 },
+ { ArchSpec::eCore_arm_armv5 , llvm::MachO::CPUTypeARM , 7 },
+ { ArchSpec::eCore_arm_xscale , llvm::MachO::CPUTypeARM , 8 },
+ { ArchSpec::eCore_arm_armv7 , llvm::MachO::CPUTypeARM , 9 },
+ { ArchSpec::eCore_ppc_generic , llvm::MachO::CPUTypePowerPC , CPU_ANY },
+ { ArchSpec::eCore_ppc_generic , llvm::MachO::CPUTypePowerPC , 0 },
+ { ArchSpec::eCore_ppc_ppc601 , llvm::MachO::CPUTypePowerPC , 1 },
+ { ArchSpec::eCore_ppc_ppc602 , llvm::MachO::CPUTypePowerPC , 2 },
+ { ArchSpec::eCore_ppc_ppc603 , llvm::MachO::CPUTypePowerPC , 3 },
+ { ArchSpec::eCore_ppc_ppc603e , llvm::MachO::CPUTypePowerPC , 4 },
+ { ArchSpec::eCore_ppc_ppc603ev , llvm::MachO::CPUTypePowerPC , 5 },
+ { ArchSpec::eCore_ppc_ppc604 , llvm::MachO::CPUTypePowerPC , 6 },
+ { ArchSpec::eCore_ppc_ppc604e , llvm::MachO::CPUTypePowerPC , 7 },
+ { ArchSpec::eCore_ppc_ppc620 , llvm::MachO::CPUTypePowerPC , 8 },
+ { ArchSpec::eCore_ppc_ppc750 , llvm::MachO::CPUTypePowerPC , 9 },
+ { ArchSpec::eCore_ppc_ppc7400 , llvm::MachO::CPUTypePowerPC , 10 },
+ { ArchSpec::eCore_ppc_ppc7450 , llvm::MachO::CPUTypePowerPC , 11 },
+ { ArchSpec::eCore_ppc_ppc970 , llvm::MachO::CPUTypePowerPC , 100 },
+ { ArchSpec::eCore_ppc64_generic , llvm::MachO::CPUTypePowerPC64 , 0 },
+ { ArchSpec::eCore_ppc64_ppc970_64 , llvm::MachO::CPUTypePowerPC64 , 100 },
+ { ArchSpec::eCore_x86_32_i386 , llvm::MachO::CPUTypeI386 , 3 },
+ { ArchSpec::eCore_x86_32_i486 , llvm::MachO::CPUTypeI386 , 4 },
+ { ArchSpec::eCore_x86_32_i486sx , llvm::MachO::CPUTypeI386 , 0x84 },
+ { ArchSpec::eCore_x86_32_i386 , llvm::MachO::CPUTypeI386 , CPU_ANY },
+ { ArchSpec::eCore_x86_64_x86_64 , llvm::MachO::CPUTypeX86_64 , 3 },
+ { ArchSpec::eCore_x86_64_x86_64 , llvm::MachO::CPUTypeX86_64 , CPU_ANY }
+};
+static const ArchDefinition g_macho_arch_def = {
+ eArchTypeMachO,
+ sizeof(g_macho_arch_entries)/sizeof(g_macho_arch_entries[0]),
+ g_macho_arch_entries,
+ UINT32_MAX, // CPU type mask
+ 0x00FFFFFFu, // CPU subtype mask
+ "mach-o"
};
-#define CPU_ANY (UINT32_MAX)
-
-//----------------------------------------------------------------------
-// A table that gets searched linearly for matches. This table is used
-// to convert cpu type and subtypes to architecture names, and to
-// convert architecture names to cpu types and subtypes. The ordering
-// is important and allows the precedence to be set when the table is
-// built.
-//----------------------------------------------------------------------
-static ArchDefinition g_mach_arch_defs[] =
+//===----------------------------------------------------------------------===//
+// A table that gets searched linearly for matches. This table is used to
+// convert cpu type and subtypes to architecture names, and to convert
+// architecture names to cpu types and subtypes. The ordering is important and
+// allows the precedence to be set when the table is built.
+static const ArchDefinitionEntry g_elf_arch_entries[] =
{
- { 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" },
+ { ArchSpec::eCore_sparc_generic , llvm::ELF::EM_SPARC , LLDB_INVALID_CPUTYPE }, // Sparc
+ { ArchSpec::eCore_x86_32_i386 , llvm::ELF::EM_386 , LLDB_INVALID_CPUTYPE }, // Intel 80386
+ { ArchSpec::eCore_x86_32_i486 , llvm::ELF::EM_486 , LLDB_INVALID_CPUTYPE }, // Intel 486 (deprecated)
+ { ArchSpec::eCore_ppc_generic , llvm::ELF::EM_PPC , LLDB_INVALID_CPUTYPE }, // PowerPC
+ { ArchSpec::eCore_ppc64_generic , llvm::ELF::EM_PPC64 , LLDB_INVALID_CPUTYPE }, // PowerPC64
+ { ArchSpec::eCore_arm_generic , llvm::ELF::EM_ARM , LLDB_INVALID_CPUTYPE }, // ARM
+ { ArchSpec::eCore_alpha_generic , llvm::ELF::EM_ALPHA , LLDB_INVALID_CPUTYPE }, // DEC Alpha
+ { ArchSpec::eCore_sparc9_generic , llvm::ELF::EM_SPARCV9, LLDB_INVALID_CPUTYPE }, // SPARC V9
+ { ArchSpec::eCore_x86_64_x86_64 , llvm::ELF::EM_X86_64 , LLDB_INVALID_CPUTYPE }, // AMD64
};
-//----------------------------------------------------------------------
-// Figure out how many architecture definitions we have
-//----------------------------------------------------------------------
-const size_t k_num_mach_arch_defs = sizeof(g_mach_arch_defs)/sizeof(ArchDefinition);
-
-
-
-//----------------------------------------------------------------------
-// A table that gets searched linearly for matches. This table is used
-// to convert cpu type and subtypes to architecture names, and to
-// convert architecture names to cpu types and subtypes. The ordering
-// is important and allows the precedence to be set when the table is
-// built.
-//----------------------------------------------------------------------
-static ArchDefinition g_elf_arch_defs[] =
-{
- { 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
+static const ArchDefinition g_elf_arch_def = {
+ eArchTypeELF,
+ sizeof(g_elf_arch_entries)/sizeof(g_elf_arch_entries[0]),
+ g_elf_arch_entries,
+ UINT32_MAX, // CPU type mask
+ UINT32_MAX, // CPU subtype mask
+ "elf",
};
-//----------------------------------------------------------------------
-// Figure out how many architecture definitions we have
-//----------------------------------------------------------------------
-const size_t k_num_elf_arch_defs = sizeof(g_elf_arch_defs)/sizeof(ArchDefinition);
+//===----------------------------------------------------------------------===//
+// Table of all ArchDefinitions
+static const ArchDefinition *g_arch_definitions[] = {
+ &g_macho_arch_def,
+ &g_elf_arch_def,
+};
-//----------------------------------------------------------------------
-// Default constructor
-//----------------------------------------------------------------------
+static const size_t k_num_arch_definitions =
+ sizeof(g_arch_definitions) / sizeof(g_arch_definitions[0]);
+
+//===----------------------------------------------------------------------===//
+// Static helper functions.
+
+
+// Get the architecture definition for a given object type.
+static const ArchDefinition *
+FindArchDefinition (ArchitectureType arch_type)
+{
+ for (unsigned int i = 0; i < k_num_arch_definitions; ++i)
+ {
+ const ArchDefinition *def = g_arch_definitions[i];
+ if (def->type == arch_type)
+ return def;
+ }
+ return NULL;
+}
+
+// Get an architecture definition by name.
+static const CoreDefinition *
+FindCoreDefinition (llvm::StringRef name)
+{
+ for (unsigned int i = 0; i < ArchSpec::kNumCores; ++i)
+ {
+ if (name.equals_lower(g_core_definitions[i].name))
+ return &g_core_definitions[i];
+ }
+ return NULL;
+}
+
+static inline const CoreDefinition *
+FindCoreDefinition (ArchSpec::Core core)
+{
+ if (core >= 0 && core < ArchSpec::kNumCores)
+ return &g_core_definitions[core];
+ return NULL;
+}
+
+// Get a definition entry by cpu type and subtype.
+static const ArchDefinitionEntry *
+FindArchDefinitionEntry (const ArchDefinition *def, uint32_t cpu, uint32_t sub)
+{
+ if (def == NULL)
+ return NULL;
+
+ const uint32_t cpu_mask = def->cpu_mask;
+ const uint32_t sub_mask = def->sub_mask;
+ const ArchDefinitionEntry *entries = def->entries;
+ for (size_t i = 0; i < def->num_entries; ++i)
+ {
+ if ((entries[i].cpu == (cpu_mask & cpu)) &&
+ (entries[i].sub == (sub_mask & sub)))
+ return &entries[i];
+ }
+ return NULL;
+}
+
+static const ArchDefinitionEntry *
+FindArchDefinitionEntry (const ArchDefinition *def, ArchSpec::Core core)
+{
+ if (def == NULL)
+ return NULL;
+
+ const ArchDefinitionEntry *entries = def->entries;
+ for (size_t i = 0; i < def->num_entries; ++i)
+ {
+ if (entries[i].core == core)
+ return &entries[i];
+ }
+ return NULL;
+}
+
+//===----------------------------------------------------------------------===//
+// Constructors and destructors.
+
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_triple (),
- m_byte_order (lldb::endian::InlHostByteOrder()),
- m_addr_byte_size (0)
+ m_core (kCore_invalid),
+ m_byte_order (eByteOrderInvalid)
{
}
-//----------------------------------------------------------------------
-// Constructor that initializes the object with supplied cpu and
-// subtypes.
-//----------------------------------------------------------------------
-ArchSpec::ArchSpec (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub) :
- m_type (arch_type),
- m_cpu (cpu),
- m_sub (sub),
+ArchSpec::ArchSpec (const char *triple_cstr) :
m_triple (),
- m_byte_order (lldb::endian::InlHostByteOrder()),
- m_addr_byte_size (0)
+ m_core (kCore_invalid),
+ m_byte_order (eByteOrderInvalid)
{
- if (m_type == eArchTypeMachO)
- MachOArchUpdated ();
+ if (triple_cstr)
+ SetTriple(triple_cstr);
}
-//----------------------------------------------------------------------
-// Constructor that initializes the object with supplied
-// architecture name. There are also predefined values in
-// Defines.h:
-// LLDB_ARCH_DEFAULT
-// The arch the current system defaults to when a program is
-// launched without any extra attributes or settings.
-//
-// LLDB_ARCH_DEFAULT_32BIT
-// The 32 bit arch the current system defaults to (if any)
-//
-// 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),
+ArchSpec::ArchSpec(const llvm::Triple &triple) :
m_triple (),
- m_byte_order (lldb::endian::InlHostByteOrder()),
- m_addr_byte_size (0)
+ m_core (kCore_invalid),
+ m_byte_order (eByteOrderInvalid)
{
- SetArch (arch_name);
+ SetTriple(triple);
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
+ArchSpec::ArchSpec (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t subtype) :
+ m_triple (),
+ m_core (kCore_invalid),
+ m_byte_order (eByteOrderInvalid)
+{
+ SetArchitecture (arch_type, cpu, subtype);
+}
+
ArchSpec::~ArchSpec()
{
}
-//----------------------------------------------------------------------
-// Assignment operator
-//----------------------------------------------------------------------
+//===----------------------------------------------------------------------===//
+// Assignment and initialization.
+
const ArchSpec&
ArchSpec::operator= (const ArchSpec& rhs)
{
if (this != &rhs)
{
- m_type = rhs.m_type;
- m_cpu = rhs.m_cpu;
- m_sub = rhs.m_sub;
m_triple = rhs.m_triple;
+ m_core = rhs.m_core;
m_byte_order = rhs.m_byte_order;
- m_addr_byte_size = rhs.m_addr_byte_size;
}
return *this;
}
-//----------------------------------------------------------------------
-// Get a C string representation of the current architecture
-//----------------------------------------------------------------------
-const char *
-ArchSpec::AsCString() const
-{
- return ArchSpec::AsCString(m_type, m_cpu, m_sub);
-}
-
-//----------------------------------------------------------------------
-// Class function to get a C string representation given a CPU type
-// and subtype.
-//----------------------------------------------------------------------
-const char *
-ArchSpec::AsCString (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub)
-{
- if (arch_type >= kNumArchTypes)
- return NULL;
-
- switch (arch_type)
- {
- case kNumArchTypes:
- case eArchTypeInvalid:
- break;
-
- case eArchTypeMachO:
- for (uint32_t i=0; i<k_num_mach_arch_defs; i++)
- {
- if (cpu == g_mach_arch_defs[i].cpu)
- {
- if (sub == g_mach_arch_defs[i].sub)
- return g_mach_arch_defs[i].name;
- else if (sub != CPU_ANY && sub != LLDB_INVALID_CPUTYPE)
- {
- if ((sub & 0x00ffffff) == g_mach_arch_defs[i].sub)
- return g_mach_arch_defs[i].name;
- }
- }
- }
- break;
-
- case eArchTypeELF:
- for (uint32_t i=0; i<k_num_elf_arch_defs; i++)
- {
- if (cpu == g_elf_arch_defs[i].cpu)
- {
- if (sub == g_elf_arch_defs[i].sub)
- return g_elf_arch_defs[i].name;
- }
- }
- break;
- }
-
- const char *arch_type_cstr = g_arch_type_strings[arch_type];
-
- static char s_cpu_hex_str[128];
- ::snprintf(s_cpu_hex_str,
- sizeof(s_cpu_hex_str),
- "%s%c%u%c%u",
- arch_type_cstr,
- ARCH_SPEC_SEPARATOR_CHAR,
- cpu,
- ARCH_SPEC_SEPARATOR_CHAR,
- sub);
- return s_cpu_hex_str;
-}
-
-//----------------------------------------------------------------------
-// Clears the object contents back to a default invalid state.
-//----------------------------------------------------------------------
void
ArchSpec::Clear()
{
- 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;
+ m_core = kCore_invalid;
+ m_byte_order = eByteOrderInvalid;
}
+//===----------------------------------------------------------------------===//
+// Predicates.
-
-//----------------------------------------------------------------------
-// CPU subtype get accessor.
-//----------------------------------------------------------------------
-uint32_t
-ArchSpec::GetCPUSubtype() const
-{
- if (m_type == eArchTypeMachO)
- {
- if (m_sub == CPU_ANY || m_sub == LLDB_INVALID_CPUTYPE)
- return m_sub;
- return m_sub & 0xffffff;
- }
- return 0;
-}
-
-
-//----------------------------------------------------------------------
-// CPU type get accessor.
-//----------------------------------------------------------------------
-uint32_t
-ArchSpec::GetCPUType() const
-{
- return m_cpu;
-}
-
-//----------------------------------------------------------------------
-// This function is designed to abstract us from having to know any
-// details about the current m_type, m_cpu, and m_sub values and
-// translate the result into a generic CPU type so LLDB core code can
-// detect any CPUs that it supports.
-//----------------------------------------------------------------------
-ArchSpec::CPU
-ArchSpec::GetGenericCPUType () const
-{
- switch (m_type)
- {
- case kNumArchTypes:
- case eArchTypeInvalid:
- break;
-
- case eArchTypeMachO:
- switch (m_cpu)
- {
- case llvm::MachO::CPUTypeARM: return eCPU_arm;
- case llvm::MachO::CPUTypeI386: return eCPU_i386;
- case llvm::MachO::CPUTypeX86_64: return eCPU_x86_64;
- case llvm::MachO::CPUTypePowerPC: return eCPU_ppc;
- case llvm::MachO::CPUTypePowerPC64: return eCPU_ppc64;
- case llvm::MachO::CPUTypeSPARC: return eCPU_sparc;
- }
- break;
-
- case eArchTypeELF:
- switch (m_cpu)
- {
- case llvm::ELF::EM_ARM: return eCPU_arm;
- case llvm::ELF::EM_386: return eCPU_i386;
- case llvm::ELF::EM_X86_64: return eCPU_x86_64;
- case llvm::ELF::EM_PPC: return eCPU_ppc;
- case 21: return eCPU_ppc64;
- case llvm::ELF::EM_SPARC: return eCPU_sparc;
- }
- break;
- }
-
- return eCPU_Unknown;
-}
-
-
-
-
-//----------------------------------------------------------------------
-// Feature flags get accessor.
-//----------------------------------------------------------------------
-uint32_t
-ArchSpec::GetFeatureFlags() const
-{
- if (m_type == eArchTypeMachO)
- {
- if (m_sub == CPU_ANY || m_sub == LLDB_INVALID_CPUTYPE)
- return 0;
- return m_sub & 0xff000000;
- }
- return 0;
-}
-
-
-static const char * g_i386_dwarf_reg_names[] =
-{
- "eax",
- "ecx",
- "edx",
- "ebx",
- "esp",
- "ebp",
- "esi",
- "edi",
- "eip",
- "eflags"
-};
-
-static const char * g_i386_gcc_reg_names[] =
-{
- "eax",
- "ecx",
- "edx",
- "ebx",
- "ebp",
- "esp",
- "esi",
- "edi",
- "eip",
- "eflags"
-};
-
-static const char * g_x86_64_dwarf_and_gcc_reg_names[] = {
- "rax",
- "rdx",
- "rcx",
- "rbx",
- "rsi",
- "rdi",
- "rbp",
- "rsp",
- "r8",
- "r9",
- "r10",
- "r11",
- "r12",
- "r13",
- "r14",
- "r15",
- "rip"
-};
-
-// Values take from:
-// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040a/IHI0040A_aadwarf.pdf
-
-enum
-{
- eRegNumARM_DWARF_r0 = 0,
- eRegNumARM_DWARF_r1 = 1,
- eRegNumARM_DWARF_r2 = 2,
- eRegNumARM_DWARF_r3 = 3,
- eRegNumARM_DWARF_r4 = 4,
- eRegNumARM_DWARF_r5 = 5,
- eRegNumARM_DWARF_r6 = 6,
- eRegNumARM_DWARF_r7 = 7,
- eRegNumARM_DWARF_r8 = 8,
- eRegNumARM_DWARF_r9 = 9,
- eRegNumARM_DWARF_r10 = 10,
- eRegNumARM_DWARF_r11 = 11,
- eRegNumARM_DWARF_r12 = 12,
- eRegNumARM_DWARF_r13 = 13, // SP
- eRegNumARM_DWARF_r14 = 14, // LR
- eRegNumARM_DWARF_r15 = 15, // PC
-
- eRegNumARM_DWARF_f0_obsolete= 16,
- eRegNumARM_DWARF_f1_obsolete,
- eRegNumARM_DWARF_f2_obsolete,
- eRegNumARM_DWARF_f3_obsolete,
- eRegNumARM_DWARF_f4_obsolete,
- eRegNumARM_DWARF_f5_obsolete,
- eRegNumARM_DWARF_f6_obsolete,
- eRegNumARM_DWARF_f7_obsolete,
-
- eRegNumARM_DWARF_s0_obsolete = 16,
- eRegNumARM_DWARF_s1_obsolete,
- eRegNumARM_DWARF_s2_obsolete,
- eRegNumARM_DWARF_s3_obsolete,
- eRegNumARM_DWARF_s4_obsolete,
- eRegNumARM_DWARF_s5_obsolete,
- eRegNumARM_DWARF_s6_obsolete,
- eRegNumARM_DWARF_s7_obsolete,
- eRegNumARM_DWARF_s8_obsolete,
- eRegNumARM_DWARF_s9_obsolete,
- eRegNumARM_DWARF_s10_obsolete,
- eRegNumARM_DWARF_s11_obsolete,
- eRegNumARM_DWARF_s12_obsolete,
- eRegNumARM_DWARF_s13_obsolete,
- eRegNumARM_DWARF_s14_obsolete,
- eRegNumARM_DWARF_s15_obsolete,
- eRegNumARM_DWARF_s16_obsolete,
- eRegNumARM_DWARF_s17_obsolete,
- eRegNumARM_DWARF_s18_obsolete,
- eRegNumARM_DWARF_s19_obsolete,
- eRegNumARM_DWARF_s20_obsolete,
- eRegNumARM_DWARF_s21_obsolete,
- eRegNumARM_DWARF_s22_obsolete,
- eRegNumARM_DWARF_s23_obsolete,
- eRegNumARM_DWARF_s24_obsolete,
- eRegNumARM_DWARF_s25_obsolete,
- eRegNumARM_DWARF_s26_obsolete,
- eRegNumARM_DWARF_s27_obsolete,
- eRegNumARM_DWARF_s28_obsolete,
- eRegNumARM_DWARF_s29_obsolete,
- eRegNumARM_DWARF_s30_obsolete,
- eRegNumARM_DWARF_s31_obsolete,
-
- eRegNumARM_DWARF_s0 = 64,
- eRegNumARM_DWARF_s1,
- eRegNumARM_DWARF_s2,
- eRegNumARM_DWARF_s3,
- eRegNumARM_DWARF_s4,
- eRegNumARM_DWARF_s5,
- eRegNumARM_DWARF_s6,
- eRegNumARM_DWARF_s7,
- eRegNumARM_DWARF_s8,
- eRegNumARM_DWARF_s9,
- eRegNumARM_DWARF_s10,
- eRegNumARM_DWARF_s11,
- eRegNumARM_DWARF_s12,
- eRegNumARM_DWARF_s13,
- eRegNumARM_DWARF_s14,
- eRegNumARM_DWARF_s15,
- eRegNumARM_DWARF_s16,
- eRegNumARM_DWARF_s17,
- eRegNumARM_DWARF_s18,
- eRegNumARM_DWARF_s19,
- eRegNumARM_DWARF_s20,
- eRegNumARM_DWARF_s21,
- eRegNumARM_DWARF_s22,
- eRegNumARM_DWARF_s23,
- eRegNumARM_DWARF_s24,
- eRegNumARM_DWARF_s25,
- eRegNumARM_DWARF_s26,
- eRegNumARM_DWARF_s27,
- eRegNumARM_DWARF_s28,
- eRegNumARM_DWARF_s29,
- eRegNumARM_DWARF_s30,
- eRegNumARM_DWARF_s31,
-
- eRegNumARM_DWARF_f0 = 96,
- eRegNumARM_DWARF_f1,
- eRegNumARM_DWARF_f2,
- eRegNumARM_DWARF_f3,
- eRegNumARM_DWARF_f4,
- eRegNumARM_DWARF_f5,
- eRegNumARM_DWARF_f6,
- eRegNumARM_DWARF_f7,
-
- eRegNumARM_DWARF_ACC0 = 104,
- eRegNumARM_DWARF_ACC1,
- eRegNumARM_DWARF_ACC2,
- eRegNumARM_DWARF_ACC3,
- eRegNumARM_DWARF_ACC4,
- eRegNumARM_DWARF_ACC5,
- eRegNumARM_DWARF_ACC6,
- eRegNumARM_DWARF_ACC7,
-
- eRegNumARM_DWARF_wCGR0 = 104, // These overlap with ACC0-ACC7
- eRegNumARM_DWARF_wCGR1,
- eRegNumARM_DWARF_wCGR2,
- eRegNumARM_DWARF_wCGR3,
- eRegNumARM_DWARF_wCGR4,
- eRegNumARM_DWARF_wCGR5,
- eRegNumARM_DWARF_wCGR6,
- eRegNumARM_DWARF_wCGR7,
-
- eRegNumARM_DWARF_wR0 = 112,
- eRegNumARM_DWARF_wR1,
- eRegNumARM_DWARF_wR2,
- eRegNumARM_DWARF_wR3,
- eRegNumARM_DWARF_wR4,
- eRegNumARM_DWARF_wR5,
- eRegNumARM_DWARF_wR6,
- eRegNumARM_DWARF_wR7,
- eRegNumARM_DWARF_wR8,
- eRegNumARM_DWARF_wR9,
- eRegNumARM_DWARF_wR10,
- eRegNumARM_DWARF_wR11,
- eRegNumARM_DWARF_wR12,
- eRegNumARM_DWARF_wR13,
- eRegNumARM_DWARF_wR14,
- eRegNumARM_DWARF_wR15,
-
- eRegNumARM_DWARF_spsr = 128,
- eRegNumARM_DWARF_spsr_fiq,
- eRegNumARM_DWARF_spsr_irq,
- eRegNumARM_DWARF_spsr_abt,
- eRegNumARM_DWARF_spsr_und,
- eRegNumARM_DWARF_spsr_svc,
-
- eRegNumARM_DWARF_r8_usr = 144,
- eRegNumARM_DWARF_r9_usr,
- eRegNumARM_DWARF_r10_usr,
- eRegNumARM_DWARF_r11_usr,
- eRegNumARM_DWARF_r12_usr,
- eRegNumARM_DWARF_r13_usr,
- eRegNumARM_DWARF_r14_usr,
-
- eRegNumARM_DWARF_r8_fiq = 151,
- eRegNumARM_DWARF_r9_fiq,
- eRegNumARM_DWARF_r10_fiq,
- eRegNumARM_DWARF_r11_fiq,
- eRegNumARM_DWARF_r12_fiq,
- eRegNumARM_DWARF_r13_fiq,
- eRegNumARM_DWARF_r14_fiq,
-
- eRegNumARM_DWARF_r13_irq,
- eRegNumARM_DWARF_r14_irq,
-
- eRegNumARM_DWARF_r13_abt,
- eRegNumARM_DWARF_r14_abt,
-
- eRegNumARM_DWARF_r13_und,
- eRegNumARM_DWARF_r14_und,
-
- eRegNumARM_DWARF_r13_svc,
- eRegNumARM_DWARF_r14_svc,
-
- eRegNumARM_DWARF_wC0 = 192,
- eRegNumARM_DWARF_wC1,
- eRegNumARM_DWARF_wC2,
- eRegNumARM_DWARF_wC3,
- eRegNumARM_DWARF_wC4,
- eRegNumARM_DWARF_wC5,
- eRegNumARM_DWARF_wC6,
- eRegNumARM_DWARF_wC7,
-
- eRegNumARM_DWARF_d0 = 256, // VFP-v3/NEON D0-D31 (32 64 bit registers)
- eRegNumARM_DWARF_d1,
- eRegNumARM_DWARF_d2,
- eRegNumARM_DWARF_d3,
- eRegNumARM_DWARF_d4,
- eRegNumARM_DWARF_d5,
- eRegNumARM_DWARF_d6,
- eRegNumARM_DWARF_d7,
- eRegNumARM_DWARF_d8,
- eRegNumARM_DWARF_d9,
- eRegNumARM_DWARF_d10,
- eRegNumARM_DWARF_d11,
- eRegNumARM_DWARF_d12,
- eRegNumARM_DWARF_d13,
- eRegNumARM_DWARF_d14,
- eRegNumARM_DWARF_d15,
- eRegNumARM_DWARF_d16,
- eRegNumARM_DWARF_d17,
- eRegNumARM_DWARF_d18,
- eRegNumARM_DWARF_d19,
- eRegNumARM_DWARF_d20,
- eRegNumARM_DWARF_d21,
- eRegNumARM_DWARF_d22,
- eRegNumARM_DWARF_d23,
- eRegNumARM_DWARF_d24,
- eRegNumARM_DWARF_d25,
- eRegNumARM_DWARF_d26,
- eRegNumARM_DWARF_d27,
- eRegNumARM_DWARF_d28,
- eRegNumARM_DWARF_d29,
- eRegNumARM_DWARF_d30,
- eRegNumARM_DWARF_d31
-};
-
-// Register numbering definitions for 32 and 64 bit ppc for RegisterNumberingType::Dwarf
-enum
-{
- eRegNumPPC_DWARF_r0 = 0,
- eRegNumPPC_DWARF_r1 = 1,
- eRegNumPPC_DWARF_r2 = 2,
- eRegNumPPC_DWARF_r3 = 3,
- eRegNumPPC_DWARF_r4 = 4,
- eRegNumPPC_DWARF_r5 = 5,
- eRegNumPPC_DWARF_r6 = 6,
- eRegNumPPC_DWARF_r7 = 7,
- eRegNumPPC_DWARF_r8 = 8,
- eRegNumPPC_DWARF_r9 = 9,
- eRegNumPPC_DWARF_r10 = 10,
- eRegNumPPC_DWARF_r11 = 11,
- eRegNumPPC_DWARF_r12 = 12,
- eRegNumPPC_DWARF_r13 = 13,
- eRegNumPPC_DWARF_r14 = 14,
- eRegNumPPC_DWARF_r15 = 15,
- eRegNumPPC_DWARF_r16 = 16,
- eRegNumPPC_DWARF_r17 = 17,
- eRegNumPPC_DWARF_r18 = 18,
- eRegNumPPC_DWARF_r19 = 19,
- eRegNumPPC_DWARF_r20 = 20,
- eRegNumPPC_DWARF_r21 = 21,
- eRegNumPPC_DWARF_r22 = 22,
- eRegNumPPC_DWARF_r23 = 23,
- eRegNumPPC_DWARF_r24 = 24,
- eRegNumPPC_DWARF_r25 = 25,
- eRegNumPPC_DWARF_r26 = 26,
- eRegNumPPC_DWARF_r27 = 27,
- eRegNumPPC_DWARF_r28 = 28,
- eRegNumPPC_DWARF_r29 = 29,
- eRegNumPPC_DWARF_r30 = 30,
- eRegNumPPC_DWARF_r31 = 31,
-
- eRegNumPPC_DWARF_fr0 = 32,
- eRegNumPPC_DWARF_fr1 = 33,
- eRegNumPPC_DWARF_fr2 = 34,
- eRegNumPPC_DWARF_fr3 = 35,
- eRegNumPPC_DWARF_fr4 = 36,
- eRegNumPPC_DWARF_fr5 = 37,
- eRegNumPPC_DWARF_fr6 = 38,
- eRegNumPPC_DWARF_fr7 = 39,
- eRegNumPPC_DWARF_fr8 = 40,
- eRegNumPPC_DWARF_fr9 = 41,
- eRegNumPPC_DWARF_fr10 = 42,
- eRegNumPPC_DWARF_fr11 = 43,
- eRegNumPPC_DWARF_fr12 = 44,
- eRegNumPPC_DWARF_fr13 = 45,
- eRegNumPPC_DWARF_fr14 = 46,
- eRegNumPPC_DWARF_fr15 = 47,
- eRegNumPPC_DWARF_fr16 = 48,
- eRegNumPPC_DWARF_fr17 = 49,
- eRegNumPPC_DWARF_fr18 = 50,
- eRegNumPPC_DWARF_fr19 = 51,
- eRegNumPPC_DWARF_fr20 = 52,
- eRegNumPPC_DWARF_fr21 = 53,
- eRegNumPPC_DWARF_fr22 = 54,
- eRegNumPPC_DWARF_fr23 = 55,
- eRegNumPPC_DWARF_fr24 = 56,
- eRegNumPPC_DWARF_fr25 = 57,
- eRegNumPPC_DWARF_fr26 = 58,
- eRegNumPPC_DWARF_fr27 = 59,
- eRegNumPPC_DWARF_fr28 = 60,
- eRegNumPPC_DWARF_fr29 = 61,
- eRegNumPPC_DWARF_fr30 = 62,
- eRegNumPPC_DWARF_fr31 = 63,
-
- eRegNumPPC_DWARF_cr = 64,
- eRegNumPPC_DWARF_fpscr = 65,
- eRegNumPPC_DWARF_msr = 66,
- eRegNumPPC_DWARF_vscr = 67,
-
- eRegNumPPC_DWARF_sr0 = 70,
- eRegNumPPC_DWARF_sr1,
- eRegNumPPC_DWARF_sr2,
- eRegNumPPC_DWARF_sr3,
- eRegNumPPC_DWARF_sr4,
- eRegNumPPC_DWARF_sr5,
- eRegNumPPC_DWARF_sr6,
- eRegNumPPC_DWARF_sr7,
- eRegNumPPC_DWARF_sr8,
- eRegNumPPC_DWARF_sr9,
- eRegNumPPC_DWARF_sr10,
- eRegNumPPC_DWARF_sr11,
- eRegNumPPC_DWARF_sr12,
- eRegNumPPC_DWARF_sr13,
- eRegNumPPC_DWARF_sr14,
- eRegNumPPC_DWARF_sr15,
-
-
- eRegNumPPC_DWARF_acc = 99,
- eRegNumPPC_DWARF_mq = 100,
- eRegNumPPC_DWARF_xer = 101,
- eRegNumPPC_DWARF_rtcu = 104,
- eRegNumPPC_DWARF_rtcl = 105,
-
- eRegNumPPC_DWARF_lr = 108,
- eRegNumPPC_DWARF_ctr = 109,
-
- eRegNumPPC_DWARF_dsisr = 118,
- eRegNumPPC_DWARF_dar = 119,
- eRegNumPPC_DWARF_dec = 122,
- eRegNumPPC_DWARF_sdr1 = 125,
- eRegNumPPC_DWARF_srr0 = 126,
- eRegNumPPC_DWARF_srr1 = 127,
-
- eRegNumPPC_DWARF_vrsave = 356,
- eRegNumPPC_DWARF_sprg0 = 372,
- eRegNumPPC_DWARF_sprg1,
- eRegNumPPC_DWARF_sprg2,
- eRegNumPPC_DWARF_sprg3,
-
- eRegNumPPC_DWARF_asr = 380,
- eRegNumPPC_DWARF_ear = 382,
- eRegNumPPC_DWARF_tb = 384,
- eRegNumPPC_DWARF_tbu = 385,
- eRegNumPPC_DWARF_pvr = 387,
-
- eRegNumPPC_DWARF_spefscr = 612,
-
- eRegNumPPC_DWARF_ibat0u = 628,
- eRegNumPPC_DWARF_ibat0l = 629,
- eRegNumPPC_DWARF_ibat1u = 630,
- eRegNumPPC_DWARF_ibat1l = 631,
- eRegNumPPC_DWARF_ibat2u = 632,
- eRegNumPPC_DWARF_ibat2l = 633,
- eRegNumPPC_DWARF_ibat3u = 634,
- eRegNumPPC_DWARF_ibat3l = 635,
- eRegNumPPC_DWARF_dbat0u = 636,
- eRegNumPPC_DWARF_dbat0l = 637,
- eRegNumPPC_DWARF_dbat1u = 638,
- eRegNumPPC_DWARF_dbat1l = 639,
- eRegNumPPC_DWARF_dbat2u = 640,
- eRegNumPPC_DWARF_dbat2l = 641,
- eRegNumPPC_DWARF_dbat3u = 642,
- eRegNumPPC_DWARF_dbat3l = 643,
-
- eRegNumPPC_DWARF_hid0 = 1108,
- eRegNumPPC_DWARF_hid1,
- eRegNumPPC_DWARF_hid2,
- eRegNumPPC_DWARF_hid3,
- eRegNumPPC_DWARF_hid4,
- eRegNumPPC_DWARF_hid5,
- eRegNumPPC_DWARF_hid6,
- eRegNumPPC_DWARF_hid7,
- eRegNumPPC_DWARF_hid8,
- eRegNumPPC_DWARF_hid9,
- eRegNumPPC_DWARF_hid10,
- eRegNumPPC_DWARF_hid11,
- eRegNumPPC_DWARF_hid12,
- eRegNumPPC_DWARF_hid13,
- eRegNumPPC_DWARF_hid14,
- eRegNumPPC_DWARF_hid15,
-
- eRegNumPPC_DWARF_vr0 = 1124,
- eRegNumPPC_DWARF_vr1,
- eRegNumPPC_DWARF_vr2,
- eRegNumPPC_DWARF_vr3,
- eRegNumPPC_DWARF_vr4,
- eRegNumPPC_DWARF_vr5,
- eRegNumPPC_DWARF_vr6,
- eRegNumPPC_DWARF_vr7,
- eRegNumPPC_DWARF_vr8,
- eRegNumPPC_DWARF_vr9,
- eRegNumPPC_DWARF_vr10,
- eRegNumPPC_DWARF_vr11,
- eRegNumPPC_DWARF_vr12,
- eRegNumPPC_DWARF_vr13,
- eRegNumPPC_DWARF_vr14,
- eRegNumPPC_DWARF_vr15,
- eRegNumPPC_DWARF_vr16,
- eRegNumPPC_DWARF_vr17,
- eRegNumPPC_DWARF_vr18,
- eRegNumPPC_DWARF_vr19,
- eRegNumPPC_DWARF_vr20,
- eRegNumPPC_DWARF_vr21,
- eRegNumPPC_DWARF_vr22,
- eRegNumPPC_DWARF_vr23,
- eRegNumPPC_DWARF_vr24,
- eRegNumPPC_DWARF_vr25,
- eRegNumPPC_DWARF_vr26,
- eRegNumPPC_DWARF_vr27,
- eRegNumPPC_DWARF_vr28,
- eRegNumPPC_DWARF_vr29,
- eRegNumPPC_DWARF_vr30,
- eRegNumPPC_DWARF_vr31,
-
- eRegNumPPC_DWARF_ev0 = 1200,
- eRegNumPPC_DWARF_ev1,
- eRegNumPPC_DWARF_ev2,
- eRegNumPPC_DWARF_ev3,
- eRegNumPPC_DWARF_ev4,
- eRegNumPPC_DWARF_ev5,
- eRegNumPPC_DWARF_ev6,
- eRegNumPPC_DWARF_ev7,
- eRegNumPPC_DWARF_ev8,
- eRegNumPPC_DWARF_ev9,
- eRegNumPPC_DWARF_ev10,
- eRegNumPPC_DWARF_ev11,
- eRegNumPPC_DWARF_ev12,
- eRegNumPPC_DWARF_ev13,
- eRegNumPPC_DWARF_ev14,
- eRegNumPPC_DWARF_ev15,
- eRegNumPPC_DWARF_ev16,
- eRegNumPPC_DWARF_ev17,
- eRegNumPPC_DWARF_ev18,
- eRegNumPPC_DWARF_ev19,
- eRegNumPPC_DWARF_ev20,
- eRegNumPPC_DWARF_ev21,
- eRegNumPPC_DWARF_ev22,
- eRegNumPPC_DWARF_ev23,
- eRegNumPPC_DWARF_ev24,
- eRegNumPPC_DWARF_ev25,
- eRegNumPPC_DWARF_ev26,
- eRegNumPPC_DWARF_ev27,
- eRegNumPPC_DWARF_ev28,
- eRegNumPPC_DWARF_ev29,
- eRegNumPPC_DWARF_ev30,
- eRegNumPPC_DWARF_ev31
-};
-
-// Register numbering definitions for 32 and 64 bit ppc for RegisterNumberingType::GCC
-enum
-{
- eRegNumPPC_GCC_r0 = 0,
- eRegNumPPC_GCC_r1 = 1,
- eRegNumPPC_GCC_r2 = 2,
- eRegNumPPC_GCC_r3 = 3,
- eRegNumPPC_GCC_r4 = 4,
- eRegNumPPC_GCC_r5 = 5,
- eRegNumPPC_GCC_r6 = 6,
- eRegNumPPC_GCC_r7 = 7,
- eRegNumPPC_GCC_r8 = 8,
- eRegNumPPC_GCC_r9 = 9,
- eRegNumPPC_GCC_r10 = 10,
- eRegNumPPC_GCC_r11 = 11,
- eRegNumPPC_GCC_r12 = 12,
- eRegNumPPC_GCC_r13 = 13,
- eRegNumPPC_GCC_r14 = 14,
- eRegNumPPC_GCC_r15 = 15,
- eRegNumPPC_GCC_r16 = 16,
- eRegNumPPC_GCC_r17 = 17,
- eRegNumPPC_GCC_r18 = 18,
- eRegNumPPC_GCC_r19 = 19,
- eRegNumPPC_GCC_r20 = 20,
- eRegNumPPC_GCC_r21 = 21,
- eRegNumPPC_GCC_r22 = 22,
- eRegNumPPC_GCC_r23 = 23,
- eRegNumPPC_GCC_r24 = 24,
- eRegNumPPC_GCC_r25 = 25,
- eRegNumPPC_GCC_r26 = 26,
- eRegNumPPC_GCC_r27 = 27,
- eRegNumPPC_GCC_r28 = 28,
- eRegNumPPC_GCC_r29 = 29,
- eRegNumPPC_GCC_r30 = 30,
- eRegNumPPC_GCC_r31 = 31,
- eRegNumPPC_GCC_fr0 = 32,
- eRegNumPPC_GCC_fr1 = 33,
- eRegNumPPC_GCC_fr2 = 34,
- eRegNumPPC_GCC_fr3 = 35,
- eRegNumPPC_GCC_fr4 = 36,
- eRegNumPPC_GCC_fr5 = 37,
- eRegNumPPC_GCC_fr6 = 38,
- eRegNumPPC_GCC_fr7 = 39,
- eRegNumPPC_GCC_fr8 = 40,
- eRegNumPPC_GCC_fr9 = 41,
- eRegNumPPC_GCC_fr10 = 42,
- eRegNumPPC_GCC_fr11 = 43,
- eRegNumPPC_GCC_fr12 = 44,
- eRegNumPPC_GCC_fr13 = 45,
- eRegNumPPC_GCC_fr14 = 46,
- eRegNumPPC_GCC_fr15 = 47,
- eRegNumPPC_GCC_fr16 = 48,
- eRegNumPPC_GCC_fr17 = 49,
- eRegNumPPC_GCC_fr18 = 50,
- eRegNumPPC_GCC_fr19 = 51,
- eRegNumPPC_GCC_fr20 = 52,
- eRegNumPPC_GCC_fr21 = 53,
- eRegNumPPC_GCC_fr22 = 54,
- eRegNumPPC_GCC_fr23 = 55,
- eRegNumPPC_GCC_fr24 = 56,
- eRegNumPPC_GCC_fr25 = 57,
- eRegNumPPC_GCC_fr26 = 58,
- eRegNumPPC_GCC_fr27 = 59,
- eRegNumPPC_GCC_fr28 = 60,
- eRegNumPPC_GCC_fr29 = 61,
- eRegNumPPC_GCC_fr30 = 62,
- eRegNumPPC_GCC_fr31 = 63,
- eRegNumPPC_GCC_mq = 64,
- eRegNumPPC_GCC_lr = 65,
- eRegNumPPC_GCC_ctr = 66,
- eRegNumPPC_GCC_ap = 67,
- eRegNumPPC_GCC_cr0 = 68,
- eRegNumPPC_GCC_cr1 = 69,
- eRegNumPPC_GCC_cr2 = 70,
- eRegNumPPC_GCC_cr3 = 71,
- eRegNumPPC_GCC_cr4 = 72,
- eRegNumPPC_GCC_cr5 = 73,
- eRegNumPPC_GCC_cr6 = 74,
- eRegNumPPC_GCC_cr7 = 75,
- eRegNumPPC_GCC_xer = 76,
- eRegNumPPC_GCC_v0 = 77,
- eRegNumPPC_GCC_v1 = 78,
- eRegNumPPC_GCC_v2 = 79,
- eRegNumPPC_GCC_v3 = 80,
- eRegNumPPC_GCC_v4 = 81,
- eRegNumPPC_GCC_v5 = 82,
- eRegNumPPC_GCC_v6 = 83,
- eRegNumPPC_GCC_v7 = 84,
- eRegNumPPC_GCC_v8 = 85,
- eRegNumPPC_GCC_v9 = 86,
- eRegNumPPC_GCC_v10 = 87,
- eRegNumPPC_GCC_v11 = 88,
- eRegNumPPC_GCC_v12 = 89,
- eRegNumPPC_GCC_v13 = 90,
- eRegNumPPC_GCC_v14 = 91,
- eRegNumPPC_GCC_v15 = 92,
- eRegNumPPC_GCC_v16 = 93,
- eRegNumPPC_GCC_v17 = 94,
- eRegNumPPC_GCC_v18 = 95,
- eRegNumPPC_GCC_v19 = 96,
- eRegNumPPC_GCC_v20 = 97,
- eRegNumPPC_GCC_v21 = 98,
- eRegNumPPC_GCC_v22 = 99,
- eRegNumPPC_GCC_v23 = 100,
- eRegNumPPC_GCC_v24 = 101,
- eRegNumPPC_GCC_v25 = 102,
- eRegNumPPC_GCC_v26 = 103,
- eRegNumPPC_GCC_v27 = 104,
- eRegNumPPC_GCC_v28 = 105,
- eRegNumPPC_GCC_v29 = 106,
- eRegNumPPC_GCC_v30 = 107,
- eRegNumPPC_GCC_v31 = 108,
- eRegNumPPC_GCC_vrsave = 109,
- eRegNumPPC_GCC_vscr = 110,
- eRegNumPPC_GCC_spe_acc = 111,
- eRegNumPPC_GCC_spefscr = 112,
- eRegNumPPC_GCC_sfp = 113
-};
-
-static const char * g_arm_gcc_reg_names[] = {
- "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
- "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc",
- "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
- "cc", "sfp", "afp",
- "mv0", "mv1", "mv2", "mv3", "mv4", "mv5", "mv6", "mv7",
- "mv8", "mv9", "mv10", "mv11", "mv12", "mv13", "mv14", "mv15",
- "wcgr0","wcgr1","wcgr2","wcgr3",
- "wr0", "wr1", "wr2", "wr3", "wr4", "wr5", "wr6", "wr7",
- "wr8", "wr9", "wr10", "wr11", "wr12", "wr13", "wr14", "wr15",
- "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
- "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
- "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
- "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
- "vfpcc"
-};
-
-//----------------------------------------------------------------------
-// Get register names for the current object architecture given
-// a register number, and a reg_kind for that register number.
-//----------------------------------------------------------------------
const char *
-ArchSpec::GetRegisterName(uint32_t reg_num, uint32_t reg_kind) const
+ArchSpec::GetArchitectureName () const
{
- return ArchSpec::GetRegisterName(m_type, m_cpu, m_sub, reg_num, reg_kind);
+ const CoreDefinition *core_def = FindCoreDefinition (m_core);
+ if (core_def)
+ return core_def->name;
+ return "unknown";
}
-
-//----------------------------------------------------------------------
-// Get register names for the specified CPU type and subtype given
-// a register number, and a reg_kind for that register number.
-//----------------------------------------------------------------------
-const char *
-ArchSpec::GetRegisterName (ArchitectureType arch_type, uint32_t cpu, uint32_t subtype, uint32_t reg_num, uint32_t reg_kind)
+uint32_t
+ArchSpec::GetMachOCPUType () const
{
- if ((arch_type == eArchTypeMachO && cpu == llvm::MachO::CPUTypeI386) ||
- (arch_type == eArchTypeELF && cpu == llvm::ELF::EM_386))
+ const CoreDefinition *core_def = FindCoreDefinition (m_core);
+ if (core_def)
{
- switch (reg_kind)
+ const ArchDefinitionEntry *arch_def = FindArchDefinitionEntry (&g_macho_arch_def, core_def->core);
+ if (arch_def)
{
- case eRegisterKindGCC:
- if (reg_num < sizeof(g_i386_gcc_reg_names)/sizeof(const char *))
- return g_i386_gcc_reg_names[reg_num];
- break;
- case eRegisterKindDWARF:
- if (reg_num < sizeof(g_i386_dwarf_reg_names)/sizeof(const char *))
- return g_i386_dwarf_reg_names[reg_num];
- break;
- default:
- break;
+ return arch_def->cpu;
}
}
- else if ((arch_type == eArchTypeMachO && cpu == llvm::MachO::CPUTypeX86_64) ||
- (arch_type == eArchTypeELF && cpu == llvm::ELF::EM_X86_64))
- {
- switch (reg_kind)
- {
- case eRegisterKindGCC:
- case eRegisterKindDWARF:
- if (reg_num < sizeof(g_x86_64_dwarf_and_gcc_reg_names)/sizeof(const char *))
- return g_x86_64_dwarf_and_gcc_reg_names[reg_num];
- break;
- default:
- break;
- }
- }
- else if ((arch_type == eArchTypeMachO && cpu == llvm::MachO::CPUTypeARM) ||
- (arch_type == eArchTypeELF && cpu == llvm::ELF::EM_ARM))
- {
- switch (reg_kind)
- {
- case eRegisterKindGCC:
- if (reg_num < sizeof(g_arm_gcc_reg_names)/sizeof(const char *))
- return g_arm_gcc_reg_names[reg_num];
- break;
-
- case eRegisterKindDWARF:
- switch (reg_num)
- {
- case eRegNumARM_DWARF_r0: return "r0";
- case eRegNumARM_DWARF_r1: return "r1";
- case eRegNumARM_DWARF_r2: return "r2";
- case eRegNumARM_DWARF_r3: return "r3";
- case eRegNumARM_DWARF_r4: return "r4";
- case eRegNumARM_DWARF_r5: return "r5";
- case eRegNumARM_DWARF_r6: return "r6";
- case eRegNumARM_DWARF_r7: return "r7";
- case eRegNumARM_DWARF_r8: return "r8";
- case eRegNumARM_DWARF_r9: return "r9";
- case eRegNumARM_DWARF_r10: return "r10";
- case eRegNumARM_DWARF_r11: return "r11";
- case eRegNumARM_DWARF_r12: return "r12";
- case eRegNumARM_DWARF_r13: return "sp";
- case eRegNumARM_DWARF_r14: return "lr";
- case eRegNumARM_DWARF_r15: return "pc";
- case eRegNumARM_DWARF_s0_obsolete: case eRegNumARM_DWARF_s0: return "s0";
- case eRegNumARM_DWARF_s1_obsolete: case eRegNumARM_DWARF_s1: return "s1";
- case eRegNumARM_DWARF_s2_obsolete: case eRegNumARM_DWARF_s2: return "s2";
- case eRegNumARM_DWARF_s3_obsolete: case eRegNumARM_DWARF_s3: return "s3";
- case eRegNumARM_DWARF_s4_obsolete: case eRegNumARM_DWARF_s4: return "s4";
- case eRegNumARM_DWARF_s5_obsolete: case eRegNumARM_DWARF_s5: return "s5";
- case eRegNumARM_DWARF_s6_obsolete: case eRegNumARM_DWARF_s6: return "s6";
- case eRegNumARM_DWARF_s7_obsolete: case eRegNumARM_DWARF_s7: return "s7";
- case eRegNumARM_DWARF_s8_obsolete: case eRegNumARM_DWARF_s8: return "s8";
- case eRegNumARM_DWARF_s9_obsolete: case eRegNumARM_DWARF_s9: return "s9";
- case eRegNumARM_DWARF_s10_obsolete: case eRegNumARM_DWARF_s10: return "s10";
- case eRegNumARM_DWARF_s11_obsolete: case eRegNumARM_DWARF_s11: return "s11";
- case eRegNumARM_DWARF_s12_obsolete: case eRegNumARM_DWARF_s12: return "s12";
- case eRegNumARM_DWARF_s13_obsolete: case eRegNumARM_DWARF_s13: return "s13";
- case eRegNumARM_DWARF_s14_obsolete: case eRegNumARM_DWARF_s14: return "s14";
- case eRegNumARM_DWARF_s15_obsolete: case eRegNumARM_DWARF_s15: return "s15";
- case eRegNumARM_DWARF_s16_obsolete: case eRegNumARM_DWARF_s16: return "s16";
- case eRegNumARM_DWARF_s17_obsolete: case eRegNumARM_DWARF_s17: return "s17";
- case eRegNumARM_DWARF_s18_obsolete: case eRegNumARM_DWARF_s18: return "s18";
- case eRegNumARM_DWARF_s19_obsolete: case eRegNumARM_DWARF_s19: return "s19";
- case eRegNumARM_DWARF_s20_obsolete: case eRegNumARM_DWARF_s20: return "s20";
- case eRegNumARM_DWARF_s21_obsolete: case eRegNumARM_DWARF_s21: return "s21";
- case eRegNumARM_DWARF_s22_obsolete: case eRegNumARM_DWARF_s22: return "s22";
- case eRegNumARM_DWARF_s23_obsolete: case eRegNumARM_DWARF_s23: return "s23";
- case eRegNumARM_DWARF_s24_obsolete: case eRegNumARM_DWARF_s24: return "s24";
- case eRegNumARM_DWARF_s25_obsolete: case eRegNumARM_DWARF_s25: return "s25";
- case eRegNumARM_DWARF_s26_obsolete: case eRegNumARM_DWARF_s26: return "s26";
- case eRegNumARM_DWARF_s27_obsolete: case eRegNumARM_DWARF_s27: return "s27";
- case eRegNumARM_DWARF_s28_obsolete: case eRegNumARM_DWARF_s28: return "s28";
- case eRegNumARM_DWARF_s29_obsolete: case eRegNumARM_DWARF_s29: return "s29";
- case eRegNumARM_DWARF_s30_obsolete: case eRegNumARM_DWARF_s30: return "s30";
- case eRegNumARM_DWARF_s31_obsolete: case eRegNumARM_DWARF_s31: return "s31";
- case eRegNumARM_DWARF_f0: return "f0";
- case eRegNumARM_DWARF_f1: return "f1";
- case eRegNumARM_DWARF_f2: return "f2";
- case eRegNumARM_DWARF_f3: return "f3";
- case eRegNumARM_DWARF_f4: return "f4";
- case eRegNumARM_DWARF_f5: return "f5";
- case eRegNumARM_DWARF_f6: return "f6";
- case eRegNumARM_DWARF_f7: return "f7";
- case eRegNumARM_DWARF_wCGR0: return "wCGR0/ACC0";
- case eRegNumARM_DWARF_wCGR1: return "wCGR1/ACC1";
- case eRegNumARM_DWARF_wCGR2: return "wCGR2/ACC2";
- case eRegNumARM_DWARF_wCGR3: return "wCGR3/ACC3";
- case eRegNumARM_DWARF_wCGR4: return "wCGR4/ACC4";
- case eRegNumARM_DWARF_wCGR5: return "wCGR5/ACC5";
- case eRegNumARM_DWARF_wCGR6: return "wCGR6/ACC6";
- case eRegNumARM_DWARF_wCGR7: return "wCGR7/ACC7";
- case eRegNumARM_DWARF_wR0: return "wR0";
- case eRegNumARM_DWARF_wR1: return "wR1";
- case eRegNumARM_DWARF_wR2: return "wR2";
- case eRegNumARM_DWARF_wR3: return "wR3";
- case eRegNumARM_DWARF_wR4: return "wR4";
- case eRegNumARM_DWARF_wR5: return "wR5";
- case eRegNumARM_DWARF_wR6: return "wR6";
- case eRegNumARM_DWARF_wR7: return "wR7";
- case eRegNumARM_DWARF_wR8: return "wR8";
- case eRegNumARM_DWARF_wR9: return "wR9";
- case eRegNumARM_DWARF_wR10: return "wR10";
- case eRegNumARM_DWARF_wR11: return "wR11";
- case eRegNumARM_DWARF_wR12: return "wR12";
- case eRegNumARM_DWARF_wR13: return "wR13";
- case eRegNumARM_DWARF_wR14: return "wR14";
- case eRegNumARM_DWARF_wR15: return "wR15";
- case eRegNumARM_DWARF_spsr: return "spsr";
- case eRegNumARM_DWARF_spsr_fiq: return "spsr_fiq";
- case eRegNumARM_DWARF_spsr_irq: return "spsr_irq";
- case eRegNumARM_DWARF_spsr_abt: return "spsr_abt";
- case eRegNumARM_DWARF_spsr_und: return "spsr_und";
- case eRegNumARM_DWARF_spsr_svc: return "spsr_svc";
- case eRegNumARM_DWARF_r8_usr: return "r8_usr";
- case eRegNumARM_DWARF_r9_usr: return "r9_usr";
- case eRegNumARM_DWARF_r10_usr: return "r10_usr";
- case eRegNumARM_DWARF_r11_usr: return "r11_usr";
- case eRegNumARM_DWARF_r12_usr: return "r12_usr";
- case eRegNumARM_DWARF_r13_usr: return "sp_usr";
- case eRegNumARM_DWARF_r14_usr: return "lr_usr";
- case eRegNumARM_DWARF_r8_fiq: return "r8_fiq";
- case eRegNumARM_DWARF_r9_fiq: return "r9_fiq";
- case eRegNumARM_DWARF_r10_fiq: return "r10_fiq";
- case eRegNumARM_DWARF_r11_fiq: return "r11_fiq";
- case eRegNumARM_DWARF_r12_fiq: return "r12_fiq";
- case eRegNumARM_DWARF_r13_fiq: return "sp_fiq";
- case eRegNumARM_DWARF_r14_fiq: return "lr_fiq";
- case eRegNumARM_DWARF_r13_irq: return "sp_irq";
- case eRegNumARM_DWARF_r14_irq: return "lr_irq";
- case eRegNumARM_DWARF_r13_abt: return "sp_abt";
- case eRegNumARM_DWARF_r14_abt: return "lr_abt";
- case eRegNumARM_DWARF_r13_und: return "sp_und";
- case eRegNumARM_DWARF_r14_und: return "lr_und";
- case eRegNumARM_DWARF_r13_svc: return "sp_svc";
- case eRegNumARM_DWARF_r14_svc: return "lr_svc";
- case eRegNumARM_DWARF_wC0: return "wC0";
- case eRegNumARM_DWARF_wC1: return "wC1";
- case eRegNumARM_DWARF_wC2: return "wC2";
- case eRegNumARM_DWARF_wC3: return "wC3";
- case eRegNumARM_DWARF_wC4: return "wC4";
- case eRegNumARM_DWARF_wC5: return "wC5";
- case eRegNumARM_DWARF_wC6: return "wC6";
- case eRegNumARM_DWARF_wC7: return "wC7";
- case eRegNumARM_DWARF_d0: return "d0";
- case eRegNumARM_DWARF_d1: return "d1";
- case eRegNumARM_DWARF_d2: return "d2";
- case eRegNumARM_DWARF_d3: return "d3";
- case eRegNumARM_DWARF_d4: return "d4";
- case eRegNumARM_DWARF_d5: return "d5";
- case eRegNumARM_DWARF_d6: return "d6";
- case eRegNumARM_DWARF_d7: return "d7";
- case eRegNumARM_DWARF_d8: return "d8";
- case eRegNumARM_DWARF_d9: return "d9";
- case eRegNumARM_DWARF_d10: return "d10";
- case eRegNumARM_DWARF_d11: return "d11";
- case eRegNumARM_DWARF_d12: return "d12";
- case eRegNumARM_DWARF_d13: return "d13";
- case eRegNumARM_DWARF_d14: return "d14";
- case eRegNumARM_DWARF_d15: return "d15";
- case eRegNumARM_DWARF_d16: return "d16";
- case eRegNumARM_DWARF_d17: return "d17";
- case eRegNumARM_DWARF_d18: return "d18";
- case eRegNumARM_DWARF_d19: return "d19";
- case eRegNumARM_DWARF_d20: return "d20";
- case eRegNumARM_DWARF_d21: return "d21";
- case eRegNumARM_DWARF_d22: return "d22";
- case eRegNumARM_DWARF_d23: return "d23";
- case eRegNumARM_DWARF_d24: return "d24";
- case eRegNumARM_DWARF_d25: return "d25";
- case eRegNumARM_DWARF_d26: return "d26";
- case eRegNumARM_DWARF_d27: return "d27";
- case eRegNumARM_DWARF_d28: return "d28";
- case eRegNumARM_DWARF_d29: return "d29";
- case eRegNumARM_DWARF_d30: return "d30";
- case eRegNumARM_DWARF_d31: return "d31";
- }
- break;
- default:
- break;
- }
- }
- else if ((arch_type == eArchTypeMachO && (cpu == llvm::MachO::CPUTypePowerPC || cpu == llvm::MachO::CPUTypePowerPC64)) ||
- (arch_type == eArchTypeELF && cpu == llvm::ELF::EM_PPC))
- {
- switch (reg_kind)
- {
- case eRegisterKindGCC:
- switch (reg_num)
- {
- case eRegNumPPC_GCC_r0: return "r0";
- case eRegNumPPC_GCC_r1: return "r1";
- case eRegNumPPC_GCC_r2: return "r2";
- case eRegNumPPC_GCC_r3: return "r3";
- case eRegNumPPC_GCC_r4: return "r4";
- case eRegNumPPC_GCC_r5: return "r5";
- case eRegNumPPC_GCC_r6: return "r6";
- case eRegNumPPC_GCC_r7: return "r7";
- case eRegNumPPC_GCC_r8: return "r8";
- case eRegNumPPC_GCC_r9: return "r9";
- case eRegNumPPC_GCC_r10: return "r10";
- case eRegNumPPC_GCC_r11: return "r11";
- case eRegNumPPC_GCC_r12: return "r12";
- case eRegNumPPC_GCC_r13: return "r13";
- case eRegNumPPC_GCC_r14: return "r14";
- case eRegNumPPC_GCC_r15: return "r15";
- case eRegNumPPC_GCC_r16: return "r16";
- case eRegNumPPC_GCC_r17: return "r17";
- case eRegNumPPC_GCC_r18: return "r18";
- case eRegNumPPC_GCC_r19: return "r19";
- case eRegNumPPC_GCC_r20: return "r20";
- case eRegNumPPC_GCC_r21: return "r21";
- case eRegNumPPC_GCC_r22: return "r22";
- case eRegNumPPC_GCC_r23: return "r23";
- case eRegNumPPC_GCC_r24: return "r24";
- case eRegNumPPC_GCC_r25: return "r25";
- case eRegNumPPC_GCC_r26: return "r26";
- case eRegNumPPC_GCC_r27: return "r27";
- case eRegNumPPC_GCC_r28: return "r28";
- case eRegNumPPC_GCC_r29: return "r29";
- case eRegNumPPC_GCC_r30: return "r30";
- case eRegNumPPC_GCC_r31: return "r31";
- case eRegNumPPC_GCC_fr0: return "fr0";
- case eRegNumPPC_GCC_fr1: return "fr1";
- case eRegNumPPC_GCC_fr2: return "fr2";
- case eRegNumPPC_GCC_fr3: return "fr3";
- case eRegNumPPC_GCC_fr4: return "fr4";
- case eRegNumPPC_GCC_fr5: return "fr5";
- case eRegNumPPC_GCC_fr6: return "fr6";
- case eRegNumPPC_GCC_fr7: return "fr7";
- case eRegNumPPC_GCC_fr8: return "fr8";
- case eRegNumPPC_GCC_fr9: return "fr9";
- case eRegNumPPC_GCC_fr10: return "fr10";
- case eRegNumPPC_GCC_fr11: return "fr11";
- case eRegNumPPC_GCC_fr12: return "fr12";
- case eRegNumPPC_GCC_fr13: return "fr13";
- case eRegNumPPC_GCC_fr14: return "fr14";
- case eRegNumPPC_GCC_fr15: return "fr15";
- case eRegNumPPC_GCC_fr16: return "fr16";
- case eRegNumPPC_GCC_fr17: return "fr17";
- case eRegNumPPC_GCC_fr18: return "fr18";
- case eRegNumPPC_GCC_fr19: return "fr19";
- case eRegNumPPC_GCC_fr20: return "fr20";
- case eRegNumPPC_GCC_fr21: return "fr21";
- case eRegNumPPC_GCC_fr22: return "fr22";
- case eRegNumPPC_GCC_fr23: return "fr23";
- case eRegNumPPC_GCC_fr24: return "fr24";
- case eRegNumPPC_GCC_fr25: return "fr25";
- case eRegNumPPC_GCC_fr26: return "fr26";
- case eRegNumPPC_GCC_fr27: return "fr27";
- case eRegNumPPC_GCC_fr28: return "fr28";
- case eRegNumPPC_GCC_fr29: return "fr29";
- case eRegNumPPC_GCC_fr30: return "fr30";
- case eRegNumPPC_GCC_fr31: return "fr31";
- case eRegNumPPC_GCC_mq: return "mq";
- case eRegNumPPC_GCC_lr: return "lr";
- case eRegNumPPC_GCC_ctr: return "ctr";
- case eRegNumPPC_GCC_ap: return "ap";
- case eRegNumPPC_GCC_cr0: return "cr0";
- case eRegNumPPC_GCC_cr1: return "cr1";
- case eRegNumPPC_GCC_cr2: return "cr2";
- case eRegNumPPC_GCC_cr3: return "cr3";
- case eRegNumPPC_GCC_cr4: return "cr4";
- case eRegNumPPC_GCC_cr5: return "cr5";
- case eRegNumPPC_GCC_cr6: return "cr6";
- case eRegNumPPC_GCC_cr7: return "cr7";
- case eRegNumPPC_GCC_xer: return "xer";
- case eRegNumPPC_GCC_v0: return "v0";
- case eRegNumPPC_GCC_v1: return "v1";
- case eRegNumPPC_GCC_v2: return "v2";
- case eRegNumPPC_GCC_v3: return "v3";
- case eRegNumPPC_GCC_v4: return "v4";
- case eRegNumPPC_GCC_v5: return "v5";
- case eRegNumPPC_GCC_v6: return "v6";
- case eRegNumPPC_GCC_v7: return "v7";
- case eRegNumPPC_GCC_v8: return "v8";
- case eRegNumPPC_GCC_v9: return "v9";
- case eRegNumPPC_GCC_v10: return "v10";
- case eRegNumPPC_GCC_v11: return "v11";
- case eRegNumPPC_GCC_v12: return "v12";
- case eRegNumPPC_GCC_v13: return "v13";
- case eRegNumPPC_GCC_v14: return "v14";
- case eRegNumPPC_GCC_v15: return "v15";
- case eRegNumPPC_GCC_v16: return "v16";
- case eRegNumPPC_GCC_v17: return "v17";
- case eRegNumPPC_GCC_v18: return "v18";
- case eRegNumPPC_GCC_v19: return "v19";
- case eRegNumPPC_GCC_v20: return "v20";
- case eRegNumPPC_GCC_v21: return "v21";
- case eRegNumPPC_GCC_v22: return "v22";
- case eRegNumPPC_GCC_v23: return "v23";
- case eRegNumPPC_GCC_v24: return "v24";
- case eRegNumPPC_GCC_v25: return "v25";
- case eRegNumPPC_GCC_v26: return "v26";
- case eRegNumPPC_GCC_v27: return "v27";
- case eRegNumPPC_GCC_v28: return "v28";
- case eRegNumPPC_GCC_v29: return "v29";
- case eRegNumPPC_GCC_v30: return "v30";
- case eRegNumPPC_GCC_v31: return "v31";
- case eRegNumPPC_GCC_vrsave: return "vrsave";
- case eRegNumPPC_GCC_vscr: return "vscr";
- case eRegNumPPC_GCC_spe_acc: return "spe_acc";
- case eRegNumPPC_GCC_spefscr: return "spefscr";
- case eRegNumPPC_GCC_sfp: return "sfp";
- default:
- break;
- }
- break;
-
- case eRegisterKindDWARF:
- switch (reg_num)
- {
- case eRegNumPPC_DWARF_r0: return "r0";
- case eRegNumPPC_DWARF_r1: return "r1";
- case eRegNumPPC_DWARF_r2: return "r2";
- case eRegNumPPC_DWARF_r3: return "r3";
- case eRegNumPPC_DWARF_r4: return "r4";
- case eRegNumPPC_DWARF_r5: return "r5";
- case eRegNumPPC_DWARF_r6: return "r6";
- case eRegNumPPC_DWARF_r7: return "r7";
- case eRegNumPPC_DWARF_r8: return "r8";
- case eRegNumPPC_DWARF_r9: return "r9";
- case eRegNumPPC_DWARF_r10: return "r10";
- case eRegNumPPC_DWARF_r11: return "r11";
- case eRegNumPPC_DWARF_r12: return "r12";
- case eRegNumPPC_DWARF_r13: return "r13";
- case eRegNumPPC_DWARF_r14: return "r14";
- case eRegNumPPC_DWARF_r15: return "r15";
- case eRegNumPPC_DWARF_r16: return "r16";
- case eRegNumPPC_DWARF_r17: return "r17";
- case eRegNumPPC_DWARF_r18: return "r18";
- case eRegNumPPC_DWARF_r19: return "r19";
- case eRegNumPPC_DWARF_r20: return "r20";
- case eRegNumPPC_DWARF_r21: return "r21";
- case eRegNumPPC_DWARF_r22: return "r22";
- case eRegNumPPC_DWARF_r23: return "r23";
- case eRegNumPPC_DWARF_r24: return "r24";
- case eRegNumPPC_DWARF_r25: return "r25";
- case eRegNumPPC_DWARF_r26: return "r26";
- case eRegNumPPC_DWARF_r27: return "r27";
- case eRegNumPPC_DWARF_r28: return "r28";
- case eRegNumPPC_DWARF_r29: return "r29";
- case eRegNumPPC_DWARF_r30: return "r30";
- case eRegNumPPC_DWARF_r31: return "r31";
-
- case eRegNumPPC_DWARF_fr0: return "fr0";
- case eRegNumPPC_DWARF_fr1: return "fr1";
- case eRegNumPPC_DWARF_fr2: return "fr2";
- case eRegNumPPC_DWARF_fr3: return "fr3";
- case eRegNumPPC_DWARF_fr4: return "fr4";
- case eRegNumPPC_DWARF_fr5: return "fr5";
- case eRegNumPPC_DWARF_fr6: return "fr6";
- case eRegNumPPC_DWARF_fr7: return "fr7";
- case eRegNumPPC_DWARF_fr8: return "fr8";
- case eRegNumPPC_DWARF_fr9: return "fr9";
- case eRegNumPPC_DWARF_fr10: return "fr10";
- case eRegNumPPC_DWARF_fr11: return "fr11";
- case eRegNumPPC_DWARF_fr12: return "fr12";
- case eRegNumPPC_DWARF_fr13: return "fr13";
- case eRegNumPPC_DWARF_fr14: return "fr14";
- case eRegNumPPC_DWARF_fr15: return "fr15";
- case eRegNumPPC_DWARF_fr16: return "fr16";
- case eRegNumPPC_DWARF_fr17: return "fr17";
- case eRegNumPPC_DWARF_fr18: return "fr18";
- case eRegNumPPC_DWARF_fr19: return "fr19";
- case eRegNumPPC_DWARF_fr20: return "fr20";
- case eRegNumPPC_DWARF_fr21: return "fr21";
- case eRegNumPPC_DWARF_fr22: return "fr22";
- case eRegNumPPC_DWARF_fr23: return "fr23";
- case eRegNumPPC_DWARF_fr24: return "fr24";
- case eRegNumPPC_DWARF_fr25: return "fr25";
- case eRegNumPPC_DWARF_fr26: return "fr26";
- case eRegNumPPC_DWARF_fr27: return "fr27";
- case eRegNumPPC_DWARF_fr28: return "fr28";
- case eRegNumPPC_DWARF_fr29: return "fr29";
- case eRegNumPPC_DWARF_fr30: return "fr30";
- case eRegNumPPC_DWARF_fr31: return "fr31";
-
- case eRegNumPPC_DWARF_cr: return "cr";
- case eRegNumPPC_DWARF_fpscr: return "fpscr";
- case eRegNumPPC_DWARF_msr: return "msr";
- case eRegNumPPC_DWARF_vscr: return "vscr";
-
- case eRegNumPPC_DWARF_sr0: return "sr0";
- case eRegNumPPC_DWARF_sr1: return "sr1";
- case eRegNumPPC_DWARF_sr2: return "sr2";
- case eRegNumPPC_DWARF_sr3: return "sr3";
- case eRegNumPPC_DWARF_sr4: return "sr4";
- case eRegNumPPC_DWARF_sr5: return "sr5";
- case eRegNumPPC_DWARF_sr6: return "sr6";
- case eRegNumPPC_DWARF_sr7: return "sr7";
- case eRegNumPPC_DWARF_sr8: return "sr8";
- case eRegNumPPC_DWARF_sr9: return "sr9";
- case eRegNumPPC_DWARF_sr10: return "sr10";
- case eRegNumPPC_DWARF_sr11: return "sr11";
- case eRegNumPPC_DWARF_sr12: return "sr12";
- case eRegNumPPC_DWARF_sr13: return "sr13";
- case eRegNumPPC_DWARF_sr14: return "sr14";
- case eRegNumPPC_DWARF_sr15: return "sr15";
-
- case eRegNumPPC_DWARF_acc: return "acc";
- case eRegNumPPC_DWARF_mq: return "mq";
- case eRegNumPPC_DWARF_xer: return "xer";
- case eRegNumPPC_DWARF_rtcu: return "rtcu";
- case eRegNumPPC_DWARF_rtcl: return "rtcl";
-
- case eRegNumPPC_DWARF_lr: return "lr";
- case eRegNumPPC_DWARF_ctr: return "ctr";
-
- case eRegNumPPC_DWARF_dsisr: return "dsisr";
- case eRegNumPPC_DWARF_dar: return "dar";
- case eRegNumPPC_DWARF_dec: return "dec";
- case eRegNumPPC_DWARF_sdr1: return "sdr1";
- case eRegNumPPC_DWARF_srr0: return "srr0";
- case eRegNumPPC_DWARF_srr1: return "srr1";
-
- case eRegNumPPC_DWARF_vrsave: return "vrsave";
-
- case eRegNumPPC_DWARF_sprg0: return "sprg0";
- case eRegNumPPC_DWARF_sprg1: return "sprg1";
- case eRegNumPPC_DWARF_sprg2: return "sprg2";
- case eRegNumPPC_DWARF_sprg3: return "sprg3";
-
- case eRegNumPPC_DWARF_asr: return "asr";
- case eRegNumPPC_DWARF_ear: return "ear";
- case eRegNumPPC_DWARF_tb: return "tb";
- case eRegNumPPC_DWARF_tbu: return "tbu";
- case eRegNumPPC_DWARF_pvr: return "pvr";
-
- case eRegNumPPC_DWARF_spefscr: return "spefscr";
-
- case eRegNumPPC_DWARF_ibat0u: return "ibat0u";
- case eRegNumPPC_DWARF_ibat0l: return "ibat0l";
- case eRegNumPPC_DWARF_ibat1u: return "ibat1u";
- case eRegNumPPC_DWARF_ibat1l: return "ibat1l";
- case eRegNumPPC_DWARF_ibat2u: return "ibat2u";
- case eRegNumPPC_DWARF_ibat2l: return "ibat2l";
- case eRegNumPPC_DWARF_ibat3u: return "ibat3u";
- case eRegNumPPC_DWARF_ibat3l: return "ibat3l";
- case eRegNumPPC_DWARF_dbat0u: return "dbat0u";
- case eRegNumPPC_DWARF_dbat0l: return "dbat0l";
- case eRegNumPPC_DWARF_dbat1u: return "dbat1u";
- case eRegNumPPC_DWARF_dbat1l: return "dbat1l";
- case eRegNumPPC_DWARF_dbat2u: return "dbat2u";
- case eRegNumPPC_DWARF_dbat2l: return "dbat2l";
- case eRegNumPPC_DWARF_dbat3u: return "dbat3u";
- case eRegNumPPC_DWARF_dbat3l: return "dbat3l";
-
- case eRegNumPPC_DWARF_hid0: return "hid0";
- case eRegNumPPC_DWARF_hid1: return "hid1";
- case eRegNumPPC_DWARF_hid2: return "hid2";
- case eRegNumPPC_DWARF_hid3: return "hid3";
- case eRegNumPPC_DWARF_hid4: return "hid4";
- case eRegNumPPC_DWARF_hid5: return "hid5";
- case eRegNumPPC_DWARF_hid6: return "hid6";
- case eRegNumPPC_DWARF_hid7: return "hid7";
- case eRegNumPPC_DWARF_hid8: return "hid8";
- case eRegNumPPC_DWARF_hid9: return "hid9";
- case eRegNumPPC_DWARF_hid10: return "hid10";
- case eRegNumPPC_DWARF_hid11: return "hid11";
- case eRegNumPPC_DWARF_hid12: return "hid12";
- case eRegNumPPC_DWARF_hid13: return "hid13";
- case eRegNumPPC_DWARF_hid14: return "hid14";
- case eRegNumPPC_DWARF_hid15: return "hid15";
-
- case eRegNumPPC_DWARF_vr0: return "vr0";
- case eRegNumPPC_DWARF_vr1: return "vr1";
- case eRegNumPPC_DWARF_vr2: return "vr2";
- case eRegNumPPC_DWARF_vr3: return "vr3";
- case eRegNumPPC_DWARF_vr4: return "vr4";
- case eRegNumPPC_DWARF_vr5: return "vr5";
- case eRegNumPPC_DWARF_vr6: return "vr6";
- case eRegNumPPC_DWARF_vr7: return "vr7";
- case eRegNumPPC_DWARF_vr8: return "vr8";
- case eRegNumPPC_DWARF_vr9: return "vr9";
- case eRegNumPPC_DWARF_vr10: return "vr10";
- case eRegNumPPC_DWARF_vr11: return "vr11";
- case eRegNumPPC_DWARF_vr12: return "vr12";
- case eRegNumPPC_DWARF_vr13: return "vr13";
- case eRegNumPPC_DWARF_vr14: return "vr14";
- case eRegNumPPC_DWARF_vr15: return "vr15";
- case eRegNumPPC_DWARF_vr16: return "vr16";
- case eRegNumPPC_DWARF_vr17: return "vr17";
- case eRegNumPPC_DWARF_vr18: return "vr18";
- case eRegNumPPC_DWARF_vr19: return "vr19";
- case eRegNumPPC_DWARF_vr20: return "vr20";
- case eRegNumPPC_DWARF_vr21: return "vr21";
- case eRegNumPPC_DWARF_vr22: return "vr22";
- case eRegNumPPC_DWARF_vr23: return "vr23";
- case eRegNumPPC_DWARF_vr24: return "vr24";
- case eRegNumPPC_DWARF_vr25: return "vr25";
- case eRegNumPPC_DWARF_vr26: return "vr26";
- case eRegNumPPC_DWARF_vr27: return "vr27";
- case eRegNumPPC_DWARF_vr28: return "vr28";
- case eRegNumPPC_DWARF_vr29: return "vr29";
- case eRegNumPPC_DWARF_vr30: return "vr30";
- case eRegNumPPC_DWARF_vr31: return "vr31";
-
- case eRegNumPPC_DWARF_ev0: return "ev0";
- case eRegNumPPC_DWARF_ev1: return "ev1";
- case eRegNumPPC_DWARF_ev2: return "ev2";
- case eRegNumPPC_DWARF_ev3: return "ev3";
- case eRegNumPPC_DWARF_ev4: return "ev4";
- case eRegNumPPC_DWARF_ev5: return "ev5";
- case eRegNumPPC_DWARF_ev6: return "ev6";
- case eRegNumPPC_DWARF_ev7: return "ev7";
- case eRegNumPPC_DWARF_ev8: return "ev8";
- case eRegNumPPC_DWARF_ev9: return "ev9";
- case eRegNumPPC_DWARF_ev10: return "ev10";
- case eRegNumPPC_DWARF_ev11: return "ev11";
- case eRegNumPPC_DWARF_ev12: return "ev12";
- case eRegNumPPC_DWARF_ev13: return "ev13";
- case eRegNumPPC_DWARF_ev14: return "ev14";
- case eRegNumPPC_DWARF_ev15: return "ev15";
- case eRegNumPPC_DWARF_ev16: return "ev16";
- case eRegNumPPC_DWARF_ev17: return "ev17";
- case eRegNumPPC_DWARF_ev18: return "ev18";
- case eRegNumPPC_DWARF_ev19: return "ev19";
- case eRegNumPPC_DWARF_ev20: return "ev20";
- case eRegNumPPC_DWARF_ev21: return "ev21";
- case eRegNumPPC_DWARF_ev22: return "ev22";
- case eRegNumPPC_DWARF_ev23: return "ev23";
- case eRegNumPPC_DWARF_ev24: return "ev24";
- case eRegNumPPC_DWARF_ev25: return "ev25";
- case eRegNumPPC_DWARF_ev26: return "ev26";
- case eRegNumPPC_DWARF_ev27: return "ev27";
- case eRegNumPPC_DWARF_ev28: return "ev28";
- case eRegNumPPC_DWARF_ev29: return "ev29";
- case eRegNumPPC_DWARF_ev30: return "ev30";
- case eRegNumPPC_DWARF_ev31: return "ev31";
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- }
- return NULL;
+ return LLDB_INVALID_CPUTYPE;
}
-//----------------------------------------------------------------------
-// Returns true if this object contains a valid architecture, false
-// otherwise.
-//----------------------------------------------------------------------
-bool
-ArchSpec::IsValid() const
+uint32_t
+ArchSpec::GetMachOCPUSubType () const
{
- return !(m_cpu == LLDB_INVALID_CPUTYPE);
+ const CoreDefinition *core_def = FindCoreDefinition (m_core);
+ if (core_def)
+ {
+ const ArchDefinitionEntry *arch_def = FindArchDefinitionEntry (&g_macho_arch_def, core_def->core);
+ if (arch_def)
+ {
+ return arch_def->cpu;
+ }
+ }
+ return LLDB_INVALID_CPUTYPE;
}
-//----------------------------------------------------------------------
-// Returns true if this architecture is 64 bit, otherwise 32 bit is
-// assumed and false is returned.
-//----------------------------------------------------------------------
+llvm::Triple::ArchType
+ArchSpec::GetMachine () const
+{
+ const CoreDefinition *core_def = FindCoreDefinition (m_core);
+ if (core_def)
+ return core_def->machine;
+
+ return llvm::Triple::UnknownArch;
+}
+
uint32_t
ArchSpec::GetAddressByteSize() const
{
- if (m_addr_byte_size > 0)
- return m_addr_byte_size;
-
- switch (m_type)
- {
- case kNumArchTypes:
- case eArchTypeInvalid:
- break;
-
- case eArchTypeMachO:
- if (GetCPUType() & llvm::MachO::CPUArchABI64)
- return 8;
- else
- return 4;
- break;
-
- case eArchTypeELF:
- switch (m_cpu)
- {
- case llvm::ELF::EM_M32:
- case llvm::ELF::EM_SPARC:
- case llvm::ELF::EM_386:
- case llvm::ELF::EM_68K:
- case llvm::ELF::EM_88K:
- case llvm::ELF::EM_486:
- case llvm::ELF::EM_860:
- case llvm::ELF::EM_MIPS:
- case llvm::ELF::EM_PPC:
- case llvm::ELF::EM_ARM:
- case llvm::ELF::EM_ALPHA:
- case llvm::ELF::EM_SPARCV9:
- return 4;
- case llvm::ELF::EM_X86_64:
- return 8;
- }
- break;
- }
+ const CoreDefinition *core_def = FindCoreDefinition (m_core);
+ if (core_def)
+ return core_def->addr_byte_size;
return 0;
}
-//----------------------------------------------------------------------
-// Returns the number of bytes that this object takes when an
-// instance exists in memory.
-//----------------------------------------------------------------------
-size_t
-ArchSpec::MemorySize() const
-{
- return sizeof(ArchSpec);
-}
-
-bool
-ArchSpec::SetArchFromTargetTriple (const char *target_triple)
-{
- if (target_triple)
- {
- const char *hyphen = strchr(target_triple, '-');
- if (hyphen)
- {
- std::string arch_only (target_triple, hyphen);
- return SetArch (arch_only.c_str());
- }
- }
- 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.
-//----------------------------------------------------------------------
-bool
-ArchSpec::SetArch (const char *arch_name)
-{
- if (arch_name && arch_name[0] != '\0')
- {
- // 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:
- case eArchTypeMachO:
- for (i=0; i<k_num_mach_arch_defs; i++)
- {
- if (strcasecmp(arch_name, g_mach_arch_defs[i].name) == 0)
- {
- m_type = eArchTypeMachO;
- m_cpu = g_mach_arch_defs[i].cpu;
- m_sub = g_mach_arch_defs[i].sub;
- MachOArchUpdated (i);
- return true;
- }
- }
- break;
-
- case eArchTypeELF:
- for (i=0; i<k_num_elf_arch_defs; i++)
- {
- if (strcasecmp(arch_name, g_elf_arch_defs[i].name) == 0)
- {
- m_cpu = g_elf_arch_defs[i].cpu;
- m_sub = g_elf_arch_defs[i].sub;
- ELFArchUpdated (i);
- return true;
- }
- }
- break;
-
- case kNumArchTypes:
- break;
- }
-
- const char *str = arch_name;
- // Check for a numeric cpu followed by an optional separator char and numeric subtype.
- // This allows for support of new cpu type/subtypes without having to have
- // a recompiled debug core.
- // Examples:
- // "12.6" is armv6
- // "0x0000000c-0x00000006" is also armv6
-
- m_type = eArchTypeInvalid;
- for (i=1; i<kNumArchTypes; ++i)
- {
- const char *arch_type_cstr = g_arch_type_strings[i];
- if (strstr(str, arch_type_cstr))
- {
- m_type = (ArchitectureType)i;
- str += strlen(arch_type_cstr) + 1; // Also skip separator char
- }
- }
-
- if (m_type != eArchTypeInvalid)
- {
- m_type = eArchTypeMachO;
- char *end = NULL;
- m_cpu = ::strtoul (str, &end, 0);
- if (str != end)
- {
- if (*end == ARCH_SPEC_SEPARATOR_CHAR)
- {
- // We have a cputype.cpusubtype format
- str = end + 1;
- if (*str != '\0')
- {
- m_sub = strtoul(str, &end, 0);
- if (*end == '\0')
- {
- MachOArchUpdated ();
- // We consumed the entire string and got a cpu type and subtype
- return true;
- }
- }
- }
-
- // If we reach this point we have a valid cpu type, but no cpu subtype.
- // Search for the first matching cpu type and use the corresponding cpu
- // subtype. This setting should typically be the _ALL variant and should
- // appear first in the list for each cpu type in the g_mach_arch_defs
- // structure.
- for (i=0; i<k_num_mach_arch_defs; ++i)
- {
- 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;
- }
- }
-
- // 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;
- }
- }
- }
- Clear();
- return false;
-}
-
ByteOrder
ArchSpec::GetDefaultEndian () const
{
- switch (GetGenericCPUType ())
- {
- case eCPU_ppc:
- case eCPU_ppc64:
- return eByteOrderBig;
-
- case eCPU_arm:
- case eCPU_i386:
- case eCPU_x86_64:
- return eByteOrderLittle;
-
- default:
- break;
- }
+ const CoreDefinition *core_def = FindCoreDefinition (m_core);
+ if (core_def)
+ return core_def->default_byte_order;
return eByteOrderInvalid;
}
-//----------------------------------------------------------------------
-// Equal operator
-//----------------------------------------------------------------------
+lldb::ByteOrder
+ArchSpec::GetByteOrder () const
+{
+ if (m_byte_order == eByteOrderInvalid)
+ return GetDefaultEndian();
+ return m_byte_order;
+}
+
+//===----------------------------------------------------------------------===//
+// Mutators.
+
+bool
+ArchSpec::SetTriple (const llvm::Triple &triple)
+{
+ m_triple = triple;
+
+ llvm::StringRef arch_name (m_triple.getArchName());
+ const CoreDefinition *core_def = FindCoreDefinition (arch_name);
+ if (core_def)
+ {
+ m_core = core_def->core;
+ m_byte_order = core_def->default_byte_order;
+
+ // If the vendor, OS or environment aren't specified, default to the system?
+ const ArchSpec &host_arch_ref = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
+ if (m_triple.getVendor() == llvm::Triple::UnknownVendor)
+ m_triple.setVendor(host_arch_ref.GetTriple().getVendor());
+ if (m_triple.getOS() == llvm::Triple::UnknownOS)
+ m_triple.setOS(host_arch_ref.GetTriple().getOS());
+ if (m_triple.getEnvironment() == llvm::Triple::UnknownEnvironment)
+ m_triple.setEnvironment(host_arch_ref.GetTriple().getEnvironment());
+ }
+ else
+ {
+ Clear();
+ }
+
+
+ return IsValid();
+}
+
+bool
+ArchSpec::SetTriple (const char *triple_cstr)
+{
+ if (triple_cstr || triple_cstr[0])
+ {
+ llvm::StringRef triple_stref (triple_cstr);
+ if (triple_stref.startswith (LLDB_ARCH_DEFAULT))
+ {
+ // Special case for the current host default architectures...
+ if (triple_stref.equals (LLDB_ARCH_DEFAULT_32BIT))
+ *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
+ else if (triple_stref.equals (LLDB_ARCH_DEFAULT_64BIT))
+ *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture64);
+ else if (triple_stref.equals (LLDB_ARCH_DEFAULT))
+ *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
+ }
+ else
+ {
+ std::string normalized_triple_sstr (llvm::Triple::normalize(triple_stref));
+ triple_stref = normalized_triple_sstr;
+ SetTriple (llvm::Triple (triple_stref));
+ }
+ }
+ else
+ Clear();
+ return IsValid();
+}
+
+//bool
+//ArchSpec::SetArchitecture (const char *arch_name)
+//{
+// return SetArchitecture(llvm::StringRef (arch_name));
+//}
+//
+//bool
+//ArchSpec::SetArchitecture (const llvm::StringRef& arch_name)
+//{
+// // All default architecture names start with LLDB_ARCH_DEFAULT.
+// if (arch_name.startswith (LLDB_ARCH_DEFAULT))
+// {
+// // Special case for the current host default architectures...
+// if (arch_name.equals (LLDB_ARCH_DEFAULT_32BIT))
+// *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
+// else if (arch_name.equals (LLDB_ARCH_DEFAULT_64BIT))
+// *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture64);
+// else
+// *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
+// }
+// else
+// {
+// const CoreDefinition *core_def = FindCoreDefinition (arch_name);
+// if (core_def)
+// m_core = core_def->core;
+// CoreUpdated(true);
+// }
+// return IsValid();
+//}
+//
+bool
+ArchSpec::SetArchitecture (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub)
+{
+ m_core = kCore_invalid;
+ bool update_triple = true;
+ const ArchDefinition *arch_def = FindArchDefinition(arch_type);
+ if (arch_def)
+ {
+ const ArchDefinitionEntry *arch_def_entry = FindArchDefinitionEntry (arch_def, cpu, sub);
+ if (arch_def_entry)
+ {
+ const CoreDefinition *core_def = FindCoreDefinition (arch_def_entry->core);
+ if (core_def)
+ {
+ m_core = core_def->core;
+ update_triple = false;
+ m_triple.setArch (core_def->machine);
+ if (arch_type == eArchTypeMachO)
+ {
+ m_triple.setVendor (llvm::Triple::Apple);
+ m_triple.setOS (llvm::Triple::Darwin);
+ }
+ else
+ {
+ m_triple.setVendor (llvm::Triple::UnknownVendor);
+ m_triple.setOS (llvm::Triple::UnknownOS);
+ }
+ }
+ }
+ }
+ CoreUpdated(update_triple);
+ return IsValid();
+}
+
+void
+ArchSpec::SetByteOrder (lldb::ByteOrder byte_order)
+{
+ m_byte_order = byte_order;
+}
+
+//===----------------------------------------------------------------------===//
+// Helper methods.
+
+void
+ArchSpec::CoreUpdated (bool update_triple)
+{
+ const CoreDefinition *core_def = FindCoreDefinition (m_core);
+ if (core_def)
+ {
+ if (update_triple)
+ m_triple = llvm::Triple(core_def->name, "unknown", "unknown");
+ m_byte_order = core_def->default_byte_order;
+ }
+ else
+ {
+ if (update_triple)
+ m_triple = llvm::Triple();
+ m_byte_order = eByteOrderInvalid;
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// Operators.
+
bool
lldb_private::operator== (const ArchSpec& lhs, const ArchSpec& rhs)
{
- uint32_t lhs_cpu = lhs.GetCPUType();
- uint32_t rhs_cpu = rhs.GetCPUType();
+ const ArchSpec::Core lhs_core = lhs.GetCore ();
+ const ArchSpec::Core rhs_core = rhs.GetCore ();
- if (lhs_cpu == CPU_ANY || rhs_cpu == CPU_ANY)
+ if (lhs_core == rhs_core)
return true;
- else if (lhs_cpu == rhs_cpu)
+ if (lhs_core == ArchSpec::kCore_any || rhs_core == ArchSpec::kCore_any)
+ return true;
+
+ if (lhs_core == ArchSpec::kCore_arm_any)
{
- uint32_t lhs_subtype = lhs.GetCPUSubtype();
- uint32_t rhs_subtype = rhs.GetCPUSubtype();
- if (lhs_subtype == CPU_ANY || rhs_subtype == CPU_ANY)
+ if ((rhs_core >= ArchSpec::kCore_arm_first && rhs_core <= ArchSpec::kCore_arm_last) || (rhs_core == ArchSpec::kCore_arm_any))
return true;
- return lhs_subtype == rhs_subtype;
+ }
+ else if (rhs_core == ArchSpec::kCore_arm_any)
+ {
+ if ((lhs_core >= ArchSpec::kCore_arm_first && lhs_core <= ArchSpec::kCore_arm_last) || (lhs_core == ArchSpec::kCore_arm_any))
+ return true;
+ }
+ else if (lhs_core == ArchSpec::kCore_x86_32_any)
+ {
+ if ((rhs_core >= ArchSpec::kCore_x86_32_first && rhs_core <= ArchSpec::kCore_x86_32_last) || (rhs_core == ArchSpec::kCore_x86_32_any))
+ return true;
+ }
+ else if (rhs_core == ArchSpec::kCore_x86_32_any)
+ {
+ if ((lhs_core >= ArchSpec::kCore_x86_32_first && lhs_core <= ArchSpec::kCore_x86_32_last) || (lhs_core == ArchSpec::kCore_x86_32_any))
+ return true;
+ }
+ else if (lhs_core == ArchSpec::kCore_ppc_any)
+ {
+ if ((rhs_core >= ArchSpec::kCore_ppc_first && rhs_core <= ArchSpec::kCore_ppc_last) || (rhs_core == ArchSpec::kCore_ppc_any))
+ return true;
+ }
+ else if (rhs_core == ArchSpec::kCore_ppc_any)
+ {
+ if ((lhs_core >= ArchSpec::kCore_ppc_first && lhs_core <= ArchSpec::kCore_ppc_last) || (lhs_core == ArchSpec::kCore_ppc_any))
+ return true;
+ }
+ else if (lhs_core == ArchSpec::kCore_ppc64_any)
+ {
+ if ((rhs_core >= ArchSpec::kCore_ppc64_first && rhs_core <= ArchSpec::kCore_ppc64_last) || (rhs_core == ArchSpec::kCore_ppc64_any))
+ return true;
+ }
+ else if (rhs_core == ArchSpec::kCore_ppc64_any)
+ {
+ if ((lhs_core >= ArchSpec::kCore_ppc64_first && lhs_core <= ArchSpec::kCore_ppc64_last) || (lhs_core == ArchSpec::kCore_ppc64_any))
+ return true;
}
return false;
}
-
-//----------------------------------------------------------------------
-// Not Equal operator
-//----------------------------------------------------------------------
bool
lldb_private::operator!= (const ArchSpec& lhs, const ArchSpec& rhs)
{
return !(lhs == rhs);
}
-//----------------------------------------------------------------------
-// Less than operator
-//----------------------------------------------------------------------
bool
lldb_private::operator<(const ArchSpec& lhs, const ArchSpec& rhs)
{
- uint32_t lhs_cpu = lhs.GetCPUType();
- uint32_t rhs_cpu = rhs.GetCPUType();
-
- if (lhs_cpu == rhs_cpu)
- return lhs.GetCPUSubtype() < rhs.GetCPUSubtype();
-
- return lhs_cpu < rhs_cpu;
+ const ArchSpec::Core lhs_core = lhs.GetCore ();
+ const ArchSpec::Core rhs_core = rhs.GetCore ();
+ return lhs_core < rhs_core;
}
-
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index fbbab5b..28f589f 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -877,7 +877,7 @@
ArchSpec arch (target->GetArchitecture ());
if (arch.IsValid())
{
- s.PutCString (arch.AsCString());
+ s.PutCString (arch.GetArchitectureName());
var_success = true;
}
}
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index 994e510..2c5e34a 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -38,7 +38,7 @@
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"Disassembler::FindPlugin (arch = %s)",
- arch.AsCString());
+ arch.GetArchitectureName());
std::auto_ptr<Disassembler> disassembler_ap;
DisassemblerCreateInstance create_callback;
diff --git a/source/Core/Log.cpp b/source/Core/Log.cpp
index 49bd653..1b5c74a 100644
--- a/source/Core/Log.cpp
+++ b/source/Core/Log.cpp
@@ -87,13 +87,10 @@
{
static uint32_t g_sequence_id = 0;
StreamString header;
- static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive);
-
- Mutex::Locker locker;
-
- // Lock the threaded logging mutex if we are doing thread safe logging
- if (m_options.Test (LLDB_LOG_OPTION_THREADSAFE))
- locker.Reset(g_LogThreadedMutex.GetMutex());
+ // Enabling the thread safe logging actually deadlocks right now.
+ // Need to fix this at some point.
+// static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive);
+// Mutex::Locker locker (g_LogThreadedMutex);
// Add a sequence ID if requested
if (m_options.Test (LLDB_LOG_OPTION_PREPEND_SEQUENCE))
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 96cc4d7..a504829 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -42,7 +42,7 @@
if (log)
log->Printf ("%p Module::Module((%s) '%s/%s%s%s%s')",
this,
- m_arch.AsCString(),
+ m_arch.GetArchitectureName(),
m_file.GetDirectory().AsCString(""),
m_file.GetFilename().AsCString(""),
m_object_name.IsEmpty() ? "" : "(",
@@ -56,7 +56,7 @@
if (log)
log->Printf ("%p Module::~Module((%s) '%s/%s%s%s%s')",
this,
- m_arch.AsCString(),
+ m_arch.GetArchitectureName(),
m_file.GetDirectory().AsCString(""),
m_file.GetFilename().AsCString(""),
m_object_name.IsEmpty() ? "" : "(",
@@ -474,7 +474,7 @@
Mutex::Locker locker (m_mutex);
if (m_arch.IsValid())
- s->Printf("(%s) ", m_arch.AsCString());
+ s->Printf("(%s) ", m_arch.GetArchitectureName());
char path[PATH_MAX];
if (m_file.GetPath(path, sizeof(path)))
@@ -648,17 +648,11 @@
bool
Module::SetArchitecture (const ArchSpec &new_arch)
{
- if (m_arch == new_arch)
- return true;
- else if (!m_arch.IsValid())
+ if (!m_arch.IsValid())
{
m_arch = new_arch;
return true;
- }
- else
- {
- return false;
- }
-
+ }
+ return m_arch == new_arch;
}
diff --git a/source/Core/ModuleList.cpp b/source/Core/ModuleList.cpp
index 093878d..864634f 100644
--- a/source/Core/ModuleList.cpp
+++ b/source/Core/ModuleList.cpp
@@ -404,7 +404,7 @@
prefix_cstr ? prefix_cstr : "",
(uint32_t)std::distance (begin, pos),
uuid_cstr,
- module->GetArchitecture().AsCString(),
+ module->GetArchitecture().GetArchitectureName(),
module_file_spec.GetDirectory().GetCString(),
module_file_spec.GetFilename().GetCString());
}
@@ -521,7 +521,7 @@
const FileSpec &module_file_spec = module_ptr->GetFileSpec();
fprintf (stderr, "warning: module not in shared module list: %s (%s) \"%s/%s\"\n",
uuid_cstr,
- module_ptr->GetArchitecture().AsCString(),
+ module_ptr->GetArchitecture().GetArchitectureName(),
module_file_spec.GetDirectory().GetCString(),
module_file_spec.GetFilename().GetCString());
}
@@ -650,9 +650,9 @@
if (arch.IsValid())
{
if (uuid_cstr[0])
- error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s.\n", path, arch.AsCString(), uuid_cstr[0]);
+ error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s.\n", path, arch.GetArchitectureName(), uuid_cstr[0]);
else
- error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.\n", path, arch.AsCString());
+ error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.\n", path, arch.GetArchitectureName());
}
}
else
@@ -707,7 +707,7 @@
if (file_spec)
{
if (arch.IsValid())
- error.SetErrorStringWithFormat("Unable to open %s architecture in '%s'.\n", arch.AsCString(), path);
+ error.SetErrorStringWithFormat("Unable to open %s architecture in '%s'.\n", arch.GetArchitectureName(), path);
else
error.SetErrorStringWithFormat("Unable to open '%s'.\n", path);
}
@@ -721,7 +721,7 @@
if (uuid_cstr[0])
error.SetErrorStringWithFormat("Cannot locate a module for UUID '%s'.\n", uuid_cstr[0]);
else
- error.SetErrorStringWithFormat("Cannot locate a module.\n", path, arch.AsCString());
+ error.SetErrorStringWithFormat("Cannot locate a module.\n", path, arch.GetArchitectureName());
}
}
}
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 8f27c59..231924f 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -714,7 +714,7 @@
if (disassembler == NULL)
{
ret.SetErrorToGenericError();
- ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.AsCString());
+ ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.GetArchitectureName());
return ret;
}
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index 4c72e50..98e5b95 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -268,20 +268,20 @@
if (cputype & CPU_ARCH_ABI64)
{
// We have a 64 bit kernel on a 64 bit system
- g_host_arch_32.SetMachOArch (~(CPU_ARCH_MASK) & cputype, cpusubtype);
- g_host_arch_64.SetMachOArch (cputype, cpusubtype);
+ g_host_arch_32.SetArchitecture (lldb::eArchTypeMachO, ~(CPU_ARCH_MASK) & cputype, cpusubtype);
+ g_host_arch_64.SetArchitecture (lldb::eArchTypeMachO, cputype, cpusubtype);
}
else
{
// We have a 32 bit kernel on a 64 bit system
- g_host_arch_32.SetMachOArch (cputype, cpusubtype);
+ g_host_arch_32.SetArchitecture (lldb::eArchTypeMachO, cputype, cpusubtype);
cputype |= CPU_ARCH_ABI64;
- g_host_arch_64.SetMachOArch (cputype, cpusubtype);
+ g_host_arch_64.SetArchitecture (lldb::eArchTypeMachO, cputype, cpusubtype);
}
}
else
{
- g_host_arch_32.SetMachOArch (cputype, cpusubtype);
+ g_host_arch_32.SetArchitecture (lldb::eArchTypeMachO, cputype, cpusubtype);
g_host_arch_64.Clear();
}
}
@@ -293,23 +293,23 @@
{
#if defined (__x86_64__)
- g_host_arch_64.SetArch ("x86_64");
+ g_host_arch_64.SetTriple ("x86_64");
#elif defined (__i386__)
- g_host_arch_32.SetArch ("i386");
+ g_host_arch_32.SetTriple ("i386");
#elif defined (__arm__)
- g_host_arch_32.SetArch ("arm");
+ g_host_arch_32.SetTriple ("arm");
#elif defined (__ppc64__)
- g_host_arch_64.SetArch ("ppc64");
+ g_host_arch_64.SetTriple ("ppc64");
#elif defined (__powerpc__) || defined (__ppc__)
- g_host_arch_32.SetArch ("ppc");
+ g_host_arch_32.SetTriple ("ppc");
#else
@@ -377,7 +377,7 @@
{
StreamString triple;
triple.Printf("%s-%s-%s",
- GetArchitecture().AsCString(),
+ GetArchitecture().GetArchitectureName(),
GetVendorString().AsCString(),
GetOSString().AsCString());
@@ -1093,9 +1093,9 @@
if (error == 0)
return return_spec;
if (bsd_info.pbi_flags & PROC_FLAG_LP64)
- return_spec.SetArch(LLDB_ARCH_DEFAULT_64BIT);
+ return_spec.SetTriple (LLDB_ARCH_DEFAULT_64BIT);
else
- return_spec.SetArch(LLDB_ARCH_DEFAULT_32BIT);
+ return_spec.SetTriple (LLDB_ARCH_DEFAULT_32BIT);
#endif
return return_spec;
diff --git a/source/Host/macosx/Host.mm b/source/Host/macosx/Host.mm
index 552c7b3..e7df53d 100644
--- a/source/Host/macosx/Host.mm
+++ b/source/Host/macosx/Host.mm
@@ -279,7 +279,7 @@
if (arch_spec && arch_spec->IsValid())
{
- command_file.Printf("--arch=%s ", arch_spec->AsCString());
+ command_file.Printf("--arch=%s ", arch_spec->GetArchitectureName());
}
if (disable_aslr)
@@ -441,12 +441,12 @@
darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path));
if (arch_spec)
- command.Printf("arch -arch %s ", arch_spec->AsCString());
+ command.Printf("arch -arch %s ", arch_spec->GetArchitectureName());
command.Printf("'%s' --unix-socket=%s", launcher_path, unix_socket_name.c_str());
if (arch_spec && arch_spec->IsValid())
- command.Printf(" --arch=%s", arch_spec->AsCString());
+ command.Printf(" --arch=%s", arch_spec->GetArchitectureName());
if (working_dir)
command.Printf(" --working-dir '%s'", working_dir);
diff --git a/source/Host/macosx/Symbols.cpp b/source/Host/macosx/Symbols.cpp
index 7174849..7a32e08 100644
--- a/source/Host/macosx/Symbols.cpp
+++ b/source/Host/macosx/Symbols.cpp
@@ -433,7 +433,7 @@
Timer scoped_timer (__PRETTY_FUNCTION__,
"LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
- arch ? arch->AsCString() : "<NULL>",
+ arch ? arch->GetArchitectureName() : "<NULL>",
uuid);
FileSpec objfile_fspec;
@@ -450,7 +450,7 @@
Timer scoped_timer (__PRETTY_FUNCTION__,
"LocateExecutableSymbolFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
- arch ? arch->AsCString() : "<NULL>",
+ arch ? arch->GetArchitectureName() : "<NULL>",
uuid);
FileSpec symbol_fspec;
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index bc6bfd1..edecaa1 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -345,16 +345,12 @@
static inline EDAssemblySyntax_t
SyntaxForArchSpec (const ArchSpec &arch)
{
- switch (arch.GetGenericCPUType())
+ switch (arch.GetMachine ())
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
return kEDAssemblySyntaxX86ATT;
- case ArchSpec::eCPU_arm:
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
- case ArchSpec::eCPU_sparc:
default:
break;
}
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 491cdad..76a74bd 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -6814,7 +6814,7 @@
EmulateInstructionARM::SetArchitecture (const ArchSpec &arch)
{
m_arm_isa = 0;
- const char *arch_cstr = arch.AsCString ();
+ const char *arch_cstr = arch.GetArchitectureName ();
if (arch_cstr)
{
if (0 == ::strcasecmp(arch_cstr, "armv4t")) m_arm_isa = ARMv4T;
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index fb73083..7ff54c7 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -360,7 +360,7 @@
{
s->Indent();
GetArchitectureAtIndex(i, arch);
- s->Printf("arch[%u] = %s\n", arch.AsCString());
+ s->Printf("arch[%u] = %s\n", arch.GetArchitectureName());
}
for (i=0; i<num_objects; i++)
{
diff --git a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
index c2f8edc..7ff1943 100644
--- a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
+++ b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
@@ -168,7 +168,7 @@
{
s->Indent();
GetArchitectureAtIndex(i, arch);
- s->Printf("arch[%u] = %s\n", arch.AsCString());
+ s->Printf("arch[%u] = %s\n", arch.GetArchitectureName());
}
for (i=0; i<num_objects; i++)
{
@@ -190,7 +190,7 @@
{
if (idx < m_header.nfat_arch)
{
- arch.SetMachOArch (m_fat_archs[idx].cputype, m_fat_archs[idx].cpusubtype);
+ arch.SetArchitecture (lldb::eArchTypeMachO, m_fat_archs[idx].cputype, m_fat_archs[idx].cpusubtype);
return true;
}
return false;
@@ -207,7 +207,7 @@
{
arch = Target::GetDefaultArchitecture ();
if (!arch.IsValid())
- arch = LLDB_ARCH_DEFAULT;
+ arch.SetTriple (LLDB_ARCH_DEFAULT);
}
else
arch = m_module->GetArchitecture();
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 0739b97..445518d 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/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/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index ac536c5..deac894 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/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;
}
diff --git a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
index a218c1d..5141e4b 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
@@ -42,7 +42,11 @@
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/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp b/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
index 706f63a..a31713e 100644
--- a/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
+++ b/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 @@
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/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index e4be273..464500c 100644
--- a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -337,7 +337,9 @@
// 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 @@
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 @@
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 @@
// We don't need to do this for ARM, and we really shouldn't now that we
// have multiple CPU subtypes and no posix_spawnattr call that allows us
// to set which CPU subtype to launch...
- if (arch_spec.GetType() == eArchTypeMachO)
+ cpu_type_t cpu = arch_spec.GetMachOCPUType();
+ if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE)
{
- cpu_type_t cpu = arch_spec.GetCPUType();
- if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE)
- {
- size_t ocount = 0;
- err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
- if (err.Fail() || log)
- err.PutToLog(log.get(), "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
+ size_t ocount = 0;
+ err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
+ if (err.Fail() || log)
+ err.PutToLog(log.get(), "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
- if (err.Fail() != 0 || ocount != 1)
- return LLDB_INVALID_PROCESS_ID;
- }
+ if (err.Fail() != 0 || ocount != 1)
+ return LLDB_INVALID_PROCESS_ID;
}
#endif
diff --git a/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp b/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
index 6824b79..20e3ef7 100644
--- a/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
+++ b/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp
@@ -18,7 +18,7 @@
lldb_private::ArchDefaultUnwindPlan *
ArchDefaultUnwindPlan_x86_64::CreateInstance (const lldb_private::ArchSpec &arch)
{
- if (arch.GetGenericCPUType () == ArchSpec::eCPU_x86_64)
+ if (arch.GetMachine () == llvm::Triple::x86_64)
return new ArchDefaultUnwindPlan_x86_64 ();
return NULL;
}
@@ -126,7 +126,7 @@
lldb_private::ArchDefaultUnwindPlan *
ArchDefaultUnwindPlan_i386::CreateInstance (const lldb_private::ArchSpec &arch)
{
- if (arch.GetGenericCPUType () == ArchSpec::eCPU_i386)
+ if (arch.GetMachine () == llvm::Triple::x86)
return new ArchDefaultUnwindPlan_i386 ();
return NULL;
}
diff --git a/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp b/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
index 35a4bf9..19eda66 100644
--- a/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
+++ b/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
@@ -34,22 +34,20 @@
lldb_private::ArchVolatileRegs *
ArchVolatileRegs_x86::CreateInstance (const lldb_private::ArchSpec &arch)
{
- uint32_t cpu = arch.GetCPUType ();
- if (cpu != llvm::MachO::CPUTypeX86_64 && cpu != llvm::MachO::CPUTypeI386)
- return NULL;
-
- return new ArchVolatileRegs_x86 (cpu);
+ llvm::Triple::ArchType cpu = arch.GetMachine ();
+ if (cpu == llvm::Triple::x86 || cpu == llvm::Triple::x86_64)
+ return new ArchVolatileRegs_x86 (cpu);
+ return NULL;
}
-ArchVolatileRegs_x86::ArchVolatileRegs_x86(int cpu) :
- lldb_private::ArchVolatileRegs(),
- m_cpu(cpu),
- m_non_volatile_regs()
+ArchVolatileRegs_x86::ArchVolatileRegs_x86(llvm::Triple::ArchType cpu) :
+ lldb_private::ArchVolatileRegs(),
+ m_cpu(cpu),
+ m_non_volatile_regs()
{
}
void
-
ArchVolatileRegs_x86::initialize_regset(Thread& thread)
{
if (m_non_volatile_regs.size() > 0)
@@ -78,13 +76,14 @@
const char **names;
int namecount;
- if (m_cpu == llvm::MachO::CPUTypeX86_64)
+ if (m_cpu == llvm::Triple::x86_64)
{
names = x86_64_regnames;
namecount = sizeof (x86_64_regnames) / sizeof (char *);
}
else
{
+ assert (m_cpu == llvm::Triple::x86);
names = i386_regnames;
namecount = sizeof (i386_regnames) / sizeof (char *);
}
diff --git a/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h b/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h
index 97714b9..516f126 100644
--- a/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h
+++ b/source/Plugins/Process/Utility/ArchVolatileRegs-x86.h
@@ -11,6 +11,7 @@
#define liblldb_ArchVolatileRegs_x86_h_
#include "lldb/lldb-private.h"
+#include "lldb/Core/ArchSpec.h"
#include "lldb/Utility/ArchVolatileRegs.h"
#include <set>
@@ -62,11 +63,11 @@
EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command);
private:
- ArchVolatileRegs_x86(int cpu); // Call CreateInstance instead.
+ ArchVolatileRegs_x86(llvm::Triple::ArchType cpu); // Call CreateInstance instead.
void initialize_regset(lldb_private::Thread& thread);
- int m_cpu;
+ llvm::Triple::ArchType m_cpu;
std::set<int> m_non_volatile_regs;
};
diff --git a/source/Plugins/Process/Utility/StopInfoMachException.cpp b/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 2a47640..79cbde4 100644
--- a/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -30,7 +30,7 @@
{
if (m_description.empty() && m_value != 0)
{
- ArchSpec::CPU cpu = m_thread.GetProcess().GetTarget().GetArchitecture().GetGenericCPUType();
+ const llvm::Triple::ArchType cpu = m_thread.GetProcess().GetTarget().GetArchitecture().GetMachine();
const char *exc_desc = NULL;
const char *code_label = "code";
@@ -44,7 +44,7 @@
subcode_label = "address";
switch (cpu)
{
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
switch (m_exc_code)
{
case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
@@ -52,8 +52,8 @@
}
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (m_exc_code)
{
case 0x101: code_desc = "EXC_PPC_VM_PROT_READ"; break;
@@ -71,14 +71,14 @@
exc_desc = "EXC_BAD_INSTRUCTION";
switch (cpu)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
if (m_exc_code == 1)
code_desc = "EXC_I386_INVOP";
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (m_exc_code)
{
case 1: code_desc = "EXC_PPC_INVALID_SYSCALL"; break;
@@ -90,7 +90,7 @@
}
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
if (m_exc_code == 1)
code_desc = "EXC_ARM_UNDEFINED";
break;
@@ -104,8 +104,8 @@
exc_desc = "EXC_ARITHMETIC";
switch (cpu)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
switch (m_exc_code)
{
case 1: code_desc = "EXC_I386_DIV"; break;
@@ -119,8 +119,8 @@
}
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (m_exc_code)
{
case 1: code_desc = "EXC_PPC_OVERFLOW"; break;
@@ -157,8 +157,8 @@
exc_desc = "EXC_BREAKPOINT";
switch (cpu)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
switch (m_exc_code)
{
case 1: subcode_desc = "EXC_I386_SGL"; break;
@@ -166,15 +166,15 @@
}
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (m_exc_code)
{
case 1: subcode_desc = "EXC_PPC_BREAKPOINT"; break;
}
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
switch (m_exc_code)
{
case 1: subcode_desc = "EXC_ARM_BREAKPOINT"; break;
@@ -248,7 +248,7 @@
{
if (exc_type != 0)
{
- ArchSpec::CPU cpu = thread.GetProcess().GetTarget().GetArchitecture().GetGenericCPUType();
+ const llvm::Triple::ArchType cpu = thread.GetProcess().GetTarget().GetArchitecture().GetMachine();
switch (exc_type)
{
@@ -258,8 +258,8 @@
case 2: // EXC_BAD_INSTRUCTION
switch (cpu)
{
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
switch (exc_code)
{
case 1: // EXC_PPC_INVALID_SYSCALL
@@ -293,8 +293,8 @@
bool is_software_breakpoint = false;
switch (cpu)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
if (exc_code == 1) // EXC_I386_SGL
{
return StopInfo::CreateStopReasonToTrace(thread);
@@ -305,12 +305,12 @@
}
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
is_software_breakpoint = exc_code == 1; // EXC_PPC_BREAKPOINT
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
is_software_breakpoint = exc_code == 1; // EXC_ARM_BREAKPOINT
break;
diff --git a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
index 94b3ae1..8f0f7d4 100644
--- a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
+++ b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp
@@ -847,11 +847,12 @@
UnwindAssemblyProfiler *
UnwindAssemblyProfiler_x86::CreateInstance (const ArchSpec &arch)
{
- ArchSpec::CPU cpu = arch.GetGenericCPUType ();
- if (cpu != ArchSpec::eCPU_x86_64 && cpu != ArchSpec::eCPU_i386)
- return NULL;
-
- return new UnwindAssemblyProfiler_x86 (cpu == ArchSpec::eCPU_x86_64 ? k_x86_64 : k_i386);
+ const llvm::Triple::ArchType cpu = arch.GetMachine ();
+ if (cpu == llvm::Triple::x86)
+ return new UnwindAssemblyProfiler_x86 (k_i386);
+ else if (cpu == llvm::Triple::x86_64)
+ return new UnwindAssemblyProfiler_x86 (k_x86_64);
+ return NULL;
}
diff --git a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
index 2d9e021..f712fd9 100644
--- a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
+++ b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
@@ -32,12 +32,12 @@
{
if (m_cursors.empty())
{
- const ArchSpec target_arch (m_thread.GetProcess().GetTarget().GetArchitecture ());
+ const ArchSpec& target_arch = m_thread.GetProcess().GetTarget().GetArchitecture ();
// Frame zero should always be supplied by the thread...
StackFrameSP frame_sp (m_thread.GetStackFrameAtIndex (0));
- if (target_arch == ArchSpec("x86_64"))
+ if (target_arch.GetMachine() == llvm::Triple::x86_64)
GetStackFrameData_x86_64 (frame_sp.get());
- else if (target_arch == ArchSpec("i386"))
+ else if (target_arch.GetMachine() == llvm::Triple::x86)
GetStackFrameData_i386 (frame_sp.get());
}
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index e23be43..126b60f 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1001,7 +1001,7 @@
}
if (cpu != LLDB_INVALID_CPUTYPE)
- m_arch.SetMachOArch (cpu, sub);
+ m_arch.SetArchitecture (lldb::eArchTypeMachO, cpu, sub);
}
}
return m_supports_qHostInfo == eLazyBoolYes;
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index df3e09a..34eca44 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -328,8 +328,7 @@
// We didn't get anything. See if we are debugging ARM and fill with
// a hard coded register set until we can get an updated debugserver
// down on the devices.
- ArchSpec arm_arch ("arm");
- if (GetTarget().GetArchitecture() == arm_arch)
+ if (GetTarget().GetArchitecture().GetMachine() == llvm::Triple::arm)
m_register_info.HardcodeARMRegisters();
}
m_register_info.Finalize ();
@@ -553,7 +552,9 @@
{
// Set our user ID to an invalid process ID.
SetID(LLDB_INVALID_PROCESS_ID);
- error.SetErrorStringWithFormat("Failed to get object file from '%s' for arch %s.\n", module->GetFileSpec().GetFilename().AsCString(), module->GetArchitecture().AsCString());
+ error.SetErrorStringWithFormat("Failed to get object file from '%s' for arch %s.\n",
+ module->GetFileSpec().GetFilename().AsCString(),
+ module->GetArchitecture().GetArchitectureName());
}
return error;
@@ -642,8 +643,8 @@
// it has, so we really need to take the remote host architecture as our
// defacto architecture in this case.
- if (gdb_remote_arch == ArchSpec ("arm") &&
- vendor && ::strcmp(vendor, "apple") == 0)
+ if (gdb_remote_arch.GetMachine() == llvm::Triple::arm &&
+ gdb_remote_arch.GetTriple().getVendor() == llvm::Triple::Apple)
{
GetTarget().SetArchitecture (gdb_remote_arch);
target_arch = gdb_remote_arch;
@@ -1044,16 +1045,16 @@
static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
- ArchSpec::CPU arch_cpu = GetTarget().GetArchitecture().GetGenericCPUType();
- switch (arch_cpu)
+ const llvm::Triple::ArchType machine = GetTarget().GetArchitecture().GetMachine();
+ switch (machine)
{
- case ArchSpec::eCPU_i386:
- case ArchSpec::eCPU_x86_64:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
trap_opcode = g_i386_breakpoint_opcode;
trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
break;
- case ArchSpec::eCPU_arm:
+ case llvm::Triple::arm:
// TODO: fill this in for ARM. We need to dig up the symbol for
// the address in the breakpoint locaiton and figure out if it is
// an ARM or Thumb breakpoint.
@@ -1061,8 +1062,8 @@
trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
break;
- case ArchSpec::eCPU_ppc:
- case ArchSpec::eCPU_ppc64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
trap_opcode = g_ppc_breakpoint_opcode;
trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
break;
@@ -1955,31 +1956,33 @@
Error local_err; // Errors that don't affect the spawning.
if (log)
- log->Printf ("%s ( path='%s', argv=%p, envp=%p, arch=%s )", __FUNCTION__, debugserver_path, inferior_argv, inferior_envp, inferior_arch.AsCString());
+ log->Printf ("%s ( path='%s', argv=%p, envp=%p, arch=%s )",
+ __FUNCTION__,
+ debugserver_path,
+ inferior_argv,
+ inferior_envp,
+ inferior_arch.GetArchitectureName());
error.SetError( ::posix_spawnattr_init (&attr), eErrorTypePOSIX);
if (error.Fail() || log)
error.PutToLog(log.get(), "::posix_spawnattr_init ( &attr )");
if (error.Fail())
- return error;;
+ return error;
#if !defined (__arm__)
// We don't need to do this for ARM, and we really shouldn't now
// that we have multiple CPU subtypes and no posix_spawnattr call
// that allows us to set which CPU subtype to launch...
- if (inferior_arch.GetType() == eArchTypeMachO)
+ cpu_type_t cpu = inferior_arch.GetMachOCPUType();
+ if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE)
{
- cpu_type_t cpu = inferior_arch.GetCPUType();
- if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE)
- {
- size_t ocount = 0;
- error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
- if (error.Fail() || log)
- error.PutToLog(log.get(), "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
-
- if (error.Fail() != 0 || ocount != 1)
- return error;
- }
+ size_t ocount = 0;
+ error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
+ if (error.Fail() || log)
+ error.PutToLog(log.get(), "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount);
+
+ if (error.Fail() != 0 || ocount != 1)
+ return error;
}
#endif
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 635c00c..99ce588 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -142,7 +142,8 @@
if (m_unwinder_ap.get() == NULL)
{
const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ());
- if (target_arch == ArchSpec("x86_64") || target_arch == ArchSpec("i386"))
+ const llvm::Triple::ArchType machine = target_arch.GetMachine();
+ if (machine == llvm::Triple::x86_64 || machine == llvm::Triple::x86)
{
m_unwinder_ap.reset (new UnwindLLDB (*this));
}
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index 9b7f205..3a775b0 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -182,7 +182,7 @@
module_sp->GetFileSpec().Dump(s);
*s << '"';
if (module_sp->GetArchitecture().IsValid())
- s->Printf (", arch = \"%s\"", module_sp->GetArchitecture().AsCString());
+ s->Printf (", arch = \"%s\"", module_sp->GetArchitecture().GetArchitectureName());
s->EOL();
}
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 3ce42d8..e1e73c2 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -801,28 +801,20 @@
ArchSpec
Target::GetDefaultArchitecture ()
{
- lldb::UserSettingsControllerSP &settings_controller = GetSettingsController();
- lldb::SettableVariableType var_type;
- Error err;
- StringList result = settings_controller->GetVariable ("target.default-arch", var_type, "[]", err);
-
- const char *default_name = "";
- if (result.GetSize() == 1 && err.Success())
- default_name = result.GetStringAtIndex (0);
-
- ArchSpec default_arch (default_name);
- return default_arch;
+ lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController());
+
+ if (settings_controller_sp)
+ return static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture ();
+ return ArchSpec();
}
void
-Target::SetDefaultArchitecture (ArchSpec new_arch)
+Target::SetDefaultArchitecture (const ArchSpec& arch)
{
- if (new_arch.IsValid())
- GetSettingsController ()->SetVariable ("target.default-arch",
- new_arch.AsCString(),
- lldb::eVarSetOperationAssign,
- false,
- "[]");
+ lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController());
+
+ if (settings_controller_sp)
+ static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture () = arch;
}
Target *
@@ -854,7 +846,7 @@
{
sstr.Printf ("%s_%s",
module_sp->GetFileSpec().GetFilename().AsCString(),
- module_sp->GetArchitecture().AsCString());
+ module_sp->GetArchitecture().GetArchitectureName());
GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(),
sstr.GetData());
}
@@ -1053,11 +1045,9 @@
{
if (var_name == GetSettingNameForDefaultArch())
{
- ArchSpec tmp_spec (value);
- if (tmp_spec.IsValid())
- m_default_architecture = tmp_spec;
- else
- err.SetErrorStringWithFormat ("'%s' is not a valid architecture.", value);
+ m_default_architecture.SetTriple (value);
+ if (!m_default_architecture.IsValid())
+ err.SetErrorStringWithFormat ("'%s' is not a valid architecture or triple.", value);
}
return true;
}
@@ -1072,7 +1062,7 @@
{
// If the arch is invalid (the default), don't show a string for it
if (m_default_architecture.IsValid())
- value.AppendString (m_default_architecture.AsCString());
+ value.AppendString (m_default_architecture.GetArchitectureName());
return true;
}
else
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index cbbb12f..af681d2 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -58,7 +58,7 @@
"TargetList::CreateTarget (file = '%s/%s', arch = '%s', uuid = %p)",
file.GetDirectory().AsCString(),
file.GetFilename().AsCString(),
- arch.AsCString(),
+ arch.GetArchitectureName(),
uuid_ptr);
Error error;
@@ -96,7 +96,7 @@
file.GetDirectory().AsCString(),
file.GetDirectory() ? "/" : "",
file.GetFilename().AsCString(),
- arch.AsCString());
+ arch.GetArchitectureName());
}
else
{
diff --git a/test/dotest.py b/test/dotest.py
index d36a5fe..77ee47d 100755
--- a/test/dotest.py
+++ b/test/dotest.py
@@ -629,7 +629,7 @@
else:
lldb_log_option = "event process expr state api"
ci.HandleCommand(
- "log enable -T -n -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option,
+ "log enable -n -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option,
res)
if not res.Succeeded():
raise Exception('log enable failed (check LLDB_LOG env variable.')
@@ -641,7 +641,7 @@
else:
gdb_remote_log_option = "packets process"
ci.HandleCommand(
- "log enable -T -n -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote "
+ "log enable -n -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote "
+ gdb_remote_log_option,
res)
if not res.Succeeded():