From a71bdc761e6c3e416ffaf12ce8765544b968eba0 Mon Sep 17 00:00:00 2001 From: Eladash Date: Mon, 22 Aug 2022 18:08:10 +0300 Subject: [PATCH] SPU/Debugger: Improve debugging reservations Simplify and make the debugging results more consistent. --- rpcs3/Emu/Cell/SPUThread.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index e1da9a04ae..cf8bb08258 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -4248,6 +4248,8 @@ s64 spu_thread::get_ch_value(u32 ch) resrv_mem = vm::get_super_ptr(raddr); std::shared_ptr rdata_shm; + const u32 old_raddr = raddr; + // Does not need to safe-access reservation if LR is the only event masked // Because it's either an access violation or a livelock if an invalid memory is passed if (raddr && mask1 > SPU_EVENT_LR) @@ -4293,14 +4295,6 @@ s64 spu_thread::get_ch_value(u32 ch) return -1; } - if (is_paused(old)) - { - // Ensure spu_thread::rdata's stagnancy while the thread is paused for debugging purposes - check_state(); - state += cpu_flag::wait; - continue; - } - // Optimized check if (raddr && (!vm::check_addr(raddr) || rtime != vm::reservation_acquire(raddr) || !cmp_rdata(rdata, *resrv_mem))) { @@ -4326,11 +4320,6 @@ s64 spu_thread::get_ch_value(u32 ch) return false; } - if (is_paused(old)) - { - return true; - } - if (!vm::check_addr(_this->raddr) || !cmp_rdata(_this->rdata, *_this->resrv_mem)) { _this->set_events(SPU_EVENT_LR); @@ -4355,6 +4344,18 @@ s64 spu_thread::get_ch_value(u32 ch) } wakeup_delay(); + + if (is_paused(state - cpu_flag::suspend)) + { + if (!raddr && old_raddr) + { + // Restore reservation address temporarily for debugging use + raddr = old_raddr; + check_state(); + raddr = 0; + } + } + check_state(); return events.events & mask1; }