From b71bfe5a621a25d440d264fd3b09693305dbd2f9 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Mon, 25 Nov 2013 21:53:01 +0100 Subject: [PATCH] -Get branch lines for opcodes outside of a function -fix labels causing analyzing issues --- Core/Debugger/DisassemblyManager.cpp | 31 ++++++++++++++++++++++++++-- Core/Debugger/DisassemblyManager.h | 1 + 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index ca9a9d1d62..16242c2f1f 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -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& 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) { diff --git a/Core/Debugger/DisassemblyManager.h b/Core/Debugger/DisassemblyManager.h index 8eeefa5712..94b5f97efc 100644 --- a/Core/Debugger/DisassemblyManager.h +++ b/Core/Debugger/DisassemblyManager.h @@ -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& dest); private: u32 address; int num;