Bring back the debugger message handler thread
This commit is contained in:
parent
5f5cb73baa
commit
0396997c17
1 changed files with 30 additions and 21 deletions
|
@ -28,6 +28,7 @@ namespace Ryujinx.HLE.Debugger
|
||||||
private NetworkStream WriteStream = null;
|
private NetworkStream WriteStream = null;
|
||||||
private BlockingCollection<IMessage> Messages = new BlockingCollection<IMessage>(1);
|
private BlockingCollection<IMessage> Messages = new BlockingCollection<IMessage>(1);
|
||||||
private Thread DebuggerThread;
|
private Thread DebuggerThread;
|
||||||
|
private Thread MessageHandlerThread;
|
||||||
private bool _shuttingDown = false;
|
private bool _shuttingDown = false;
|
||||||
|
|
||||||
private ulong? cThread;
|
private ulong? cThread;
|
||||||
|
@ -42,6 +43,8 @@ namespace Ryujinx.HLE.Debugger
|
||||||
|
|
||||||
DebuggerThread = new Thread(DebuggerThreadMain);
|
DebuggerThread = new Thread(DebuggerThreadMain);
|
||||||
DebuggerThread.Start();
|
DebuggerThread.Start();
|
||||||
|
MessageHandlerThread = new Thread(MessageHandlerMain);
|
||||||
|
MessageHandlerThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDebuggableProcess DebugProcess => Device.System.DebugGetApplicationProcess();
|
private IDebuggableProcess DebugProcess => Device.System.DebugGetApplicationProcess();
|
||||||
|
@ -138,29 +141,33 @@ namespace Ryujinx.HLE.Debugger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleMessage(IMessage msg)
|
private void MessageHandlerMain()
|
||||||
{
|
{
|
||||||
switch (msg)
|
while (!_shuttingDown)
|
||||||
{
|
{
|
||||||
case BreakInMessage:
|
IMessage msg = Messages.Take();
|
||||||
Logger.Notice.Print(LogClass.GdbStub, "Break-in requested");
|
switch (msg)
|
||||||
CommandQuery();
|
{
|
||||||
break;
|
case BreakInMessage:
|
||||||
|
Logger.Notice.Print(LogClass.GdbStub, "Break-in requested");
|
||||||
|
CommandQuery();
|
||||||
|
break;
|
||||||
|
|
||||||
case SendNackMessage:
|
case SendNackMessage:
|
||||||
WriteStream.WriteByte((byte)'-');
|
WriteStream.WriteByte((byte)'-');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CommandMessage { Command: var cmd }:
|
case CommandMessage { Command: var cmd }:
|
||||||
Logger.Debug?.Print(LogClass.GdbStub, $"Received Command: {cmd}");
|
Logger.Debug?.Print(LogClass.GdbStub, $"Received Command: {cmd}");
|
||||||
WriteStream.WriteByte((byte)'+');
|
WriteStream.WriteByte((byte)'+');
|
||||||
ProcessCommand(cmd);
|
ProcessCommand(cmd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ThreadBreakMessage { Context: var ctx }:
|
case ThreadBreakMessage { Context: var ctx }:
|
||||||
DebugProcess.DebugStop();
|
DebugProcess.DebugStop();
|
||||||
Reply($"T05thread:{ctx.ThreadUid:x};");
|
Reply($"T05thread:{ctx.ThreadUid:x};");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +628,7 @@ namespace Ryujinx.HLE.Debugger
|
||||||
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
|
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
|
||||||
continue;
|
continue;
|
||||||
case '\x03':
|
case '\x03':
|
||||||
HandleMessage(new BreakInMessage());
|
Messages.Add(new BreakInMessage());
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
string cmd = "";
|
string cmd = "";
|
||||||
|
@ -638,11 +645,11 @@ namespace Ryujinx.HLE.Debugger
|
||||||
string checksum = $"{(char)ReadStream.ReadByte()}{(char)ReadStream.ReadByte()}";
|
string checksum = $"{(char)ReadStream.ReadByte()}{(char)ReadStream.ReadByte()}";
|
||||||
if (checksum == $"{CalculateChecksum(cmd):x2}")
|
if (checksum == $"{CalculateChecksum(cmd):x2}")
|
||||||
{
|
{
|
||||||
HandleMessage(new CommandMessage(cmd));
|
Messages.Add(new CommandMessage(cmd));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HandleMessage(new SendNackMessage());
|
Messages.Add(new SendNackMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -725,6 +732,8 @@ namespace Ryujinx.HLE.Debugger
|
||||||
ReadStream?.Close();
|
ReadStream?.Close();
|
||||||
WriteStream?.Close();
|
WriteStream?.Close();
|
||||||
DebuggerThread.Join();
|
DebuggerThread.Join();
|
||||||
|
Messages.Dispose();
|
||||||
|
MessageHandlerThread.Join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue