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

Johnny Chen johnny.chen at apple.com
Mon May 23 12:41:31 PDT 2011


Author: johnny
Date: Mon May 23 14:41:31 2011
New Revision: 131913

URL: http://llvm.org/viewvc/llvm-project?rev=131913&view=rev
Log:
Add more workarounds for "bl #..." and "blx #..." where the ARMAsmParser fails to parse/recognize
the (PC-relative) immediate operand.

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=131913&r1=131912&r2=131913&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon May 23 14:41:31 2011
@@ -328,6 +328,7 @@
             if (m_arch_type == llvm::Triple::thumb && opcode.GetString() == "b") {
                 const char *inst_str;
                 const char *pos = NULL;
+                operands.Clear(); comment.Clear();
                 if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) {
                     uint64_t operand_value = PC + atoi(++pos);
                     operands.Printf("0x%llx ", operand_value);
@@ -345,6 +346,33 @@
                     }
                 }
             }
+            // Yet more workaround for "bl #..." and "blx #...".
+            if ((m_arch_type == llvm::Triple::arm || m_arch_type == llvm::Triple::thumb) &&
+                (opcode.GetString() == "bl" || opcode.GetString() == "blx")) {
+                const char *inst_str;
+                const char *pos = NULL;
+                operands.Clear(); comment.Clear();
+                if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) {
+                    uint64_t operand_value = PC + atoi(++pos);
+                    // Put the address value into the comment
+                    comment.Printf("0x%llx ", operand_value);
+                    llvm::StringRef string_ref(pos - 1);
+                    llvm::StringRef operand_string_ref = string_ref.split('\n').first;
+                    operands.PutCString(operand_string_ref.str().c_str());
+
+                    lldb_private::Address so_addr;
+                    if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) {
+                        if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr))
+                            so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset);
+                    } else {
+                        Module *module = GetAddress().GetModule();
+                        if (module) {
+                            if (module->ResolveFileAddress (operand_value, so_addr))
+                                so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset);
+                        }
+                    }
+                }
+            }
             // END of workaround.
 
             // If both operands and comment are empty, we will just print out





More information about the lldb-commits mailing list