diff --git a/pcsx2-qt/Debugger/StackModel.cpp b/pcsx2-qt/Debugger/StackModel.cpp index 203b0b98cd..4ebcf60d9d 100644 --- a/pcsx2-qt/Debugger/StackModel.cpp +++ b/pcsx2-qt/Debugger/StackModel.cpp @@ -111,8 +111,7 @@ void StackModel::refreshData() { if (thread->Status() == ThreadStatus::THS_RUN) { - m_stackFrames = MipsStackWalk::Walk(&m_cpu, m_cpu.getPC(), m_cpu.getRegister(0, 31), m_cpu.getRegister(0, 29), - thread->EntryPoint(), thread->StackTop()); + m_stackFrames = m_cpu.StackTrace(*thread); break; } } diff --git a/pcsx2/DebugTools/DebugInterface.cpp b/pcsx2/DebugTools/DebugInterface.cpp index c8715f7875..584286b7f1 100644 --- a/pcsx2/DebugTools/DebugInterface.cpp +++ b/pcsx2/DebugTools/DebugInterface.cpp @@ -708,6 +708,23 @@ std::vector> R5900DebugInterface::GetThreadList() co return getEEThreads(); } +std::vector R5900DebugInterface::StackTrace(const BiosThread& thread) +{ + if (thread.Status() == ThreadStatus::THS_RUN) + { + return MipsStackWalk::Walk(this, getPC(), getRegister(0, 31), getRegister(0, 29), + thread.EntryPoint(), thread.StackTop()); + } + + EEInternalCtx* ctx = static_cast(PSM(thread.RegCtx())); + u32 pc = thread.PC(); + // $zero is not in the array so subtract 1 + u32 ra = ctx->gpr[31 - 1]._u32[0]; + u32 sp = ctx->gpr[29 - 1]._u32[0]; + + return MipsStackWalk::Walk(this, pc, ra, sp, thread.EntryPoint(), thread.StackTop()); +} + std::vector R5900DebugInterface::GetModuleList() const { return {}; @@ -1049,6 +1066,17 @@ std::vector> R3000DebugInterface::GetThreadList() co return getIOPThreads(); } +std::vector R3000DebugInterface::StackTrace(const BiosThread& thread) +{ + if (thread.Status() == ThreadStatus::THS_RUN) + { + return MipsStackWalk::Walk(this, getPC(), getRegister(0, 31), getRegister(0, 29), + thread.EntryPoint(), thread.StackTop()); + } + + return {}; +} + std::vector R3000DebugInterface::GetModuleList() const { return getIOPModules(); diff --git a/pcsx2/DebugTools/DebugInterface.h b/pcsx2/DebugTools/DebugInterface.h index a5f9862265..48b266ba56 100644 --- a/pcsx2/DebugTools/DebugInterface.h +++ b/pcsx2/DebugTools/DebugInterface.h @@ -7,6 +7,7 @@ #include "ExpressionParser.h" #include "SymbolGuardian.h" #include "SymbolImporter.h" +#include "MipsStackWalk.h" #include "common/MemoryInterface.h" @@ -72,6 +73,7 @@ public: virtual SymbolGuardian& GetSymbolGuardian() const = 0; virtual SymbolImporter* GetSymbolImporter() const = 0; virtual std::vector> GetThreadList() const = 0; + virtual std::vector StackTrace(const BiosThread& thread) = 0; virtual std::vector GetModuleList() const = 0; bool isAlive(); @@ -135,6 +137,7 @@ public: SymbolGuardian& GetSymbolGuardian() const override; SymbolImporter* GetSymbolImporter() const override; std::vector> GetThreadList() const override; + std::vector StackTrace(const BiosThread& thread) override; std::vector GetModuleList() const override; std::string disasm(u32 address, bool simplify) override; @@ -180,6 +183,7 @@ public: SymbolGuardian& GetSymbolGuardian() const override; SymbolImporter* GetSymbolImporter() const override; std::vector> GetThreadList() const override; + std::vector StackTrace(const BiosThread& thread) override; std::vector GetModuleList() const override; std::string disasm(u32 address, bool simplify) override;