mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-10-25 07:34:25 +00:00
gdb: some more cleanups
This commit is contained in:
@@ -60,7 +60,6 @@ namespace Ryujinx.HLE.Debugger
|
||||
_readStream = new NetworkStream(_clientSocket, System.IO.FileAccess.Read);
|
||||
_writeStream = new NetworkStream(_clientSocket, System.IO.FileAccess.Write);
|
||||
_commands = new GdbCommands(_listenerSocket, _clientSocket, _readStream, _writeStream, this);
|
||||
_commandProcessor = _commands.CreateProcessor();
|
||||
|
||||
Logger.Notice.Print(LogClass.GdbStub, "GDB client connected");
|
||||
|
||||
@@ -119,7 +118,6 @@ namespace Ryujinx.HLE.Debugger
|
||||
_writeStream = null;
|
||||
_clientSocket.Close();
|
||||
_clientSocket = null;
|
||||
_commandProcessor = null;
|
||||
_commands = null;
|
||||
|
||||
BreakpointManager.ClearAll();
|
||||
|
||||
@@ -29,14 +29,14 @@ namespace Ryujinx.HLE.Debugger
|
||||
case CommandMessage { Command: { } cmd }:
|
||||
Logger.Debug?.Print(LogClass.GdbStub, $"Received Command: {cmd}");
|
||||
_writeStream.WriteByte((byte)'+');
|
||||
_commandProcessor.Process(cmd);
|
||||
_commands.Processor.Process(cmd);
|
||||
break;
|
||||
|
||||
case ThreadBreakMessage { Context: { } ctx }:
|
||||
DebugProcess.DebugStop();
|
||||
GThread = CThread = ctx.ThreadUid;
|
||||
_breakHandlerEvent.Set();
|
||||
_commandProcessor.Reply($"T05thread:{ctx.ThreadUid:x};");
|
||||
_commands.Processor.Reply($"T05thread:{ctx.ThreadUid:x};");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
private Socket _clientSocket;
|
||||
private NetworkStream _readStream;
|
||||
private NetworkStream _writeStream;
|
||||
|
||||
private GdbCommandProcessor _commandProcessor;
|
||||
|
||||
private GdbCommands _commands;
|
||||
|
||||
private bool _shuttingDown;
|
||||
|
||||
@@ -11,19 +11,18 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
{
|
||||
class GdbCommands
|
||||
{
|
||||
const int GdbRegisterCount64 = 68;
|
||||
const int GdbRegisterCount32 = 66;
|
||||
|
||||
public readonly Debugger Debugger;
|
||||
|
||||
public GdbCommandProcessor Processor { get; private set; }
|
||||
private GdbCommandProcessor _processor;
|
||||
|
||||
public GdbCommandProcessor Processor
|
||||
=> _processor ??= new GdbCommandProcessor(this);
|
||||
|
||||
internal readonly TcpListener ListenerSocket;
|
||||
internal readonly Socket ClientSocket;
|
||||
internal readonly NetworkStream ReadStream;
|
||||
internal readonly NetworkStream WriteStream;
|
||||
|
||||
|
||||
public GdbCommands(TcpListener listenerSocket, Socket clientSocket, NetworkStream readStream,
|
||||
NetworkStream writeStream, Debugger debugger)
|
||||
{
|
||||
@@ -34,21 +33,6 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
Debugger = debugger;
|
||||
}
|
||||
|
||||
public void SetProcessor(GdbCommandProcessor commandProcessor)
|
||||
{
|
||||
if (Processor != null) return;
|
||||
|
||||
Processor = commandProcessor;
|
||||
}
|
||||
|
||||
public GdbCommandProcessor CreateProcessor()
|
||||
{
|
||||
if (Processor != null)
|
||||
return Processor;
|
||||
|
||||
return Processor = new GdbCommandProcessor(this);
|
||||
}
|
||||
|
||||
internal void Query()
|
||||
{
|
||||
// GDB is performing initial contact. Stop everything.
|
||||
@@ -104,14 +88,14 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
string registers = string.Empty;
|
||||
if (Debugger.IsProcess32Bit)
|
||||
{
|
||||
for (int i = 0; i < GdbRegisterCount32; i++)
|
||||
for (int i = 0; i < GdbRegisters.Count32; i++)
|
||||
{
|
||||
registers += ctx.ReadRegister32(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < GdbRegisterCount64; i++)
|
||||
for (int i = 0; i < GdbRegisters.Count64; i++)
|
||||
{
|
||||
registers += ctx.ReadRegister64(i);
|
||||
}
|
||||
@@ -131,7 +115,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
if (Debugger.IsProcess32Bit)
|
||||
{
|
||||
for (int i = 0; i < GdbRegisterCount32; i++)
|
||||
for (int i = 0; i < GdbRegisters.Count32; i++)
|
||||
{
|
||||
if (!ctx.WriteRegister32(i, ss))
|
||||
{
|
||||
@@ -142,7 +126,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < GdbRegisterCount64; i++)
|
||||
for (int i = 0; i < GdbRegisters.Count64; i++)
|
||||
{
|
||||
if (!ctx.WriteRegister64(i, ss))
|
||||
{
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
{
|
||||
static class GdbRegisters
|
||||
{
|
||||
public const int Count64 = 68;
|
||||
public const int Count32 = 66;
|
||||
|
||||
/*
|
||||
FPCR = FPSR & ~FpcrMask
|
||||
All of FPCR's bits are reserved in FPCR and vice versa,
|
||||
|
||||
Reference in New Issue
Block a user