Small fix

This commit is contained in:
Nekotekina 2014-09-13 01:50:50 +04:00
parent 10e9d383d4
commit 0df3e955c8
2 changed files with 17 additions and 4 deletions

View File

@ -283,11 +283,12 @@ void CPUThread::ExecOnce()
void _se_translator(unsigned int u, EXCEPTION_POINTERS* pExp) void _se_translator(unsigned int u, EXCEPTION_POINTERS* pExp)
{ {
const u64 addr = (u64)pExp->ExceptionRecord->ExceptionInformation[1] - (u64)Memory.GetBaseAddr(); const u64 addr = (u64)pExp->ExceptionRecord->ExceptionInformation[1] - (u64)Memory.GetBaseAddr();
if (u == EXCEPTION_ACCESS_VIOLATION && addr < 0x100000000) CPUThread* t = GetCurrentCPUThread();
if (u == EXCEPTION_ACCESS_VIOLATION && addr < 0x100000000 && t)
{ {
// TODO: allow recovering from a page fault // TODO: allow recovering from a page fault
throw fmt::Format("Access violation: addr = 0x%x (last_syscall=0x%llx (%s))", throw fmt::Format("Access violation: addr = 0x%x (last_syscall=0x%llx (%s))",
(u32)addr, (u64)GetCurrentCPUThread()->m_last_syscall, SysCalls::GetHLEFuncName((u32)GetCurrentCPUThread()->m_last_syscall).c_str()); (u32)addr, (u64)t->m_last_syscall, SysCalls::GetHLEFuncName((u32)t->m_last_syscall).c_str());
} }
else else
{ {
@ -317,7 +318,7 @@ void CPUThread::Task()
std::vector<u64> trace; std::vector<u64> trace;
#ifdef _WIN32 #ifdef _WIN32
_set_se_translator(_se_translator); auto old_se_translator = _set_se_translator(_se_translator);
#else #else
// TODO: linux version // TODO: linux version
#endif #endif
@ -370,6 +371,12 @@ void CPUThread::Task()
Emu.Pause(); Emu.Pause();
} }
#ifdef _WIN32
_set_se_translator(old_se_translator);
#else
// TODO: linux version
#endif
for (auto& v : trace) LOG_NOTICE(PPU, "PC = 0x%llx", v); for (auto& v : trace) LOG_NOTICE(PPU, "PC = 0x%llx", v);
if (Ini.HLELogging.GetValue()) LOG_NOTICE(PPU, "%s leave", CPUThread::GetFName().c_str()); if (Ini.HLELogging.GetValue()) LOG_NOTICE(PPU, "%s leave", CPUThread::GetFName().c_str());

View File

@ -61,10 +61,16 @@ void CallbackManager::Init()
m_cb_thread->SetEntry(cb_shit); m_cb_thread->SetEntry(cb_shit);
m_cb_thread->SetPrio(1001); // ??? m_cb_thread->SetPrio(1001); // ???
m_cb_thread->SetStackSize(0x10000); m_cb_thread->SetStackSize(0x10000);
m_cb_thread->Run();
thread cb_async_thread("CallbackManager::Async() thread", [this]() thread cb_async_thread("CallbackManager::Async() thread", [this]()
{ {
while (Emu.IsReady())
{
m_cb_thread->WaitForAnySignal();
}
m_cb_thread->Run();
SetCurrentNamedThread(m_cb_thread); SetCurrentNamedThread(m_cb_thread);
while (!Emu.IsStopped()) while (!Emu.IsStopped())