ARM: Show branch targets relative to the nearest symbol.
authorGabe Black <gblack@eecs.umich.edu>
Sat, 27 Jun 2009 07:29:30 +0000 (00:29 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Sat, 27 Jun 2009 07:29:30 +0000 (00:29 -0700)
src/arch/arm/insts/branch.cc
src/arch/arm/insts/static_inst.cc
src/arch/arm/insts/static_inst.hh

index 39ad041c8025d55e92268cf183588653bf5c238f..3deb380f8dc06bf12169e05ac3dec20d4910566c 100644 (file)
@@ -71,14 +71,11 @@ Branch::generateDisassembly(Addr pc, const SymbolTable *symtab) const
     std::stringstream ss;
 
     printMnemonic(ss);
+    ss << "\t";
 
     Addr target = pc + 8 + disp;
-
-    std::string str;
-    if (symtab && symtab->findSymbol(target, str))
-        ss << str;
-    else
-        ccprintf(ss, "0x%x", target);
+    ccprintf(ss, "%#x", target);
+    printMemSymbol(ss, symtab, " <", target, ">");
 
     return ss.str();
 }
index 6b641d8bb4f380351c1d9413e11e636b24bd5ba0..a76dbd69cbf7ab19ef3dddedf703a810957f4fda 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "arch/arm/insts/static_inst.hh"
 #include "base/condcodes.hh"
+#include "base/loader/symtab.hh"
 
 namespace ArmISA
 {
@@ -309,6 +310,23 @@ ArmStaticInst::printMnemonic(std::ostream &os,
     }
 }
 
+void
+ArmStaticInst::printMemSymbol(std::ostream &os,
+                              const SymbolTable *symtab,
+                              const std::string &prefix,
+                              const Addr addr,
+                              const std::string &suffix) const
+{
+    Addr symbolAddr;
+    std::string symbol;
+    if (symtab && symtab->findNearestSymbol(addr, symbol, symbolAddr)) {
+        ccprintf(os, "%s%s", prefix, symbol);
+        if (symbolAddr != addr)
+            ccprintf(os, "+%d", addr - symbolAddr);
+        ccprintf(os, suffix);
+    }
+}
+
 std::string
 ArmStaticInst::generateDisassembly(Addr pc,
                                    const SymbolTable *symtab) const
index ca4cb0f642d416604233c41fc8bf2cc889932696..6b745352edb50f79764c0d3e9600d71ea43f451b 100644 (file)
@@ -65,6 +65,10 @@ class ArmStaticInst : public StaticInst
     void printMnemonic(std::ostream &os,
                        const std::string &suffix = "",
                        bool withPred = true) const;
+    void printMemSymbol(std::ostream &os, const SymbolTable *symtab,
+                        const std::string &prefix, const Addr addr,
+                        const std::string &suffix) const;
+
 
     std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
 };