Debugger: Fixed infrequent deadlock when switching games while debugger window is opened
This commit is contained in:
parent
cfad3c1f91
commit
9abaeaf8d8
2 changed files with 10 additions and 2 deletions
|
@ -163,6 +163,8 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
|
||||||
if(_debugger) {
|
if(_debugger) {
|
||||||
|
//Reset debugger if it was running before
|
||||||
|
auto lock = _debuggerLock.AcquireSafe();
|
||||||
StopDebugger();
|
StopDebugger();
|
||||||
GetDebugger();
|
GetDebugger();
|
||||||
}
|
}
|
||||||
|
@ -660,8 +662,13 @@ std::shared_ptr<Debugger> Console::GetDebugger(bool autoStart)
|
||||||
{
|
{
|
||||||
shared_ptr<Debugger> debugger = _debugger;
|
shared_ptr<Debugger> debugger = _debugger;
|
||||||
if(!debugger && autoStart) {
|
if(!debugger && autoStart) {
|
||||||
debugger.reset(new Debugger(Console::Instance, _cpu, _ppu, _apu, _memoryManager, _mapper));
|
//Lock to make sure we don't try to start debuggers in 2 separate threads at once
|
||||||
_debugger = debugger;
|
auto lock = _debuggerLock.AcquireSafe();
|
||||||
|
debugger = _debugger;
|
||||||
|
if(!debugger) {
|
||||||
|
debugger.reset(new Debugger(Console::Instance, _cpu, _ppu, _apu, _memoryManager, _mapper));
|
||||||
|
_debugger = debugger;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return debugger;
|
return debugger;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ class Console
|
||||||
SimpleLock _pauseLock;
|
SimpleLock _pauseLock;
|
||||||
SimpleLock _runLock;
|
SimpleLock _runLock;
|
||||||
SimpleLock _stopLock;
|
SimpleLock _stopLock;
|
||||||
|
SimpleLock _debuggerLock;
|
||||||
|
|
||||||
shared_ptr<RewindManager> _rewindManager;
|
shared_ptr<RewindManager> _rewindManager;
|
||||||
shared_ptr<CPU> _cpu;
|
shared_ptr<CPU> _cpu;
|
||||||
|
|
Loading…
Add table
Reference in a new issue