2014-08-13 12:54:27 +00:00
|
|
|
#include "stdafx.h"
|
2016-02-01 21:55:43 +00:00
|
|
|
#include "Config.h"
|
2014-08-22 14:21:55 +00:00
|
|
|
#include "Emu/System.h"
|
2016-02-01 21:55:43 +00:00
|
|
|
#include "AutoPause.h"
|
2014-08-13 12:54:27 +00:00
|
|
|
|
2016-02-01 21:55:43 +00:00
|
|
|
cfg::bool_entry g_cfg_debug_autopause_syscall(cfg::root.misc, "Auto Pause at System Call");
|
|
|
|
cfg::bool_entry g_cfg_debug_autopause_func_call(cfg::root.misc, "Auto Pause at Function Call");
|
2014-08-13 12:54:27 +00:00
|
|
|
|
2016-02-01 21:55:43 +00:00
|
|
|
debug::autopause& debug::autopause::get_instance()
|
2014-08-13 12:54:27 +00:00
|
|
|
{
|
2016-02-01 21:55:43 +00:00
|
|
|
// Use magic static
|
|
|
|
static autopause instance;
|
|
|
|
return instance;
|
2014-08-13 12:54:27 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 21:55:43 +00:00
|
|
|
// Load Auto Pause Configuration from file "pause.bin"
|
|
|
|
void debug::autopause::reload(void)
|
2014-08-13 12:54:27 +00:00
|
|
|
{
|
2016-02-01 21:55:43 +00:00
|
|
|
auto& instance = get_instance();
|
2014-08-13 12:54:27 +00:00
|
|
|
|
2016-02-01 21:55:43 +00:00
|
|
|
instance.m_pause_function.clear();
|
|
|
|
instance.m_pause_syscall.clear();
|
2014-08-13 12:54:27 +00:00
|
|
|
|
2016-02-01 21:55:43 +00:00
|
|
|
// TODO: better format, possibly a config entry
|
|
|
|
if (fs::file list{ fs::get_config_dir() + "pause.bin" })
|
2014-08-13 12:54:27 +00:00
|
|
|
{
|
|
|
|
u32 num;
|
2015-04-19 13:19:24 +00:00
|
|
|
size_t fmax = list.size();
|
2014-08-13 12:54:27 +00:00
|
|
|
size_t fcur = 0;
|
2015-04-19 13:19:24 +00:00
|
|
|
list.seek(0);
|
2014-08-13 12:54:27 +00:00
|
|
|
while (fcur <= fmax - sizeof(u32))
|
|
|
|
{
|
2015-04-19 13:19:24 +00:00
|
|
|
list.read(&num, sizeof(u32));
|
2014-08-13 12:54:27 +00:00
|
|
|
fcur += sizeof(u32);
|
|
|
|
if (num == 0xFFFFFFFF) break;
|
|
|
|
|
|
|
|
if (num < 1024)
|
|
|
|
{
|
2016-02-01 21:55:43 +00:00
|
|
|
instance.m_pause_syscall.emplace(num);
|
|
|
|
LOG_WARNING(HLE, "Set autopause at syscall %lld", num);
|
2014-08-13 12:54:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-01 21:55:43 +00:00
|
|
|
instance.m_pause_function.emplace(num);
|
|
|
|
LOG_WARNING(HLE, "Set autopause at function 0x%08x", num);
|
2014-08-13 12:54:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-01 21:55:43 +00:00
|
|
|
bool debug::autopause::pause_syscall(u64 code)
|
2015-07-26 08:14:56 +00:00
|
|
|
{
|
2016-02-01 21:55:43 +00:00
|
|
|
if (g_cfg_debug_autopause_syscall && get_instance().m_pause_syscall.count(code) != 0)
|
2014-08-13 12:54:27 +00:00
|
|
|
{
|
2016-02-01 21:55:43 +00:00
|
|
|
Emu.Pause();
|
|
|
|
LOG_SUCCESS(HLE, "Autopause triggered at syscall %lld", code);
|
|
|
|
return true;
|
2014-08-13 12:54:27 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 21:55:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool debug::autopause::pause_function(u32 code)
|
|
|
|
{
|
|
|
|
if (g_cfg_debug_autopause_func_call && get_instance().m_pause_function.count(code) != 0)
|
|
|
|
{
|
|
|
|
Emu.Pause();
|
|
|
|
LOG_SUCCESS(HLE, "Autopause triggered at function 0x%08x", code);
|
|
|
|
return true;
|
2014-08-13 12:54:27 +00:00
|
|
|
}
|
2016-02-01 21:55:43 +00:00
|
|
|
|
|
|
|
return false;
|
2015-04-19 17:14:16 +00:00
|
|
|
}
|