ARM: Show branch targets relative to the nearest symbol.

This commit is contained in:
Gabe Black 2009-06-27 00:29:30 -07:00
parent a4ac3fad7a
commit 56f1845471
3 changed files with 25 additions and 6 deletions

View 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();
}

View 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

View 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;
};