From 9c99e75939af118cddcf4c0fc5c45c295cbf38ee Mon Sep 17 00:00:00 2001 From: elad335 <18193363+elad335@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:11:22 +0300 Subject: [PATCH] SPU Debug: WrDec and LSA view Report the last written value to WrDec. --- rpcs3/Emu/Cell/SPUThread.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index faf78babb3..6a8c3aeceb 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -1204,18 +1204,30 @@ void spu_thread::dump_regs(std::string& ret, std::any& /*custom_data*/) const std::vector gpr_saved(128); be_t rdata_saved[32]{}; + be_t lsa_saved[32]{}; + spu_mfc_cmd mfc_regs_saved{}; u32 saved_pc = umax; + const u8* lsa_state_ptr = nullptr; + + const u8* lsa_ptr = _ptr(ch_mfc_cmd.lsa); // Load PC, GPRs and reservation data atomically // We may not load the entire context atomically, but there is importance their state being intact for debugging do { saved_pc = pc; + + // Account for list transfer: record EAL instead + mfc_regs_saved = ch_mfc_cmd; + lsa_state_ptr = _ptr(mfc_regs_saved.eal < SPU_LS_SIZE && mfc_regs_saved.eal % 8 == 0 ? mfc_regs_saved.eal : mfc_regs_saved.lsa); + std::memcpy(gpr_saved.data(), gpr.data(), sizeof(v128) * gpr.size()); std::memcpy(rdata_saved, rdata, sizeof(rdata)); + std::memcpy(lsa_saved, lsa_state_ptr, std::min(128, SPU_LS_SIZE - (lsa_state_ptr - _ptr(0)))); atomic_fence_acquire(); } - while (saved_pc != pc || std::memcmp(rdata_saved, rdata, sizeof(rdata)) != 0 || std::memcmp(gpr_saved.data(), gpr.data(), sizeof(v128) * gpr.size()) != 0); + while (saved_pc != pc || std::memcmp(rdata_saved, rdata, sizeof(rdata)) != 0 || std::memcmp(gpr_saved.data(), gpr.data(), sizeof(v128) * gpr.size()) != 0 + || std::memcmp(&mfc_regs_saved, &ch_mfc_cmd, sizeof(mfc_regs_saved)) != 0 || std::memcmp(lsa_saved, lsa_state_ptr, std::min(128, SPU_LS_SIZE - (lsa_state_ptr - _ptr(0)))) != 0); for (u32 i = 0; i < 128; i++, ret += '\n') { @@ -1350,6 +1362,7 @@ void spu_thread::dump_regs(std::string& ret, std::any& /*custom_data*/) const fmt::append(ret, "SNR config: 0x%llx\n", snr_config); fmt::append(ret, "SNR1: %s\n", ch_snr1); fmt::append(ret, "SNR2: %s\n", ch_snr2); + fmt::append(ret, "Last WrDec: %-9d (0x%08x) (%s)\n", ch_dec_value, ch_dec_value, is_dec_frozen ? "suspend" : "running"); if (get_type() != spu_type::threaded) { @@ -1388,6 +1401,14 @@ void spu_thread::dump_regs(std::string& ret, std::any& /*custom_data*/) const fmt::append(ret, "[0x%02x] %08x %08x %08x %08x\n", i * sizeof(rdata_saved[0]) , rdata_saved[i + 0], rdata_saved[i + 1], rdata_saved[i + 2], rdata_saved[i + 3]); } + + fmt::append(ret, "\nLSA Data:\n"); + + for (usz i = 0; i < std::size(lsa_saved); i += 4) + { + fmt::append(ret, "[0x%02x] %08x %08x %08x %08x\n", i * sizeof(lsa_saved[0]) + , lsa_saved[i + 0], lsa_saved[i + 1], lsa_saved[i + 2], lsa_saved[i + 3]); + } } std::string spu_thread::dump_callstack() const