From 69177f7fa6b9feae87ab658411270f26924a4ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 2 Nov 2024 22:30:28 +0100 Subject: [PATCH] Same with Step Out --- Core/Core.cpp | 28 ++++++++++++++++++++++++++ Windows/Debugger/Debugger_Disasm.cpp | 30 +++------------------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index 14675816dc..1a604f2241 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -282,6 +282,34 @@ u32 Core_PerformStep(DebugInterface *cpu, CPUStepType stepType, int stepSize) { Core_Resume(); return breakpointAddress; } + case CPUStepType::Out: + { + u32 entry = cpu->GetPC(); + u32 stackTop = 0; + + auto threads = GetThreadsInfo(); + for (size_t i = 0; i < threads.size(); i++) { + if (threads[i].isCurrent) { + entry = threads[i].entrypoint; + stackTop = threads[i].initialStack; + break; + } + } + + auto frames = MIPSStackWalk::Walk(cpu->GetPC(), cpu->GetRegValue(0, 31), cpu->GetRegValue(0, 29), entry, stackTop); + if (frames.size() < 2) { + // Failure. PC not moving. + return cpu->GetPC(); + } + + u32 breakpointAddress = frames[1].pc; + + // If the current PC is on a breakpoint, the user doesn't want to do nothing. + CBreakPoints::SetSkipFirst(currentMIPS->pc); + CBreakPoints::AddBreakPoint(breakpointAddress, true); + Core_Resume(); + return breakpointAddress; + } default: // Not yet implemented return cpu->GetPC(); diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 5de02755ce..8ede3386f5 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -246,36 +246,12 @@ void CDisasm::stepOut() { if (!PSP_IsInited()) return; - - u32 entry = cpu->GetPC(); - u32 stackTop = 0; - - auto threads = GetThreadsInfo(); - for (size_t i = 0; i < threads.size(); i++) { - if (threads[i].isCurrent) { - entry = threads[i].entrypoint; - stackTop = threads[i].initialStack; - break; - } - } - - auto frames = MIPSStackWalk::Walk(cpu->GetPC(), cpu->GetRegValue(0,31), cpu->GetRegValue(0,29), entry, stackTop); - if (frames.size() < 2) { - // Failure - return; - } - - u32 breakpointAddress = frames[1].pc; - lastTicks_ = CoreTiming::GetTicks(); - - // If the current PC is on a breakpoint, the user doesn't want to do nothing. - CBreakPoints::SetSkipFirst(currentMIPS->pc); - CtrlDisAsmView *ptr = DisAsmView(); ptr->setDontRedraw(true); + lastTicks_ = CoreTiming::GetTicks(); + + u32 breakpointAddress = Core_PerformStep(cpu, CPUStepType::Out, 0); - CBreakPoints::AddBreakPoint(breakpointAddress,true); - Core_Resume(); Sleep(1); ptr->gotoAddr(breakpointAddress); UpdateDialog();