mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-26 18:43:04 +00:00
Better locking in debug methods
This commit is contained in:
parent
40584e0e45
commit
81c399ec3e
1 changed files with 43 additions and 21 deletions
|
@ -1253,6 +1253,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
private void ThreadStart()
|
private void ThreadStart()
|
||||||
{
|
{
|
||||||
_schedulerWaitEvent.WaitOne();
|
_schedulerWaitEvent.WaitOne();
|
||||||
|
DebugHalt.Reset();
|
||||||
KernelStatic.SetKernelContext(KernelContext, this);
|
KernelStatic.SetKernelContext(KernelContext, this);
|
||||||
|
|
||||||
if (_customThreadStart != null)
|
if (_customThreadStart != null)
|
||||||
|
@ -1439,41 +1440,62 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
|
|
||||||
public bool DebugStep()
|
public bool DebugStep()
|
||||||
{
|
{
|
||||||
if (_debugState != (int)DebugState.Stopped || !Context.DebugStep())
|
lock (_activityOperationLock)
|
||||||
{
|
{
|
||||||
return false;
|
if (_debugState != (int)DebugState.Stopped
|
||||||
}
|
|| (_forcePauseFlags & ThreadSchedState.ThreadPauseFlag) == 0
|
||||||
|
|| !Context.DebugStep())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DebugHalt.Reset();
|
DebugHalt.Reset();
|
||||||
SetActivity(false);
|
Resume(ThreadSchedState.ThreadPauseFlag);
|
||||||
DebugHalt.WaitOne();
|
DebugHalt.WaitOne();
|
||||||
return true;
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DebugStop()
|
public void DebugStop()
|
||||||
{
|
{
|
||||||
if (Interlocked.CompareExchange(ref _debugState, (int)DebugState.Stopping,
|
lock (_activityOperationLock)
|
||||||
(int)DebugState.Running) != (int)DebugState.Running)
|
|
||||||
{
|
{
|
||||||
return;
|
if (Interlocked.CompareExchange(ref _debugState, (int)DebugState.Stopping,
|
||||||
}
|
(int)DebugState.Running) != (int)DebugState.Running)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Context.DebugStop();
|
if ((_forcePauseFlags & ThreadSchedState.ThreadPauseFlag) == 0)
|
||||||
DebugHalt.WaitOne();
|
{
|
||||||
DebugHalt.Reset();
|
Suspend(ThreadSchedState.ThreadPauseFlag);
|
||||||
_debugState = (int)DebugState.Stopped;
|
}
|
||||||
|
|
||||||
|
Context.DebugStop();
|
||||||
|
DebugHalt.WaitOne();
|
||||||
|
|
||||||
|
_debugState = (int)DebugState.Stopped;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DebugContinue()
|
public void DebugContinue()
|
||||||
{
|
{
|
||||||
if (Interlocked.CompareExchange(ref _debugState, (int)DebugState.Running,
|
lock (_activityOperationLock)
|
||||||
(int)DebugState.Stopped) != (int)DebugState.Stopped)
|
|
||||||
{
|
{
|
||||||
return;
|
if (Interlocked.CompareExchange(ref _debugState, (int)DebugState.Running,
|
||||||
}
|
(int)DebugState.Stopped) != (int)DebugState.Stopped)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Context.DebugContinue();
|
Context.DebugContinue();
|
||||||
SetActivity(false);
|
|
||||||
|
if ((_forcePauseFlags & ThreadSchedState.ThreadPauseFlag) != 0)
|
||||||
|
{
|
||||||
|
Resume(ThreadSchedState.ThreadPauseFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DebugState GetDebugState()
|
public DebugState GetDebugState()
|
||||||
|
|
Loading…
Reference in a new issue