[Lldb-commits] [lldb] r131256 - in /lldb/trunk/source/Plugins/Disassembler/llvm: DisassemblerLLVM.cpp DisassemblerLLVM.h

Johnny Chen johnny.chen at apple.com
Thu May 12 15:25:54 PDT 2011


Author: johnny
Date: Thu May 12 17:25:53 2011
New Revision: 131256

URL: http://llvm.org/viewvc/llvm-project?rev=131256&view=rev
Log:
Fix the InstructionLLVM::Dump() so that for Triple::arm, PC reads as the address
of the current instruction plus 8.  And for Triple::thumb, it is plus 4.

rdar://problem/9170971
lldb disassembly's symbol information not correct (off by 2?)

Modified:
    lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
    lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h

Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131256&r1=131255&r2=131256&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Thu May 12 17:25:53 2011
@@ -77,10 +77,10 @@
 InstructionLLVM::InstructionLLVM (const Address &addr, 
                                   AddressClass addr_class,
                                   EDDisassemblerRef disassembler,
-                                  bool force_raw) :
+                                  llvm::Triple::ArchType arch_type) :
     Instruction (addr, addr_class),
     m_disassembler (disassembler),
-    m_force_raw (force_raw)
+    m_arch_type (arch_type)
 {
 }
 
@@ -154,8 +154,13 @@
 
     int numTokens = -1;
     
+    // FIXME!!!
+    /* Remove the following section of code related to force_raw .... */
+    bool force_raw = m_arch_type == llvm::Triple::arm ||
+                     m_arch_type == llvm::Triple::thumb;
     if (!raw)
-        raw = m_force_raw;
+        raw = force_raw;
+    /* .... when we fix the edis for arm/thumb. */
 
     if (!raw)
         numTokens = EDNumTokens(m_inst);
@@ -173,7 +178,16 @@
         if (base_addr == LLDB_INVALID_ADDRESS)
             base_addr = GetAddress().GetFileAddress ();
                     
-        RegisterReaderArg rra(base_addr + EDInstByteSize(m_inst), m_disassembler);
+        lldb::addr_t PC = base_addr + EDInstByteSize(m_inst);
+
+        // When executing an ARM instruction, PC reads as the address of the
+        // current instruction plus 8.  And for Thumb, it is plus 4.
+        if (m_arch_type == llvm::Triple::arm)
+          PC = base_addr + 8;
+        else if (m_arch_type == llvm::Triple::thumb)
+          PC = base_addr + 4;
+
+        RegisterReaderArg rra(PC, m_disassembler);
         
         printTokenized = true;
 
@@ -488,20 +502,11 @@
             if (inst_address_class == eAddressClassCodeAlternateISA)
                 use_thumb = true;
         }
-        bool force_raw = false;
-        switch (m_arch.GetMachine())
-        {
-            case llvm::Triple::arm:
-            case llvm::Triple::thumb:
-                force_raw = true;
-                break;
-            default:
-                break;
-        }
+        
         InstructionSP inst_sp (new InstructionLLVM (inst_addr, 
                                                     inst_address_class,
                                                     use_thumb ? m_disassembler_thumb : m_disassembler,
-                                                    force_raw));
+                                                    m_arch.GetMachine()));
 
         size_t inst_byte_size = inst_sp->Decode (*this, data, data_offset);
 

Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=131256&r1=131255&r2=131256&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Thu May 12 17:25:53 2011
@@ -22,7 +22,7 @@
     InstructionLLVM (const lldb_private::Address &addr,
                      lldb_private::AddressClass addr_class,
                      EDDisassemblerRef disassembler,
-                     bool force_raw);
+                     llvm::Triple::ArchType arch_type);
     
     virtual
     ~InstructionLLVM();
@@ -46,7 +46,7 @@
 protected:
     EDDisassemblerRef m_disassembler;
     EDInstRef m_inst;
-    bool m_force_raw;
+    llvm::Triple::ArchType m_arch_type;
 };
 
 





More information about the lldb-commits mailing list