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