gdb: more cleanups
- convert GdbRegisters utilities into extensions on IExecutionContext - add a Write/Read Register helper on Debugger that handles 32/64 bit instead of doing that for every usage of register reading/writing
This commit is contained in:
parent
2a2ab523cb
commit
e11eff0f41
4 changed files with 26 additions and 33 deletions
|
|
@ -112,15 +112,22 @@ namespace Ryujinx.HLE.Debugger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal bool WriteRegister(IExecutionContext ctx, int gdbRegId, StringStream ss) =>
|
||||||
|
IsProcess32Bit
|
||||||
|
? ctx.WriteRegister32(gdbRegId, ss)
|
||||||
|
: ctx.WriteRegister64(gdbRegId, ss);
|
||||||
|
|
||||||
|
internal string ReadRegister(IExecutionContext ctx, int gdbRegId) =>
|
||||||
|
IsProcess32Bit
|
||||||
|
? ctx.ReadRegister32(gdbRegId)
|
||||||
|
: ctx.ReadRegister64(gdbRegId);
|
||||||
|
|
||||||
public string GetStackTrace()
|
public string GetStackTrace()
|
||||||
{
|
{
|
||||||
if (GThread == null)
|
if (GThread == null)
|
||||||
return "No thread selected\n";
|
return "No thread selected\n";
|
||||||
|
|
||||||
if (Process == null)
|
return Process?.Debugger?.GetGuestStackTrace(DebugProcess.GetThread(GThread.Value)) ?? "No application process found\n";
|
||||||
return "No application process found\n";
|
|
||||||
|
|
||||||
return Process.Debugger.GetGuestStackTrace(DebugProcess.GetThread(GThread.Value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRegisters()
|
public string GetRegisters()
|
||||||
|
|
@ -128,10 +135,7 @@ namespace Ryujinx.HLE.Debugger
|
||||||
if (GThread == null)
|
if (GThread == null)
|
||||||
return "No thread selected\n";
|
return "No thread selected\n";
|
||||||
|
|
||||||
if (Process == null)
|
return Process?.Debugger?.GetCpuRegisterPrintout(DebugProcess.GetThread(GThread.Value)) ?? "No application process found\n";
|
||||||
return "No application process found\n";
|
|
||||||
|
|
||||||
return Process.Debugger.GetCpuRegisterPrintout(DebugProcess.GetThread(GThread.Value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetMinidump()
|
public string GetMinidump()
|
||||||
|
|
|
||||||
|
|
@ -105,14 +105,14 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
{
|
{
|
||||||
for (int i = 0; i < GdbRegisterCount32; i++)
|
for (int i = 0; i < GdbRegisterCount32; i++)
|
||||||
{
|
{
|
||||||
registers += GdbRegisters.Read32(ctx, i);
|
registers += ctx.ReadRegister32(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < GdbRegisterCount64; i++)
|
for (int i = 0; i < GdbRegisterCount64; i++)
|
||||||
{
|
{
|
||||||
registers += GdbRegisters.Read64(ctx, i);
|
registers += ctx.ReadRegister64(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,7 +132,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
{
|
{
|
||||||
for (int i = 0; i < GdbRegisterCount32; i++)
|
for (int i = 0; i < GdbRegisterCount32; i++)
|
||||||
{
|
{
|
||||||
if (!GdbRegisters.Write32(ctx, i, ss))
|
if (!ctx.WriteRegister32(i, ss))
|
||||||
{
|
{
|
||||||
Processor.ReplyError();
|
Processor.ReplyError();
|
||||||
return;
|
return;
|
||||||
|
|
@ -143,7 +143,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
{
|
{
|
||||||
for (int i = 0; i < GdbRegisterCount64; i++)
|
for (int i = 0; i < GdbRegisterCount64; i++)
|
||||||
{
|
{
|
||||||
if (!GdbRegisters.Write64(ctx, i, ss))
|
if (!ctx.WriteRegister64(i, ss))
|
||||||
{
|
{
|
||||||
Processor.ReplyError();
|
Processor.ReplyError();
|
||||||
return;
|
return;
|
||||||
|
|
@ -236,9 +236,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
}
|
}
|
||||||
|
|
||||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||||
string result = Debugger.IsProcess32Bit
|
string result = Debugger.ReadRegister(ctx, gdbRegId);
|
||||||
? GdbRegisters.Read32(ctx, gdbRegId)
|
|
||||||
: GdbRegisters.Read64(ctx, gdbRegId);
|
|
||||||
|
|
||||||
Processor.Reply(result != null, result);
|
Processor.Reply(result != null, result);
|
||||||
}
|
}
|
||||||
|
|
@ -252,14 +250,8 @@ 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)
|
|
||||||
{
|
Processor.Reply(Debugger.WriteRegister(ctx, gdbRegId, ss) && ss.IsEmpty());
|
||||||
Processor.Reply(GdbRegisters.Write32(ctx, gdbRegId, ss) && ss.IsEmpty());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Processor.Reply(GdbRegisters.Write64(ctx, gdbRegId, ss) && ss.IsEmpty());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Step(ulong? newPc)
|
internal void Step(ulong? newPc)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
*/
|
*/
|
||||||
private const uint FpcrMask = 0xfc1fffff;
|
private const uint FpcrMask = 0xfc1fffff;
|
||||||
|
|
||||||
public static string Read64(IExecutionContext state, int gdbRegId)
|
public static string ReadRegister64(this IExecutionContext state, int gdbRegId)
|
||||||
{
|
{
|
||||||
switch (gdbRegId)
|
switch (gdbRegId)
|
||||||
{
|
{
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Write64(IExecutionContext state, int gdbRegId, StringStream ss)
|
public static bool WriteRegister64(this IExecutionContext state, int gdbRegId, StringStream ss)
|
||||||
{
|
{
|
||||||
switch (gdbRegId)
|
switch (gdbRegId)
|
||||||
{
|
{
|
||||||
|
|
@ -80,7 +80,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Read32(IExecutionContext state, int gdbRegId)
|
public static string ReadRegister32(this IExecutionContext state, int gdbRegId)
|
||||||
{
|
{
|
||||||
switch (gdbRegId)
|
switch (gdbRegId)
|
||||||
{
|
{
|
||||||
|
|
@ -106,7 +106,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Write32(IExecutionContext state, int gdbRegId, StringStream ss)
|
public static bool WriteRegister32(this IExecutionContext state, int gdbRegId, StringStream ss)
|
||||||
{
|
{
|
||||||
switch (gdbRegId)
|
switch (gdbRegId)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,9 @@ namespace Ryujinx.HLE.Debugger
|
||||||
|
|
||||||
private static string GetEmbeddedResourceContent(string resourceName)
|
private static string GetEmbeddedResourceContent(string resourceName)
|
||||||
{
|
{
|
||||||
Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.HLE.Debugger.Gdb.Xml." + resourceName);
|
using Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.HLE.Debugger.Gdb.Xml." + resourceName);
|
||||||
StreamReader reader = new(stream);
|
using StreamReader reader = new(stream);
|
||||||
string result = reader.ReadToEnd();
|
return reader.ReadToEnd();
|
||||||
reader.Dispose();
|
|
||||||
stream.Dispose();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue