[Lldb-commits] [lldb] r131910 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp

Johnny Chen johnny.chen at apple.com
Mon May 23 11:00:40 PDT 2011


Author: johnny
Date: Mon May 23 13:00:40 2011
New Revision: 131910

URL: http://llvm.org/viewvc/llvm-project?rev=131910&view=rev
Log:
Fix the Align() utility which tries to align the raw disassembly with the edis'ed disassembly
so that both the opcode and the operands are aligned with the rest of output.

Comment out the code related to force_raw mode when disassembling arm or thumb for now.
It testing goes ok, we will remove the section of code related to force_raw.

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

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=131910&r1=131909&r2=131910&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon May 23 13:00:40 2011
@@ -109,11 +109,15 @@
         Str = Str.substr(0, Str.size()-1);
 }
 static void
-Align(Stream *s, const char *str)
+Align(Stream *s, const char *str, size_t opcodeColWidth, size_t operandColWidth)
 {
     llvm::StringRef raw_disasm(str);
     StripSpaces(raw_disasm);
-    s->PutCString(raw_disasm.str().c_str());    
+    // Split the raw disassembly into opcode and operands.
+    std::pair<llvm::StringRef, llvm::StringRef> p = raw_disasm.split('\t');
+    PadString(s, p.first, opcodeColWidth);
+    if (!p.second.empty())
+        PadString(s, p.second, operandColWidth);
 }
 
 void
@@ -173,10 +177,12 @@
     
     // 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 = force_raw;
+    */
     /* .... when we fix the edis for arm/thumb. */
 
     if (!raw)
@@ -349,7 +355,7 @@
 
                 if (EDGetInstString(&str, m_inst))
                     return;
-                Align(s, str);
+                Align(s, str, opcodeColumnWidth, operandColumnWidth);
             }
             else
             {
@@ -380,7 +386,7 @@
         {
             // EDis fails to parse the tokens of this inst.  Need to align this
             // raw disassembly's opcode with the rest of output.
-            Align(s, str);
+            Align(s, str, opcodeColumnWidth, operandColumnWidth);
         }
     }
 }





More information about the lldb-commits mailing list