diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index ddbce64215..b0859a3028 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -690,6 +690,7 @@ namespace rsx public: atomic_t sync_point_request = false; + atomic_t pause_on_draw = false; bool in_begin_end = false; std::queue recovered_fifo_cmds_history; diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 046ef9ed03..14f37e793f 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -657,6 +657,13 @@ namespace rsx { rsxthr->in_begin_end = false; } + + if (rsxthr->pause_on_draw && rsxthr->pause_on_draw.exchange(false)) + { + rsxthr->state -= cpu_flag::dbg_step; + rsxthr->state += cpu_flag::dbg_pause; + rsxthr->check_state(); + } } vm::addr_t get_report_data_impl(u32 offset) diff --git a/rpcs3/rpcs3qt/debugger_frame.cpp b/rpcs3/rpcs3qt/debugger_frame.cpp index f24ef43683..b27446df74 100644 --- a/rpcs3/rpcs3qt/debugger_frame.cpp +++ b/rpcs3/rpcs3qt/debugger_frame.cpp @@ -166,42 +166,7 @@ debugger_frame::debugger_frame(std::shared_ptr gui_settings, QWidg connect(m_btn_step, &QAbstractButton::clicked, this, &debugger_frame::DoStep); connect(m_btn_step_over, &QAbstractButton::clicked, [this]() { DoStep(true); }); - connect(m_btn_run, &QAbstractButton::clicked, [this]() - { - if (const auto cpu = get_cpu()) - { - // If paused, unpause. - // If not paused, add dbg_pause. - const auto old = cpu->state.fetch_op([](bs_t& state) - { - if (state & s_pause_flags) - { - state -= s_pause_flags; - } - else - { - state += cpu_flag::dbg_pause; - } - }); - - // Notify only if no pause flags are set after this change - if (old & s_pause_flags) - { - if (g_debugger_pause_all_threads_on_bp && Emu.IsPaused() && (old & s_pause_flags) == s_pause_flags) - { - // Resume all threads were paused by this breakpoint - Emu.Resume(); - } - - cpu->state.notify_one(s_pause_flags); - m_debugger_list->EnableThreadFollowing(); - } - } - - // Tighten up, put the debugger on a wary watch over any thread info changes if there aren't any - // This allows responsive debugger interaction - m_ui_fast_update_permission_deadline = m_ui_update_ctr + 5; - }); + connect(m_btn_run, &QAbstractButton::clicked, this, &debugger_frame::RunBtnPress); connect(m_choice_units->lineEdit(), &QLineEdit::editingFinished, [&] { @@ -1156,6 +1121,20 @@ void debugger_frame::DoStep(bool step_over) m_debugger_list->ShowAddress(cpu->get_pc() + 4, false); } + if (step_over && cpu->id_type() == 0x55) + { + const bool was_paused = cpu->is_paused(); + static_cast(cpu)->pause_on_draw = true; + + if (was_paused) + { + RunBtnPress(); + m_debugger_list->EnableThreadFollowing(true); + } + + return; + } + if (const auto _state = +cpu->state; _state & s_pause_flags && _state & cpu_flag::wait && !(_state & cpu_flag::dbg_step)) { if (should_step_over) @@ -1166,7 +1145,7 @@ void debugger_frame::DoStep(bool step_over) const u32 next_instruction_pc = current_instruction_pc + 4; m_ppu_breakpoint_handler->AddBreakpoint(next_instruction_pc); - // Undefine previous step over breakpoint if it hasnt been already + // Undefine previous step over breakpoint if it hasn't been already // This can happen when the user steps over a branch that doesn't return to itself if (m_last_step_over_breakpoint != umax) { @@ -1204,6 +1183,43 @@ void debugger_frame::EnableUpdateTimer(bool enable) const enable ? m_update->start(10) : m_update->stop(); } +void debugger_frame::RunBtnPress() +{ + if (const auto cpu = get_cpu()) + { + // If paused, unpause. + // If not paused, add dbg_pause. + const auto old = cpu->state.fetch_op([](bs_t& state) + { + if (state & s_pause_flags) + { + state -= s_pause_flags; + } + else + { + state += cpu_flag::dbg_pause; + } + }); + + // Notify only if no pause flags are set after this change + if (old & s_pause_flags) + { + if (g_debugger_pause_all_threads_on_bp && Emu.IsPaused() && (old & s_pause_flags) == s_pause_flags) + { + // Resume all threads were paused by this breakpoint + Emu.Resume(); + } + + cpu->state.notify_one(s_pause_flags); + m_debugger_list->EnableThreadFollowing(); + } + } + + // Tighten up, put the debugger on a wary watch over any thread info changes if there aren't any + // This allows responsive debugger interaction + m_ui_fast_update_permission_deadline = m_ui_update_ctr + 5; +} + void debugger_frame::EnableButtons(bool enable) { const auto cpu = get_cpu(); diff --git a/rpcs3/rpcs3qt/debugger_frame.h b/rpcs3/rpcs3qt/debugger_frame.h index 47248da4e3..d9575db065 100644 --- a/rpcs3/rpcs3qt/debugger_frame.h +++ b/rpcs3/rpcs3qt/debugger_frame.h @@ -115,6 +115,7 @@ private Q_SLOTS: void OnSelectUnit(); void ShowPC(bool user_requested = false); void EnableUpdateTimer(bool enable) const; + void RunBtnPress(); }; Q_DECLARE_METATYPE(u32) diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index 8c44a241e4..d74494b970 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -400,8 +400,8 @@ void Buffer::ShowContextMenu(const QPoint& pos) } }); - contextMenu.addAction(&action); - contextMenu.exec(mapToGlobal(pos)); + context_menu.addAction(&action); + context_menu.exec(mapToGlobal(pos)); } namespace