Merge pull request #5238 from sepalani/ppc-analyst-rfi

PPCAnalyst: Support return from interrupt
This commit is contained in:
Anthony 2017-04-29 12:44:18 -07:00 committed by GitHub
commit 4d3a794942
1 changed files with 9 additions and 9 deletions

View File

@ -67,12 +67,11 @@ static u32 EvaluateBranchTarget(UGeckoInstruction instr, u32 pc)
}
// To find the size of each found function, scan
// forward until we hit blr. In the meantime, collect information
// forward until we hit blr or rfi. In the meantime, collect information
// about which functions this function calls.
// Also collect which internal branch goes the farthest
// If any one goes farther than the blr, assume that there is more than
// one blr, and keep scanning.
// Also collect which internal branch goes the farthest.
// If any one goes farther than the blr or rfi, assume that there is more than
// one blr or rfi, and keep scanning.
bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
{
if (!func.name.size())
@ -107,9 +106,10 @@ bool AnalyzeFunction(u32 startAddr, Symbol& func, int max_size)
const UGeckoInstruction instr = read_result.hex;
if (read_result.valid && PPCTables::IsValidInstruction(instr))
{
if (instr.hex == 0x4e800020) // 4e800021 is blrl, not the end of a function
// BLR or RFI
// 4e800021 is blrl, not the end of a function
if (instr.hex == 0x4e800020 || instr.hex == 0x4C000064)
{
// BLR
if (farthestInternalBranchTarget > addr)
{
// bah, not this one, continue..
@ -300,7 +300,7 @@ static void FindFunctionsFromBranches(u32 startAddr, u32 endAddr, SymbolDB* func
}
}
static void FindFunctionsAfterBLR(PPCSymbolDB* func_db)
static void FindFunctionsAfterReturnInstruction(PPCSymbolDB* func_db)
{
std::vector<u32> funcAddrs;
@ -340,7 +340,7 @@ void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db)
{
// Step 1: Find all functions
FindFunctionsFromBranches(startAddr, endAddr, func_db);
FindFunctionsAfterBLR(func_db);
FindFunctionsAfterReturnInstruction(func_db);
// Step 2:
func_db->FillInCallers();