From cfc7865f8294e8e1f9ebcc48e5eb9278224c1256 Mon Sep 17 00:00:00 2001 From: Eladash Date: Sun, 31 Jan 2021 20:25:15 +0200 Subject: [PATCH] Debugger: Allow to unpause a thread which has been paused by global pause --- rpcs3/rpcs3qt/debugger_frame.cpp | 38 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/rpcs3/rpcs3qt/debugger_frame.cpp b/rpcs3/rpcs3qt/debugger_frame.cpp index a5af00a0b6..8be971107a 100644 --- a/rpcs3/rpcs3qt/debugger_frame.cpp +++ b/rpcs3/rpcs3qt/debugger_frame.cpp @@ -33,6 +33,8 @@ constexpr auto qstr = QString::fromStdString; +constexpr auto s_pause_flags = cpu_flag::dbg_pause + cpu_flag::dbg_global_pause; + debugger_frame::debugger_frame(std::shared_ptr settings, QWidget *parent) : custom_dock_widget(tr("Debugger"), parent), xgui_settings(settings) { @@ -140,11 +142,24 @@ debugger_frame::debugger_frame(std::shared_ptr settings, QWidget * { if (const auto cpu = get_cpu()) { - // Alter dbg_pause bit state (disable->enable, enable->disable) - const auto old = cpu->state.xor_fetch(cpu_flag::dbg_pause); + // If paused, unpause. + // If not paused, add dbg_pause. + const auto old = cpu->state.atomic_op([](bs_t& state) + { + if (state & s_pause_flags) + { + state -= s_pause_flags; + } + else + { + state += cpu_flag::dbg_pause; + } + + return state; + }); // Notify only if no pause flags are set after this change - if (!(old & (cpu_flag::dbg_pause + cpu_flag::dbg_global_pause))) + if (!(old & s_pause_flags)) { cpu->notify(); } @@ -441,7 +456,7 @@ void debugger_frame::UpdateUI() m_last_pc = cia; DoUpdate(); - if (cpu->state & cpu_flag::dbg_pause) + if (cpu->state & s_pause_flags) { m_btn_run->setText(RunString); m_btn_step->setEnabled(true); @@ -725,13 +740,7 @@ void debugger_frame::DoStep(bool stepOver) { bool should_step_over = stepOver && cpu->id_type() == 1; - if (+cpu_flag::dbg_pause & +cpu->state.fetch_op([&](bs_t& state) - { - if (!should_step_over) - state += cpu_flag::dbg_step; - - state -= cpu_flag::dbg_pause; - })) + if (cpu->state & s_pause_flags) { if (should_step_over) { @@ -751,6 +760,13 @@ void debugger_frame::DoStep(bool stepOver) m_last_step_over_breakpoint = next_instruction_pc; } + cpu->state.atomic_op([&](bs_t& state) + { + state -= s_pause_flags; + + if (!should_step_over) state += cpu_flag::dbg_step; + }); + cpu->notify(); } }