mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
34 lines
No EOL
707 B
C++
34 lines
No EOL
707 B
C++
#pragma once
|
|
#include "stdafx.h"
|
|
#include "Debugger/Debugger.h"
|
|
#include "Shared/Emulator.h"
|
|
|
|
class DebugBreakHelper
|
|
{
|
|
private:
|
|
Debugger * _debugger;
|
|
bool _needBreak = false;
|
|
|
|
public:
|
|
DebugBreakHelper(Debugger* debugger)
|
|
{
|
|
_debugger = debugger;
|
|
|
|
_needBreak = debugger->GetEmulator()->GetEmulationThreadId() != std::this_thread::get_id();
|
|
|
|
if(_needBreak) {
|
|
//Only attempt to break if this is done in a thread other than the main emulation thread (and the debugger is active)
|
|
debugger->BreakRequest(false);
|
|
if(!debugger->IsExecutionStopped()) {
|
|
while(!debugger->IsExecutionStopped()) {}
|
|
}
|
|
}
|
|
}
|
|
|
|
~DebugBreakHelper()
|
|
{
|
|
if(_needBreak) {
|
|
_debugger->BreakRequest(true);
|
|
}
|
|
}
|
|
}; |