1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00
rpcs3/Utilities/AutoPause.cpp

74 lines
1.7 KiB
C++
Raw Normal View History

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