Handle GDB server reconnections
This commit is contained in:
parent
5e65fd8808
commit
de4ec65bd7
1 changed files with 43 additions and 32 deletions
|
@ -6,6 +6,7 @@ using Ryujinx.HLE.HOS.Kernel;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
@ -616,46 +617,56 @@ namespace Ryujinx.HLE.Debugger
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
switch (ReadStream.ReadByte())
|
try
|
||||||
{
|
{
|
||||||
case -1:
|
switch (ReadStream.ReadByte())
|
||||||
goto eof;
|
{
|
||||||
case '+':
|
case -1:
|
||||||
continue;
|
goto eof;
|
||||||
case '-':
|
case '+':
|
||||||
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
|
continue;
|
||||||
continue;
|
case '-':
|
||||||
case '\x03':
|
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
|
||||||
Messages.Add(new BreakInMessage());
|
continue;
|
||||||
break;
|
case '\x03':
|
||||||
case '$':
|
Messages.Add(new BreakInMessage());
|
||||||
string cmd = "";
|
break;
|
||||||
while (true)
|
case '$':
|
||||||
{
|
string cmd = "";
|
||||||
int x = ReadStream.ReadByte();
|
while (true)
|
||||||
if (x == -1)
|
{
|
||||||
goto eof;
|
int x = ReadStream.ReadByte();
|
||||||
if (x == '#')
|
if (x == -1)
|
||||||
break;
|
goto eof;
|
||||||
cmd += (char)x;
|
if (x == '#')
|
||||||
}
|
break;
|
||||||
|
cmd += (char)x;
|
||||||
|
}
|
||||||
|
|
||||||
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}")
|
||||||
{
|
{
|
||||||
Messages.Add(new CommandMessage(cmd));
|
Messages.Add(new CommandMessage(cmd));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Messages.Add(new SendNackMessage());
|
Messages.Add(new SendNackMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
goto eof;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eof:
|
eof:
|
||||||
Logger.Notice.Print(LogClass.GdbStub, "GDB client lost connection");
|
Logger.Notice.Print(LogClass.GdbStub, "GDB client lost connection");
|
||||||
|
ReadStream.Close();
|
||||||
|
WriteStream.Close();
|
||||||
|
ClientSocket.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue