mirror of
https://github.com/libretro/Mesen.git
synced 2024-12-13 20:42:24 +00:00
40 lines
791 B
C++
40 lines
791 B
C++
#pragma once
|
|
#include "stdafx.h"
|
|
#include "Debugger.h"
|
|
#include "Console.h"
|
|
|
|
class DebugBreakHelper
|
|
{
|
|
private:
|
|
Debugger* _debugger;
|
|
bool _needResume = false;
|
|
bool _isEmulationThread = false;
|
|
|
|
public:
|
|
DebugBreakHelper(Debugger* debugger)
|
|
{
|
|
_debugger = debugger;
|
|
|
|
_isEmulationThread = Console::GetEmulationThreadId() == std::this_thread::get_id();
|
|
|
|
if(!_isEmulationThread) {
|
|
//Only attempt to break if this is done in a thread other than the main emulation thread
|
|
debugger->PreventResume();
|
|
if(!debugger->IsExecutionStopped()) {
|
|
debugger->Step(1);
|
|
while(!debugger->IsExecutionStopped()) {}
|
|
_needResume = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
~DebugBreakHelper()
|
|
{
|
|
if(!_isEmulationThread) {
|
|
if(_needResume) {
|
|
_debugger->Run();
|
|
}
|
|
_debugger->AllowResume();
|
|
}
|
|
}
|
|
}; |