mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Added on_error handler for Module
This commit is contained in:
parent
5815d90eb4
commit
25056f49c4
@ -25,6 +25,11 @@ public:
|
||||
|
||||
void Init()
|
||||
{
|
||||
on_load = nullptr;
|
||||
on_unload = nullptr;
|
||||
on_stop = nullptr;
|
||||
on_error = nullptr;
|
||||
|
||||
m_init();
|
||||
}
|
||||
|
||||
|
@ -198,6 +198,12 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index)
|
||||
CPU.PC = VM_CAST(CPU.LR & ~3) - 4;
|
||||
}
|
||||
|
||||
// execute module-specific error check
|
||||
if ((s64)CPU.GPR[3] < 0 && func->module && func->module->on_error)
|
||||
{
|
||||
func->module->on_error(CPU.GPR[3], func);
|
||||
}
|
||||
|
||||
CPU.hle_code = last_code;
|
||||
}
|
||||
else
|
||||
@ -610,6 +616,11 @@ Module::~Module()
|
||||
|
||||
void Module::Init()
|
||||
{
|
||||
on_load = nullptr;
|
||||
on_unload = nullptr;
|
||||
on_stop = nullptr;
|
||||
on_error = nullptr;
|
||||
|
||||
m_init();
|
||||
}
|
||||
|
||||
|
@ -99,6 +99,7 @@ public:
|
||||
std::function<void()> on_load;
|
||||
std::function<void()> on_unload;
|
||||
std::function<void()> on_stop;
|
||||
std::function<void(s64 value, ModuleFunc* func)> on_error;
|
||||
|
||||
void Init();
|
||||
void Load();
|
||||
|
@ -1596,6 +1596,41 @@ s32 _cellSyncLFQueueDetachLv2EventQueue(vm::ptr<u32> spus, u32 num, vm::ptr<Cell
|
||||
|
||||
Module cellSync("cellSync", []()
|
||||
{
|
||||
// setup error handler
|
||||
cellSync.on_error = [](s64 value, ModuleFunc* func)
|
||||
{
|
||||
// get error name for CELL_SYNC errors
|
||||
auto get_error = [](s32 code) -> const char*
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case CELL_SYNC_ERROR_AGAIN: return "CELL_SYNC_ERROR_AGAIN";
|
||||
case CELL_SYNC_ERROR_INVAL: return "CELL_SYNC_ERROR_INVAL";
|
||||
case CELL_SYNC_ERROR_NOSYS: return "CELL_SYNC_ERROR_NOSYS";
|
||||
case CELL_SYNC_ERROR_NOMEM: return "CELL_SYNC_ERROR_NOMEM";
|
||||
case CELL_SYNC_ERROR_SRCH: return "CELL_SYNC_ERROR_SRCH";
|
||||
case CELL_SYNC_ERROR_NOENT: return "CELL_SYNC_ERROR_NOENT";
|
||||
case CELL_SYNC_ERROR_NOEXEC: return "CELL_SYNC_ERROR_NOEXEC";
|
||||
case CELL_SYNC_ERROR_DEADLK: return "CELL_SYNC_ERROR_DEADLK";
|
||||
case CELL_SYNC_ERROR_PERM: return "CELL_SYNC_ERROR_PERM";
|
||||
case CELL_SYNC_ERROR_BUSY: return "CELL_SYNC_ERROR_BUSY";
|
||||
case CELL_SYNC_ERROR_ABORT: return "CELL_SYNC_ERROR_ABORT";
|
||||
case CELL_SYNC_ERROR_FAULT: return "CELL_SYNC_ERROR_FAULT";
|
||||
case CELL_SYNC_ERROR_CHILD: return "CELL_SYNC_ERROR_CHILD";
|
||||
case CELL_SYNC_ERROR_STAT: return "CELL_SYNC_ERROR_STAT";
|
||||
case CELL_SYNC_ERROR_ALIGN: return "CELL_SYNC_ERROR_ALIGN";
|
||||
}
|
||||
|
||||
return "???";
|
||||
};
|
||||
|
||||
// analyse error code
|
||||
if (s32 code = (value & 0xffffff00) == 0x80410100 ? static_cast<s32>(value) : 0)
|
||||
{
|
||||
cellSync.Error("%s() -> %s (0x%x)", func->name, get_error(code), code);
|
||||
}
|
||||
};
|
||||
|
||||
REG_FUNC(cellSync, cellSyncMutexInitialize);
|
||||
REG_FUNC(cellSync, cellSyncMutexLock);
|
||||
REG_FUNC(cellSync, cellSyncMutexTryLock);
|
||||
|
Loading…
Reference in New Issue
Block a user