[Lldb-commits] [lldb] r228486 - When creating a disassembler for one of the arm variants that can

Jason Molenda jmolenda at apple.com
Fri Feb 6 22:03:49 PST 2015


Author: jmolenda
Date: Sat Feb  7 00:03:49 2015
New Revision: 228486

URL: http://llvm.org/viewvc/llvm-project?rev=228486&view=rev
Log:
When creating a disassembler for one of the arm variants that can
only execute thumb instructions, force the arch triple string to
be "thumbv..." instead of "armv..." so we do the right thing by
default when disassembling arbitrary chunks of code.
<rdar://problem/15126397> 

Modified:
    lldb/trunk/include/lldb/Core/Disassembler.h
    lldb/trunk/source/Core/Disassembler.cpp

Modified: lldb/trunk/include/lldb/Core/Disassembler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=228486&r1=228485&r2=228486&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Disassembler.h (original)
+++ lldb/trunk/include/lldb/Core/Disassembler.h Sat Feb  7 00:03:49 2015
@@ -457,7 +457,7 @@ protected:
     //------------------------------------------------------------------
     // Classes that inherit from Disassembler can see and modify these
     //------------------------------------------------------------------
-    const ArchSpec m_arch;
+    ArchSpec m_arch;
     InstructionList m_instruction_list;
     lldb::addr_t m_base_addr;
     std::string m_flavor;

Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=228486&r1=228485&r2=228486&view=diff
==============================================================================
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Sat Feb  7 00:03:49 2015
@@ -1172,6 +1172,24 @@ Disassembler::Disassembler(const ArchSpe
         m_flavor.assign("default");
     else
         m_flavor.assign(flavor);
+
+    // If this is an arm variant that can only include thumb (T16, T32)
+    // instructions, force the arch triple to be "thumbv.." instead of
+    // "armv..."
+    if (arch.GetTriple().getArch() == llvm::Triple::arm
+        && (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
+            || arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em
+            || arch.GetCore() == ArchSpec::Core::eCore_arm_armv6m))
+    {
+        std::string thumb_arch_name (arch.GetTriple().getArchName().str());
+        // Replace "arm" with "thumb" so we get all thumb variants correct
+        if (thumb_arch_name.size() > 3)
+        {
+            thumb_arch_name.erase(0, 3);
+            thumb_arch_name.insert(0, "thumb");
+        }
+        m_arch.SetTriple (thumb_arch_name.c_str());
+    }
 }
 
 //----------------------------------------------------------------------





More information about the lldb-commits mailing list