diff --git a/Core/Core.cpp b/Core/Core.cpp index 76ebd19689..bbb372291c 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -56,7 +56,6 @@ static std::mutex g_stepMutex; struct CPUStepCommand { CPUStepType type; - int stepSize; BreakReason reason; u32 relatedAddr; bool empty() const { @@ -64,7 +63,6 @@ struct CPUStepCommand { } void clear() { type = CPUStepType::None; - stepSize = 0; // Deliberately NOT resetting reason/relatedAddr here: they describe why we're // currently paused (not whether a step is pending), and for CPUStepType::Into this // clear() runs immediately after finishing the step, before SteppingBroadcaster gets @@ -373,23 +371,14 @@ void Core_SwitchToGe() { coreState = CORE_RUNNING_GE; } -bool Core_RequestCPUStep(CPUStepType type, int stepSize) { +bool Core_RequestCPUStep(CPUStepType type) { std::lock_guard guard(g_stepMutex); if (g_cpuStepCommand.type != CPUStepType::None) { ERROR_LOG(Log::CPU, "Can't submit two steps in one host frame"); return false; } - // Some step types don't need a size. - switch (type) { - case CPUStepType::Out: - case CPUStepType::Frame: - break; - default: - _dbg_assert_(stepSize != 0); - break; - } BreakReason reason = type == CPUStepType::Into ? BreakReason::DebugStepInto : BreakReason::DebugStep; - g_cpuStepCommand = { type, stepSize, reason, 0 }; + g_cpuStepCommand = { type, reason, 0 }; return true; } @@ -397,23 +386,20 @@ bool Core_RequestCPUStep(CPUStepType type, int stepSize) { // stepSize is always in instructions (4 bytes each), never bytes. // Doesn't return the new address, as that's just mips->getPC(). // Internal use. -static void Core_PerformCPUStep(MIPSDebugInterface *cpu, CPUStepType stepType, int stepSize) { +static void Core_PerformCPUStep(MIPSDebugInterface *cpu, CPUStepType stepType) { switch (stepType) { case CPUStepType::Into: { u32 currentPc = cpu->GetPC(); // If the current PC is on a breakpoint, the user still wants the step to happen. g_breakpoints.SetSkipFirst(currentPc); - for (int i = 0; i < stepSize; i++) { - currentMIPS->SingleStep(); - } + currentMIPS->SingleStep(); CoreTiming::Advance(currentMIPS); break; } case CPUStepType::Over: { u32 currentPc = cpu->GetPC(); - u32 breakpointAddress = currentPc + stepSize * 4; g_breakpoints.SetSkipFirst(currentPc); MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu, cpu->GetPC()); @@ -421,6 +407,7 @@ static void Core_PerformCPUStep(MIPSDebugInterface *cpu, CPUStepType stepType, i // TODO: Doing a step over in a delay slot is a bit .. unclear. Maybe just do a single step. if (info.isBranch) { + u32 breakpointAddress = currentPc + 4; if (info.isConditional == false) { if (info.isLinkedBranch) { // jal, jalr // it's a function call with a delay slot - skip that too @@ -440,9 +427,7 @@ static void Core_PerformCPUStep(MIPSDebugInterface *cpu, CPUStepType stepType, i Core_Resume(); } else { // If not a branch, just do a simple single-step, no point in involving the breakpoint machinery. - for (int i = 0; i < (int)(breakpointAddress - currentPc) / 4; i++) { - currentMIPS->SingleStep(); - } + currentMIPS->SingleStep(); } break; } @@ -529,7 +514,7 @@ static bool Core_ProcessStepping(MIPSDebugInterface *cpu) { Core_ResetException(); if (!g_cpuStepCommand.empty()) { - Core_PerformCPUStep(cpu, g_cpuStepCommand.type, g_cpuStepCommand.stepSize); + Core_PerformCPUStep(cpu, g_cpuStepCommand.type); if (g_cpuStepCommand.type == CPUStepType::Into) { // We're already done. The other step types will resume the CPU. System_Notify(SystemNotification::DISASSEMBLY_AFTERSTEP); diff --git a/Core/Core.h b/Core/Core.h index 0d7d371907..774bde4167 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -87,7 +87,7 @@ BreakReason Core_BreakReason(); // This should be called externally. // Can fail if another step type was requested this frame. // stepSize is always in instructions (4 bytes each), never bytes - see Core_PerformCPUStep in Core.cpp. -bool Core_RequestCPUStep(CPUStepType stepType, int stepSize); +bool Core_RequestCPUStep(CPUStepType stepType); bool Core_NextFrame(); void Core_SwitchToGe(); // Switches from CPU emulation to GE display list execution. diff --git a/Core/Debugger/WebSocket/CPUCoreSubscriber.cpp b/Core/Debugger/WebSocket/CPUCoreSubscriber.cpp index 9c3aa3bdf1..b2947bc61f 100644 --- a/Core/Debugger/WebSocket/CPUCoreSubscriber.cpp +++ b/Core/Debugger/WebSocket/CPUCoreSubscriber.cpp @@ -97,7 +97,7 @@ void WebSocketCPUResume(DebuggerRequest &req) { Core_RunOnCPUThread([&] { g_breakpoints.SetSkipFirst(currentMIPS->pc); if (currentMIPS->inDelaySlot) { - Core_RequestCPUStep(CPUStepType::Into, 1); + Core_RequestCPUStep(CPUStepType::Into); } Core_Resume(); }); diff --git a/Core/Debugger/WebSocket/SteppingSubscriber.cpp b/Core/Debugger/WebSocket/SteppingSubscriber.cpp index cd13db9878..35bbf52d87 100644 --- a/Core/Debugger/WebSocket/SteppingSubscriber.cpp +++ b/Core/Debugger/WebSocket/SteppingSubscriber.cpp @@ -116,7 +116,7 @@ void WebSocketSteppingState::Into(DebuggerRequest &req) { // fires, but the client got no response either (this event's contract is "no // immediate response, a cpu.stepping event follows") - so a rejected step looked // identical to one that's just still in flight, indefinitely. Surface it instead. - if (!Core_RequestCPUStep(CPUStepType::Into, 1)) { + if (!Core_RequestCPUStep(CPUStepType::Into)) { req.Fail("Could not step: a step or run request is already pending"); return; } diff --git a/UI/ImDebugger/ImDisasmView.cpp b/UI/ImDebugger/ImDisasmView.cpp index 50645ae762..4ef0841764 100644 --- a/UI/ImDebugger/ImDisasmView.cpp +++ b/UI/ImDebugger/ImDisasmView.cpp @@ -1093,10 +1093,10 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro if (ImGui::IsWindowFocused()) { // Process stepping keyboard shortcuts. if (ImGui::IsKeyPressed(ImGuiKey_F10)) { - Core_RequestCPUStep(CPUStepType::Over, 1); + Core_RequestCPUStep(CPUStepType::Over); } if (ImGui::IsKeyPressed(ImGuiKey_F11)) { - Core_RequestCPUStep(CPUStepType::Into, 1); + Core_RequestCPUStep(CPUStepType::Into); } } @@ -1129,7 +1129,7 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro ImGui::SameLine(); if (ImGui::RepeatButtonShift("Into")) { - Core_RequestCPUStep(CPUStepType::Into, 1); + Core_RequestCPUStep(CPUStepType::Into); } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("F11"); @@ -1137,7 +1137,7 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro ImGui::SameLine(); if (ImGui::SmallButton("Over")) { - Core_RequestCPUStep(CPUStepType::Over, 1); + Core_RequestCPUStep(CPUStepType::Over); } if (ImGui::IsItemHovered()) { ImGui::SetTooltip("F10"); @@ -1145,13 +1145,13 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro ImGui::SameLine(); if (ImGui::SmallButton("Out")) { - Core_RequestCPUStep(CPUStepType::Out, 0); + Core_RequestCPUStep(CPUStepType::Out); } /* ImGui::SameLine(); if (ImGui::SmallButton("Frame")) { - Core_RequestCPUStep(CPUStepType::Frame, 0); + Core_RequestCPUStep(CPUStepType::Frame); }*/ ImGui::SameLine(); diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index a4ca6b63a2..3ec4cba98a 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -208,7 +208,7 @@ void CDisasm::step(CPUStepType stepType) { // Route the actual step request to the CPU thread instead of poking at it directly from this // GUI thread - see Core_RunOnCPUThread() in Core.h. - Core_RunOnCPUThread([&] { Core_RequestCPUStep(stepType, 1); }); + Core_RunOnCPUThread([&] { Core_RequestCPUStep(stepType); }); } void CDisasm::runToLine() {