SPU/PPU/Debugger: Ensure ascending stack frames (#13833)

* PPU/Debugger: Ensure ascending stack frames

* SPU/Debugger: Ensure descending stack frame pointers
This commit is contained in:
Elad Ashkenazi 2023-05-10 11:23:09 +03:00 committed by GitHub
parent 58140e1d3a
commit db7f84f9f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -1290,7 +1290,7 @@ std::vector<std::pair<u32, u32>> ppu_thread::dump_callstack_list() const
for (
u64 sp = r1;
sp % 0x10 == 0u && sp >= stack_min && sp <= stack_max - ppu_stack_start_offset;
sp = *vm::get_super_ptr<u64>(static_cast<u32>(sp)), first = false
first = false
)
{
u64 addr = *vm::get_super_ptr<u64>(static_cast<u32>(sp + 16));
@ -1328,6 +1328,16 @@ std::vector<std::pair<u32, u32>> ppu_thread::dump_callstack_list() const
// TODO: function addresses too
call_stack_list.emplace_back(static_cast<u32>(addr), static_cast<u32>(sp));
const u64 temp_sp = *vm::get_super_ptr<u64>(static_cast<u32>(sp));
if (temp_sp <= sp)
{
// Ensure inequality and that the old stack pointer is higher than current
break;
}
sp = temp_sp;
}
return call_stack_list;

View File

@ -1182,7 +1182,7 @@ std::vector<std::pair<u32, u32>> spu_thread::dump_callstack_list() const
const v128 gpr0 = gpr[0];
// Declare first 128-bytes as invalid for stack (common values such as 0 do not make sense here)
for (u32 sp = gpr[1]._u32[3]; (sp & 0xF) == 0u && sp >= 0x80u && sp <= 0x3FFE0u; sp = _ref<u32>(sp), first = false)
for (u32 sp = gpr[1]._u32[3]; (sp & 0xF) == 0u && sp >= 0x80u && sp <= 0x3FFE0u; first = false)
{
v128 lr = _ref<v128>(sp + 16);
@ -1310,6 +1310,16 @@ std::vector<std::pair<u32, u32>> spu_thread::dump_callstack_list() const
// TODO: function addresses too
call_stack_list.emplace_back(lr._u32[3], sp);
const u32 temp_sp = _ref<u32>(sp);
if (temp_sp <= sp)
{
// Ensure ascending stack frame pointers
break;
}
sp = temp_sp;
}
return call_stack_list;