-Get branch lines for opcodes outside of a function

-fix labels causing analyzing issues
This commit is contained in:
Kingcom 2013-11-25 21:53:01 +01:00
parent 8146e7bfb0
commit b71bfe5a62
2 changed files with 30 additions and 2 deletions

View File

@ -139,13 +139,13 @@ void DisassemblyManager::analyze(u32 address, u32 size = 1024)
}
SymbolInfo info;
if (symbolMap.GetSymbolInfo(&info,address))
if (symbolMap.GetSymbolInfo(&info,address) && info.size >= 4)
{
DisassemblyFunction* function = new DisassemblyFunction(info.address,info.size);
entries[info.address] = function;
address = info.address+info.size;
} else {
u32 next = symbolMap.GetNextSymbolAddress(address);
u32 next = symbolMap.GetNextSymbolAddress(address+1);
// let's just assume anything otuside a function is a normal opcode
DisassemblyOpcode* opcode = new DisassemblyOpcode(address,(next-address)/4);
@ -558,6 +558,33 @@ bool DisassemblyOpcode::disassemble(u32 address, DisassemblyLineInfo& dest, bool
return true;
}
void DisassemblyOpcode::getBranchLines(u32 start, u32 size, std::vector<BranchLine>& dest)
{
int lane = 0;
for (u32 pos = start; pos < start+size; pos += 4)
{
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(DisassemblyManager::getCpu(),pos);
if (info.isBranch && !info.isBranchToRegister && !info.isLinkedBranch)
{
BranchLine line;
line.laneIndex = lane++;
if (info.branchTarget < pos)
{
line.first = info.branchTarget;
line.second = pos;
line.type = LINE_UP;
} else {
line.first = pos;
line.second = info.branchTarget;
line.type = LINE_DOWN;
}
dest.push_back(line);
}
}
}
void DisassemblyMacro::setMacroLi(u32 _immediate, u8 _rt)
{

View File

@ -94,6 +94,7 @@ public:
virtual u32 getLineAddress(int line) { return address+line*4; };
virtual u32 getTotalSize() { return num*4; };
virtual bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols);
virtual void getBranchLines(u32 start, u32 size, std::vector<BranchLine>& dest);
private:
u32 address;
int num;