Bring back the debugger message handler thread

This commit is contained in:
svc64 2023-12-12 20:29:33 +02:00
parent 5f5cb73baa
commit 0396997c17

View file

@ -28,6 +28,7 @@ namespace Ryujinx.HLE.Debugger
private NetworkStream WriteStream = null;
private BlockingCollection<IMessage> Messages = new BlockingCollection<IMessage>(1);
private Thread DebuggerThread;
private Thread MessageHandlerThread;
private bool _shuttingDown = false;
private ulong? cThread;
@ -42,6 +43,8 @@ namespace Ryujinx.HLE.Debugger
DebuggerThread = new Thread(DebuggerThreadMain);
DebuggerThread.Start();
MessageHandlerThread = new Thread(MessageHandlerMain);
MessageHandlerThread.Start();
}
private IDebuggableProcess DebugProcess => Device.System.DebugGetApplicationProcess();
@ -138,8 +141,11 @@ namespace Ryujinx.HLE.Debugger
}
}
private void HandleMessage(IMessage msg)
private void MessageHandlerMain()
{
while (!_shuttingDown)
{
IMessage msg = Messages.Take();
switch (msg)
{
case BreakInMessage:
@ -163,6 +169,7 @@ namespace Ryujinx.HLE.Debugger
break;
}
}
}
private void ProcessCommand(string cmd)
{
@ -621,7 +628,7 @@ namespace Ryujinx.HLE.Debugger
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
continue;
case '\x03':
HandleMessage(new BreakInMessage());
Messages.Add(new BreakInMessage());
break;
case '$':
string cmd = "";
@ -638,11 +645,11 @@ namespace Ryujinx.HLE.Debugger
string checksum = $"{(char)ReadStream.ReadByte()}{(char)ReadStream.ReadByte()}";
if (checksum == $"{CalculateChecksum(cmd):x2}")
{
HandleMessage(new CommandMessage(cmd));
Messages.Add(new CommandMessage(cmd));
}
else
{
HandleMessage(new SendNackMessage());
Messages.Add(new SendNackMessage());
}
break;
@ -725,6 +732,8 @@ namespace Ryujinx.HLE.Debugger
ReadStream?.Close();
WriteStream?.Close();
DebuggerThread.Join();
Messages.Dispose();
MessageHandlerThread.Join();
}
}