lv2: Do not lose r3 data on syscalls

Allows to get the ID of the lv2 sync objects in the debugger by looking at r3's content.
This commit is contained in:
Eladash 2020-03-22 10:35:35 +02:00 committed by Ivan
parent f1cf62ac57
commit dc839e1784
5 changed files with 6 additions and 2 deletions

View file

@ -28,7 +28,7 @@ error_code sys_spinlock_lock(ppu_thread& ppu, vm::ptr<atomic_be_t<u32>> lock)
}
}
return not_an_error(ppu.gpr[3]);
return CELL_OK;
}
s32 sys_spinlock_trylock(vm::ptr<atomic_be_t<u32>> lock)

View file

@ -9,6 +9,7 @@ using ppu_function_t = bool(*)(ppu_thread&);
const auto old_f = ppu.current_function;\
if (!old_f) ppu.last_function = #func;\
ppu.current_function = #func;\
ppu.syscall_r3 = ppu.gpr[3];\
ppu_func_detail::do_call(ppu, func);\
ppu.current_function = old_f;\
ppu.cia += 4;\

View file

@ -432,6 +432,7 @@ std::string ppu_thread::dump() const
ret += "Current function: ";
ret += _func;
ret += '\n';
fmt::append(ret, "syscall r3: 0x%llx\n", syscall_r3);
}
else if (is_paused())
{

View file

@ -189,6 +189,7 @@ public:
cmd64 cmd_get(u32 index) { return cmd_queue[cmd_queue.peek() + index].load(); }
u64 start_time{0}; // Sleep start timepoint
u64 syscall_r3{0}; // Save r3 before syscalls
const char* current_function{}; // Current function name for diagnosis, optimized for speed.
const char* last_function{}; // Sticky copy of current_function, is not cleared on function return

View file

@ -95,13 +95,14 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm
sys_event_flag.trace("sys_event_flag_wait(id=0x%x, bitptn=0x%llx, mode=0x%x, result=*0x%x, timeout=0x%llx)", id, bitptn, mode, result, timeout);
// Fix function arguments for external access
// TODO: Avoid using registers
ppu.gpr[3] = -1;
ppu.gpr[4] = bitptn;
ppu.gpr[5] = mode;
ppu.gpr[6] = 0;
// Always set result
if (result) *result = ppu.gpr[6];
if (result) *result = 0;
if (!lv2_event_flag::check_mode(mode))
{