Make suspension on start work

This commit is contained in:
svc64 2023-12-22 22:15:09 +02:00
parent 1bf244173d
commit 8a1c48e035
8 changed files with 24 additions and 13 deletions

View File

@ -674,8 +674,8 @@ namespace Ryujinx.UI.Windows
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value = (int)_scalingFilterLevel.Value;
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value = _multiLanSelect.ActiveId;
ConfigurationState.Instance.Debug.EnableGdbStub.Value = _gdbStubToggle.Active;
ConfigurationState.Instance.Debug.DebuggerSuspendOnStart.Value = _suspendOnStartToggle.Active;
ConfigurationState.Instance.Debug.GdbStubPort.Value = (ushort)_gdbStubPortSpinAdjustment.Value;
ConfigurationState.Instance.Debug.DebuggerSuspendOnStart.Value = _suspendOnStartToggle.Active;
_previousVolumeLevel = ConfigurationState.Instance.System.AudioVolume.Value;

View File

@ -21,7 +21,6 @@ namespace Ryujinx.HLE.Debugger
internal Switch Device { get; private set; }
public ushort GdbStubPort { get; private set; }
public bool SuspendOnStart { get; private set; }
private TcpListener ListenerSocket;
private Socket ClientSocket = null;
@ -35,11 +34,10 @@ namespace Ryujinx.HLE.Debugger
private ulong? cThread;
private ulong? gThread;
public Debugger(Switch device, ushort port, bool suspendOnStart)
public Debugger(Switch device, ushort port)
{
Device = device;
GdbStubPort = port;
SuspendOnStart = suspendOnStart;
ARMeilleure.Optimizations.EnableDebugging = true;

View File

@ -93,6 +93,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public HleProcessDebugger Debugger { get; private set; }
public IDebuggableProcess DebugInterface { get; private set; }
protected int debugState = (int)DebugState.Running;
public KProcess(KernelContext context, bool allowCodeMemoryForJit = false) : base(context)
{
@ -685,6 +686,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
SetState(newState);
if (KernelContext.Device.Configuration.DebuggerSuspendOnStart && IsApplication)
{
mainThread.Suspend(ThreadSchedState.ThreadPauseFlag);
debugState = (int)DebugState.Stopped;
}
result = mainThread.Start();
if (result != Result.Success)
@ -1197,7 +1204,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
private readonly KProcess _parent;
private readonly KernelContext _kernelContext;
private KThread steppingThread;
private int _debugState = (int)DebugState.Running;
public DebuggerInterface(KProcess p)
{
@ -1208,7 +1214,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public void DebugStop()
{
if (Interlocked.CompareExchange(ref _debugState, (int)DebugState.Stopping,
if (Interlocked.CompareExchange(ref _parent.debugState, (int)DebugState.Stopping,
(int)DebugState.Running) != (int)DebugState.Running)
{
return;
@ -1225,13 +1231,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
}
}
_debugState = (int)DebugState.Stopped;
_parent.debugState = (int)DebugState.Stopped;
_kernelContext.CriticalSection.Leave();
}
public void DebugContinue()
{
if (Interlocked.CompareExchange(ref _debugState, (int)DebugState.Running,
if (Interlocked.CompareExchange(ref _parent.debugState, (int)DebugState.Running,
(int)DebugState.Stopped) != (int)DebugState.Stopped)
{
return;
@ -1250,7 +1256,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public bool DebugStep(KThread target)
{
if (_debugState != (int)DebugState.Stopped)
if (_parent.debugState != (int)DebugState.Stopped)
{
return false;
}
@ -1299,7 +1305,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public DebugState GetDebugState()
{
return (DebugState)_debugState;
return (DebugState)_parent.debugState;
}
public ulong[] GetThreadUids()

View File

@ -205,6 +205,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
Context.TpidrroEl0 = (long)_tlsAddress;
Context.DebugPc = _entrypoint;
ThreadUid = KernelContext.NewThreadUid();
Context.ThreadUid = ThreadUid;

View File

@ -54,7 +54,7 @@ namespace Ryujinx.HLE
AudioDeviceDriver = new CompatLayerHardwareDeviceDriver(Configuration.AudioDeviceDriver);
Memory = new MemoryBlock(Configuration.MemoryConfiguration.ToDramSize(), memoryAllocationFlags);
Gpu = new GpuContext(Configuration.GpuRenderer);
Debugger = Configuration.EnableGdbStub ? new Debugger.Debugger(this, Configuration.GdbStubPort, Configuration.DebuggerSuspendOnStart) : null;
Debugger = Configuration.EnableGdbStub ? new Debugger.Debugger(this, Configuration.GdbStubPort) : null;
System = new HOS.Horizon(this);
Statistics = new PerformanceStatistics();
Hid = new Hid(this, System.HidStorage);

View File

@ -397,9 +397,9 @@ namespace Ryujinx.UI.Common.Configuration
public ushort GdbStubPort { get; set; }
/// <summary>
/// Which TCP port should the GDB stub listen on
/// Suspend execution when starting an application
/// </summary>
public ushort DebuggerSuspendOnStart { get; set; }
public bool DebuggerSuspendOnStart { get; set; }
/// <summary>
/// Loads a configuration file from disk

View File

@ -805,6 +805,7 @@ namespace Ryujinx.UI.Common.Configuration
MultiplayerMode = Multiplayer.Mode,
EnableGdbStub = Debug.EnableGdbStub,
GdbStubPort = Debug.GdbStubPort,
DebuggerSuspendOnStart = Debug.DebuggerSuspendOnStart,
};
return configurationFile;
@ -964,6 +965,7 @@ namespace Ryujinx.UI.Common.Configuration
};
Debug.EnableGdbStub.Value = false;
Debug.GdbStubPort.Value = 55555;
Debug.DebuggerSuspendOnStart.Value = false;
}
public void Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
@ -1484,6 +1486,7 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileFormat.EnableGdbStub = false;
configurationFileFormat.GdbStubPort = 55555;
configurationFileFormat.DebuggerSuspendOnStart = false;
configurationFileUpdated = true;
}
@ -1616,6 +1619,7 @@ namespace Ryujinx.UI.Common.Configuration
Hid.InputConfig.Value = configurationFileFormat.InputConfig;
Debug.EnableGdbStub.Value = configurationFileFormat.EnableGdbStub;
Debug.GdbStubPort.Value = configurationFileFormat.GdbStubPort;
Debug.DebuggerSuspendOnStart.Value = configurationFileFormat.DebuggerSuspendOnStart;
if (Hid.InputConfig.Value == null)
{

View File

@ -511,6 +511,7 @@ namespace Ryujinx.Ava.UI.ViewModels
// Debug
EnableGdbStub = config.Debug.EnableGdbStub.Value;
GDBStubPort = config.Debug.GdbStubPort.Value;
DebuggerSuspendOnStart = config.Debug.DebuggerSuspendOnStart.Value;
}
public void SaveSettings()
@ -623,6 +624,7 @@ namespace Ryujinx.Ava.UI.ViewModels
// Debug
config.Debug.EnableGdbStub.Value = EnableGdbStub;
config.Debug.GdbStubPort.Value = GDBStubPort;
config.Debug.DebuggerSuspendOnStart.Value = DebuggerSuspendOnStart;
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);