mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Avoid a segfault when reading ppu stack contents in debuggers
TODO: lock vm mutex.
This commit is contained in:
parent
a3289e9d40
commit
1dbb5422a2
@ -472,8 +472,17 @@ std::string ppu_thread::dump() const
|
|||||||
fmt::append(ret, "FPSCR = [FL=%u | FG=%u | FE=%u | FU=%u]\n", fpscr.fl, fpscr.fg, fpscr.fe, fpscr.fu);
|
fmt::append(ret, "FPSCR = [FL=%u | FG=%u | FE=%u | FU=%u]\n", fpscr.fl, fpscr.fg, fpscr.fe, fpscr.fu);
|
||||||
fmt::append(ret, "\nCall stack:\n=========\n0x%08x (0x0) called\n", cia);
|
fmt::append(ret, "\nCall stack:\n=========\n0x%08x (0x0) called\n", cia);
|
||||||
|
|
||||||
|
//std::shared_lock rlock(vm::g_mutex); // Needs optimizations
|
||||||
|
|
||||||
// Determine stack range
|
// Determine stack range
|
||||||
u32 stack_ptr = static_cast<u32>(gpr[1]);
|
u32 stack_ptr = static_cast<u32>(gpr[1]);
|
||||||
|
|
||||||
|
if (!vm::check_addr(stack_ptr, 1, vm::page_writable))
|
||||||
|
{
|
||||||
|
// Normally impossible unless the code does not follow ABI rules
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
u32 stack_min = stack_ptr & ~0xfff;
|
u32 stack_min = stack_ptr & ~0xfff;
|
||||||
u32 stack_max = stack_min + 4096;
|
u32 stack_max = stack_min + 4096;
|
||||||
|
|
||||||
@ -487,10 +496,10 @@ std::string ppu_thread::dump() const
|
|||||||
stack_max += 4096;
|
stack_max += 4096;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u64 sp = vm::read64(stack_ptr); sp >= stack_min && std::max(sp, sp + 0x200) < stack_max; sp = vm::read64(static_cast<u32>(sp)))
|
for (u64 sp = *vm::get_super_ptr<u64>(stack_ptr); sp >= stack_min && std::max(sp, sp + 0x200) < stack_max; sp = *vm::get_super_ptr<u64>(static_cast<u32>(sp)))
|
||||||
{
|
{
|
||||||
// TODO: print also function addresses
|
// TODO: print also function addresses
|
||||||
fmt::append(ret, "> from 0x%08llx (0x0)\n", vm::read64(static_cast<u32>(sp + 16)));
|
fmt::append(ret, "> from 0x%08llx (0x0)\n", *vm::get_super_ptr<u64>(static_cast<u32>(sp + 16)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user