2019-03-07 20:12:32 -05:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Debugger.h"
|
|
|
|
#include "Console.h"
|
|
|
|
|
|
|
|
class DebugBreakHelper
|
|
|
|
{
|
|
|
|
private:
|
2021-03-10 11:13:28 -05:00
|
|
|
Debugger * _debugger;
|
2019-03-07 20:12:32 -05:00
|
|
|
bool _needResume = false;
|
|
|
|
bool _isEmulationThread = false;
|
|
|
|
|
|
|
|
public:
|
|
|
|
DebugBreakHelper(Debugger* debugger)
|
|
|
|
{
|
|
|
|
_debugger = debugger;
|
|
|
|
|
|
|
|
_isEmulationThread = debugger->GetConsole()->GetEmulationThreadId() == std::this_thread::get_id();
|
|
|
|
|
2021-03-10 11:13:28 -05:00
|
|
|
if(!_isEmulationThread) {
|
2019-03-07 20:12:32 -05:00
|
|
|
//Only attempt to break if this is done in a thread other than the main emulation thread
|
2019-05-14 19:27:45 -04:00
|
|
|
debugger->BreakRequest(false);
|
2021-03-10 11:13:28 -05:00
|
|
|
if(!debugger->IsExecutionStopped()) {
|
|
|
|
while(!debugger->IsExecutionStopped()) {}
|
2019-03-07 20:12:32 -05:00
|
|
|
_needResume = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~DebugBreakHelper()
|
|
|
|
{
|
2021-03-10 11:13:28 -05:00
|
|
|
if(!_isEmulationThread) {
|
2019-05-14 19:27:45 -04:00
|
|
|
_debugger->BreakRequest(true);
|
2019-03-07 20:12:32 -05:00
|
|
|
}
|
|
|
|
}
|
2021-03-10 11:13:28 -05:00
|
|
|
};
|