mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
Auto-Pause At Function Call and System Call.
Would have a configuration window (with create the list, and enable/disable, being something similar to VFSManger and etc). Move the code to Debug::AutoPause in AutoPause.cpp and AutoPause.h It triggers currently in GameViewer, and would finally change to somewhere else. Well and now it is all enabled (Function call + System call) by default.
This commit is contained in:
parent
36ab30d3e9
commit
ea00c3a07f
8 changed files with 175 additions and 49 deletions
130
Utilities/AutoPause.cpp
Normal file
130
Utilities/AutoPause.cpp
Normal file
|
@ -0,0 +1,130 @@
|
|||
#include "stdafx.h"
|
||||
#include "AutoPause.h"
|
||||
|
||||
using namespace Debug;
|
||||
|
||||
//Even different from those tutorials on webpages, i use the method similiar from Log.h
|
||||
//TODO:: Question: Does such a Singleton struct get fully deallocated after its pointer?
|
||||
AutoPause* gAutoPause = nullptr;
|
||||
|
||||
AutoPause& AutoPause::getInstance(void)
|
||||
{
|
||||
if (!gAutoPause)
|
||||
{
|
||||
gAutoPause = new AutoPause();
|
||||
}
|
||||
return *gAutoPause;
|
||||
}
|
||||
|
||||
//Still use binary format. Default Setting should be "disable all auto-pause".
|
||||
AutoPause::AutoPause(void)
|
||||
{
|
||||
m_pause_function.reserve(16);
|
||||
m_pause_syscall.reserve(16);
|
||||
initialized = false;
|
||||
//Reload(false, false);
|
||||
Reload(true, true); //Temporarily use auto enable
|
||||
}
|
||||
|
||||
//Notice: I would not allow to write the binary to file in this command.
|
||||
AutoPause::~AutoPause(void)
|
||||
{
|
||||
initialized = false;
|
||||
m_pause_function.clear();
|
||||
m_pause_syscall.clear();
|
||||
m_pause_function_enable = false;
|
||||
m_pause_syscall_enable = false;
|
||||
}
|
||||
|
||||
//Load Auto-Pause Configuration from file "pause.bin"
|
||||
//This would be able to create in a GUI window.
|
||||
void AutoPause::Reload(void)
|
||||
{
|
||||
if (rExists("pause.bin"))
|
||||
{
|
||||
m_pause_function.clear();
|
||||
m_pause_function.reserve(16);
|
||||
m_pause_syscall.clear();
|
||||
m_pause_syscall.reserve(16);
|
||||
|
||||
rFile list;
|
||||
list.Open("pause.bin", rFile::read);
|
||||
//System calls ID and Function calls ID are all u32 iirc.
|
||||
u32 num;
|
||||
size_t fmax = list.Length();
|
||||
size_t fcur = 0;
|
||||
list.Seek(0);
|
||||
while (fcur <= fmax - sizeof(u32))
|
||||
{
|
||||
list.Read(&num, sizeof(u32));
|
||||
fcur += sizeof(u32);
|
||||
if (num == 0xFFFFFFFF) break;
|
||||
|
||||
if (num < 1024)
|
||||
{
|
||||
//Less than 1024 - be regarded as a system call.
|
||||
//emplace_back may not cause reductant move/copy operation.
|
||||
m_pause_syscall.emplace_back(num);
|
||||
LOG_WARNING(HLE, "Auto-Pause: Find System Call ID %x", num);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pause_function.emplace_back(num);
|
||||
LOG_WARNING(HLE, "Auto-Pause: Find Function Call ID %x", num);
|
||||
}
|
||||
}
|
||||
list.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING(HLE, "No Pause ID specified in pause.bin, Auto-Pause would not act.");
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void AutoPause::Reload(bool enable_pause_syscall, bool enable_pause_function)
|
||||
{
|
||||
Reload();
|
||||
m_pause_syscall_enable = enable_pause_syscall;
|
||||
m_pause_function_enable = enable_pause_function;
|
||||
}
|
||||
|
||||
void AutoPause::TryPause(u32 code) {
|
||||
if (code < 1024)
|
||||
{
|
||||
//Would first check Enable setting. Then the list length.
|
||||
if ((!m_pause_syscall_enable)
|
||||
|| (m_pause_syscall.size() <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < m_pause_syscall.size(); ++i)
|
||||
{
|
||||
if (code == m_pause_syscall[i])
|
||||
{
|
||||
Emu.Pause();
|
||||
LOG_ERROR(HLE, "Auto-Pause Triggered: System call %x", code); //Used Error
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Well similiar.. Seperate the list caused by possible setting difference.
|
||||
if ((!m_pause_function_enable)
|
||||
|| (m_pause_function.size() <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < m_pause_function.size(); ++i)
|
||||
{
|
||||
if (code == m_pause_function[i])
|
||||
{
|
||||
Emu.Pause();
|
||||
LOG_ERROR(HLE, "Auto-Pause Triggered: Function call %x", code); //Used Error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue