gdb: More cleanup changes
- Move the message handler into its debugger class part, - Move all message types into one file and collapse 3 of the ones with no data into a generic, stateless message with a single property being its type, - Add an Fpscr helper property on IExecutionContext along with a comment about what Fpscr is (similar to the other registers in there) - Moved the Rcmd helpers (such as GetRegisters, GetMinidump, etc) into a dedicated Debugger class part, - Fixed the double-collection (ToArray being called twice) in GetThreadUids & GetThread in KProcess
This commit is contained in:
parent
6058af5119
commit
247e2e03d6
19 changed files with 319 additions and 328 deletions
|
|
@ -42,6 +42,11 @@ namespace Ryujinx.Cpu
|
||||||
/// </summary>
|
/// </summary>
|
||||||
uint Fpsr { get; set; }
|
uint Fpsr { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Floating-point Status and Control Register.
|
||||||
|
/// </summary>
|
||||||
|
uint Fpscr => Fpsr | Fpcr;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates whenever the CPU is running 64-bit (AArch64 mode) or 32-bit (AArch32 mode) code.
|
/// Indicates whenever the CPU is running 64-bit (AArch64 mode) or 32-bit (AArch32 mode) code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,10 @@ namespace Ryujinx.HLE.Debugger
|
||||||
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
|
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
|
||||||
continue;
|
continue;
|
||||||
case '\x03':
|
case '\x03':
|
||||||
_messages.Add(new BreakInMessage());
|
_messages.Add(StatelessMessage.BreakIn);
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
string cmd = "";
|
string cmd = string.Empty;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int x = _readStream.ReadByte();
|
int x = _readStream.ReadByte();
|
||||||
|
|
@ -85,7 +85,7 @@ namespace Ryujinx.HLE.Debugger
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_messages.Add(new SendNackMessage());
|
_messages.Add(StatelessMessage.SendNack);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
58
src/Ryujinx.HLE/Debugger/Debugger.MessageHandler.cs
Normal file
58
src/Ryujinx.HLE/Debugger/Debugger.MessageHandler.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.Debugger
|
||||||
|
{
|
||||||
|
public partial class Debugger
|
||||||
|
{
|
||||||
|
private void MessageHandlerMain()
|
||||||
|
{
|
||||||
|
while (!_shuttingDown)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (_messages.Take())
|
||||||
|
{
|
||||||
|
case StatelessMessage { Type: MessageType.BreakIn }:
|
||||||
|
Logger.Notice.Print(LogClass.GdbStub, "Break-in requested");
|
||||||
|
_commands.Interrupt();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case StatelessMessage { Type: MessageType.SendNack }:
|
||||||
|
_writeStream.WriteByte((byte)'-');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case StatelessMessage { Type: MessageType.Kill }:
|
||||||
|
return;
|
||||||
|
|
||||||
|
case CommandMessage { Command: { } cmd }:
|
||||||
|
Logger.Debug?.Print(LogClass.GdbStub, $"Received Command: {cmd}");
|
||||||
|
_writeStream.WriteByte((byte)'+');
|
||||||
|
_commandProcessor.Process(cmd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ThreadBreakMessage { Context: { } ctx }:
|
||||||
|
DebugProcess.DebugStop();
|
||||||
|
GThread = CThread = ctx.ThreadUid;
|
||||||
|
_breakHandlerEvent.Set();
|
||||||
|
_commandProcessor.Reply($"T05thread:{ctx.ThreadUid:x};");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
||||||
|
}
|
||||||
|
catch (NullReferenceException e)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException e)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
103
src/Ryujinx.HLE/Debugger/Debugger.Rcmd.cs
Normal file
103
src/Ryujinx.HLE/Debugger/Debugger.Rcmd.cs
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.Debugger
|
||||||
|
{
|
||||||
|
public partial class Debugger
|
||||||
|
{
|
||||||
|
public string GetStackTrace()
|
||||||
|
{
|
||||||
|
if (GThread == null)
|
||||||
|
return "No thread selected\n";
|
||||||
|
|
||||||
|
return Process?.Debugger?.GetGuestStackTrace(DebugProcess.GetThread(GThread.Value)) ?? "No application process found\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetRegisters()
|
||||||
|
{
|
||||||
|
if (GThread == null)
|
||||||
|
return "No thread selected\n";
|
||||||
|
|
||||||
|
return Process?.Debugger?.GetCpuRegisterPrintout(DebugProcess.GetThread(GThread.Value)) ?? "No application process found\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetMinidump()
|
||||||
|
{
|
||||||
|
var response = new StringBuilder();
|
||||||
|
response.AppendLine("=== Begin Minidump ===\n");
|
||||||
|
response.AppendLine(GetProcessInfo());
|
||||||
|
|
||||||
|
foreach (var thread in GetThreads())
|
||||||
|
{
|
||||||
|
response.AppendLine($"=== Thread {thread.ThreadUid} ===");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string stackTrace = Process.Debugger.GetGuestStackTrace(thread);
|
||||||
|
response.AppendLine(stackTrace);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
response.AppendLine($"[Error getting stack trace: {e.Message}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string registers = Process.Debugger.GetCpuRegisterPrintout(thread);
|
||||||
|
response.AppendLine(registers);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
response.AppendLine($"[Error getting registers: {e.Message}]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response.AppendLine("=== End Minidump ===");
|
||||||
|
|
||||||
|
Logger.Info?.Print(LogClass.GdbStub, response.ToString());
|
||||||
|
return response.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetProcessInfo()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Process is not { } kProcess)
|
||||||
|
return "No application process found\n";
|
||||||
|
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.AppendLine($"Program Id: 0x{kProcess.TitleId:x16}");
|
||||||
|
sb.AppendLine($"Application: {(kProcess.IsApplication ? 1 : 0)}");
|
||||||
|
sb.AppendLine("Layout:");
|
||||||
|
sb.AppendLine(
|
||||||
|
$" Alias: 0x{kProcess.MemoryManager.AliasRegionStart:x10} - 0x{kProcess.MemoryManager.AliasRegionEnd - 1:x10}");
|
||||||
|
sb.AppendLine(
|
||||||
|
$" Heap: 0x{kProcess.MemoryManager.HeapRegionStart:x10} - 0x{kProcess.MemoryManager.HeapRegionEnd - 1:x10}");
|
||||||
|
sb.AppendLine(
|
||||||
|
$" Aslr: 0x{kProcess.MemoryManager.AslrRegionStart:x10} - 0x{kProcess.MemoryManager.AslrRegionEnd - 1:x10}");
|
||||||
|
sb.AppendLine(
|
||||||
|
$" Stack: 0x{kProcess.MemoryManager.StackRegionStart:x10} - 0x{kProcess.MemoryManager.StackRegionEnd - 1:x10}");
|
||||||
|
|
||||||
|
sb.AppendLine("Modules:");
|
||||||
|
var debugger = kProcess.Debugger;
|
||||||
|
if (debugger != null)
|
||||||
|
{
|
||||||
|
foreach (HleProcessDebugger.Image image in debugger.GetLoadedImages())
|
||||||
|
{
|
||||||
|
ulong endAddress = image.BaseAddress + image.Size - 1;
|
||||||
|
sb.AppendLine($" 0x{image.BaseAddress:x10} - 0x{endAddress:x10} {image.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.GdbStub, $"Error getting process info: {e.Message}");
|
||||||
|
return $"Error getting process info: {e.Message}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -57,172 +57,24 @@ namespace Ryujinx.HLE.Debugger
|
||||||
internal KProcess Process => Device.System?.DebugGetApplicationProcess();
|
internal KProcess Process => Device.System?.DebugGetApplicationProcess();
|
||||||
internal IDebuggableProcess DebugProcess => Device.System?.DebugGetApplicationProcessDebugInterface();
|
internal IDebuggableProcess DebugProcess => Device.System?.DebugGetApplicationProcessDebugInterface();
|
||||||
|
|
||||||
internal KThread[] GetThreads() =>
|
internal KThread[] GetThreads() => DebugProcess.ThreadUids.Select(DebugProcess.GetThread).ToArray();
|
||||||
DebugProcess.GetThreadUids().Select(x => DebugProcess.GetThread(x)).ToArray();
|
|
||||||
|
|
||||||
internal bool IsProcess32Bit => DebugProcess.GetThread(GThread.Value).Context.IsAarch32;
|
internal bool IsProcess32Bit => DebugProcess.GetThread(GThread.Value).Context.IsAarch32;
|
||||||
|
|
||||||
private void MessageHandlerMain()
|
internal bool WriteRegister(IExecutionContext ctx, int registerId, StringStream ss) =>
|
||||||
{
|
|
||||||
while (!_shuttingDown)
|
|
||||||
{
|
|
||||||
IMessage msg = _messages.Take();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case BreakInMessage:
|
|
||||||
Logger.Notice.Print(LogClass.GdbStub, "Break-in requested");
|
|
||||||
_commandProcessor.Commands.Interrupt();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SendNackMessage:
|
|
||||||
_writeStream.WriteByte((byte)'-');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CommandMessage { Command: var cmd }:
|
|
||||||
Logger.Debug?.Print(LogClass.GdbStub, $"Received Command: {cmd}");
|
|
||||||
_writeStream.WriteByte((byte)'+');
|
|
||||||
_commandProcessor.Process(cmd);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ThreadBreakMessage { Context: var ctx }:
|
|
||||||
DebugProcess.DebugStop();
|
|
||||||
GThread = CThread = ctx.ThreadUid;
|
|
||||||
_breakHandlerEvent.Set();
|
|
||||||
_commandProcessor.Reply($"T05thread:{ctx.ThreadUid:x};");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KillMessage:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
|
||||||
}
|
|
||||||
catch (NullReferenceException e)
|
|
||||||
{
|
|
||||||
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
|
||||||
}
|
|
||||||
catch (ObjectDisposedException e)
|
|
||||||
{
|
|
||||||
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal bool WriteRegister(IExecutionContext ctx, int gdbRegId, StringStream ss) =>
|
|
||||||
IsProcess32Bit
|
IsProcess32Bit
|
||||||
? ctx.WriteRegister32(gdbRegId, ss)
|
? ctx.WriteRegister32(registerId, ss)
|
||||||
: ctx.WriteRegister64(gdbRegId, ss);
|
: ctx.WriteRegister64(registerId, ss);
|
||||||
|
|
||||||
internal string ReadRegister(IExecutionContext ctx, int gdbRegId) =>
|
internal string ReadRegister(IExecutionContext ctx, int registerId) =>
|
||||||
IsProcess32Bit
|
IsProcess32Bit
|
||||||
? ctx.ReadRegister32(gdbRegId)
|
? ctx.ReadRegister32(registerId)
|
||||||
: ctx.ReadRegister64(gdbRegId);
|
: ctx.ReadRegister64(registerId);
|
||||||
|
|
||||||
public string GetStackTrace()
|
|
||||||
{
|
|
||||||
if (GThread == null)
|
|
||||||
return "No thread selected\n";
|
|
||||||
|
|
||||||
return Process?.Debugger?.GetGuestStackTrace(DebugProcess.GetThread(GThread.Value)) ?? "No application process found\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetRegisters()
|
|
||||||
{
|
|
||||||
if (GThread == null)
|
|
||||||
return "No thread selected\n";
|
|
||||||
|
|
||||||
return Process?.Debugger?.GetCpuRegisterPrintout(DebugProcess.GetThread(GThread.Value)) ?? "No application process found\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetMinidump()
|
|
||||||
{
|
|
||||||
var response = new StringBuilder();
|
|
||||||
response.AppendLine("=== Begin Minidump ===\n");
|
|
||||||
response.AppendLine(GetProcessInfo());
|
|
||||||
|
|
||||||
foreach (var thread in GetThreads())
|
|
||||||
{
|
|
||||||
response.AppendLine($"=== Thread {thread.ThreadUid} ===");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string stackTrace = Process.Debugger.GetGuestStackTrace(thread);
|
|
||||||
response.AppendLine(stackTrace);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
response.AppendLine($"[Error getting stack trace: {e.Message}]");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string registers = Process.Debugger.GetCpuRegisterPrintout(thread);
|
|
||||||
response.AppendLine(registers);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
response.AppendLine($"[Error getting registers: {e.Message}]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response.AppendLine("=== End Minidump ===");
|
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.GdbStub, response.ToString());
|
|
||||||
return response.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetProcessInfo()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (Process == null)
|
|
||||||
return "No application process found\n";
|
|
||||||
|
|
||||||
KProcess kProcess = Process;
|
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.AppendLine($"Program Id: 0x{kProcess.TitleId:x16}");
|
|
||||||
sb.AppendLine($"Application: {(kProcess.IsApplication ? 1 : 0)}");
|
|
||||||
sb.AppendLine("Layout:");
|
|
||||||
sb.AppendLine(
|
|
||||||
$" Alias: 0x{kProcess.MemoryManager.AliasRegionStart:x10} - 0x{kProcess.MemoryManager.AliasRegionEnd - 1:x10}");
|
|
||||||
sb.AppendLine(
|
|
||||||
$" Heap: 0x{kProcess.MemoryManager.HeapRegionStart:x10} - 0x{kProcess.MemoryManager.HeapRegionEnd - 1:x10}");
|
|
||||||
sb.AppendLine(
|
|
||||||
$" Aslr: 0x{kProcess.MemoryManager.AslrRegionStart:x10} - 0x{kProcess.MemoryManager.AslrRegionEnd - 1:x10}");
|
|
||||||
sb.AppendLine(
|
|
||||||
$" Stack: 0x{kProcess.MemoryManager.StackRegionStart:x10} - 0x{kProcess.MemoryManager.StackRegionEnd - 1:x10}");
|
|
||||||
|
|
||||||
sb.AppendLine("Modules:");
|
|
||||||
var debugger = kProcess.Debugger;
|
|
||||||
if (debugger != null)
|
|
||||||
{
|
|
||||||
var images = debugger.GetLoadedImages();
|
|
||||||
for (int i = 0; i < images.Count; i++)
|
|
||||||
{
|
|
||||||
var image = images[i];
|
|
||||||
ulong endAddress = image.BaseAddress + image.Size - 1;
|
|
||||||
string name = image.Name;
|
|
||||||
sb.AppendLine($" 0x{image.BaseAddress:x10} - 0x{endAddress:x10} {name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Logger.Error?.Print(LogClass.GdbStub, $"Error getting process info: {e.Message}");
|
|
||||||
return $"Error getting process info: {e.Message}\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
|
|
@ -237,7 +89,7 @@ namespace Ryujinx.HLE.Debugger
|
||||||
_readStream?.Close();
|
_readStream?.Close();
|
||||||
_writeStream?.Close();
|
_writeStream?.Close();
|
||||||
_debuggerThread.Join();
|
_debuggerThread.Join();
|
||||||
_messages.Add(new KillMessage());
|
_messages.Add(StatelessMessage.Kill);
|
||||||
_messageHandlerThread.Join();
|
_messageHandlerThread.Join();
|
||||||
_messages.Dispose();
|
_messages.Dispose();
|
||||||
_breakHandlerEvent.Dispose();
|
_breakHandlerEvent.Dispose();
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
switch (ss.ReadChar())
|
switch (ss.ReadChar())
|
||||||
{
|
{
|
||||||
case '!':
|
case '!':
|
||||||
if (!ss.IsEmpty())
|
if (!ss.IsEmpty)
|
||||||
{
|
{
|
||||||
goto unknownCommand;
|
goto unknownCommand;
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
ReplyOK();
|
ReplyOK();
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if (!ss.IsEmpty())
|
if (!ss.IsEmpty)
|
||||||
{
|
{
|
||||||
goto unknownCommand;
|
goto unknownCommand;
|
||||||
}
|
}
|
||||||
|
|
@ -70,10 +70,10 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
Commands.Query();
|
Commands.Query();
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
Commands.Continue(ss.IsEmpty() ? null : ss.ReadRemainingAsHex());
|
Commands.Continue(ss.IsEmpty ? null : ss.ReadRemainingAsHex());
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
if (!ss.IsEmpty())
|
if (!ss.IsEmpty)
|
||||||
{
|
{
|
||||||
goto unknownCommand;
|
goto unknownCommand;
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +81,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
Commands.Detach();
|
Commands.Detach();
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
if (!ss.IsEmpty())
|
if (!ss.IsEmpty)
|
||||||
{
|
{
|
||||||
goto unknownCommand;
|
goto unknownCommand;
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +172,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
if (ss.ConsumeRemaining("fThreadInfo"))
|
if (ss.ConsumeRemaining("fThreadInfo"))
|
||||||
{
|
{
|
||||||
Reply(
|
Reply(
|
||||||
$"m{Debugger.DebugProcess.GetThreadUids().Select(x => $"{x:x}").JoinToString(",")}");
|
$"m{Debugger.DebugProcess.ThreadUids.Select(x => $"{x:x}").JoinToString(",")}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
|
|
||||||
if (len >= (ulong)data.Length - offset)
|
if (len >= (ulong)data.Length - offset)
|
||||||
{
|
{
|
||||||
Reply("l" + Helpers.ToBinaryFormat(data.Substring((int)offset)));
|
Reply("l" + Helpers.ToBinaryFormat(data[(int)offset..]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -274,7 +274,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
case 'Q':
|
case 'Q':
|
||||||
goto unknownCommand;
|
goto unknownCommand;
|
||||||
case 's':
|
case 's':
|
||||||
Commands.Step(ss.IsEmpty() ? null : ss.ReadRemainingAsHex());
|
Commands.Step(ss.IsEmpty ? null : ss.ReadRemainingAsHex());
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
{
|
{
|
||||||
// GDB is performing initial contact. Stop everything.
|
// GDB is performing initial contact. Stop everything.
|
||||||
Debugger.DebugProcess.DebugStop();
|
Debugger.DebugProcess.DebugStop();
|
||||||
Debugger.GThread = Debugger.CThread = Debugger.DebugProcess.GetThreadUids().First();
|
Debugger.GThread = Debugger.CThread = Debugger.DebugProcess.ThreadUids.First();
|
||||||
Processor.Reply($"T05thread:{Debugger.CThread:x};");
|
Processor.Reply($"T05thread:{Debugger.CThread:x};");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
Debugger.DebugProcess.DebugStop();
|
Debugger.DebugProcess.DebugStop();
|
||||||
if (Debugger.GThread == null || Debugger.GetThreads().All(x => x.ThreadUid != Debugger.GThread.Value))
|
if (Debugger.GThread == null || Debugger.GetThreads().All(x => x.ThreadUid != Debugger.GThread.Value))
|
||||||
{
|
{
|
||||||
Debugger.GThread = Debugger.CThread = Debugger.DebugProcess.GetThreadUids().First();
|
Debugger.GThread = Debugger.CThread = Debugger.DebugProcess.ThreadUids.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
Processor.Reply($"T02thread:{Debugger.GThread:x};");
|
Processor.Reply($"T02thread:{Debugger.GThread:x};");
|
||||||
|
|
@ -151,7 +151,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Processor.Reply(ss.IsEmpty());
|
Processor.Reply(ss.IsEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetThread(char op, ulong? threadId)
|
internal void SetThread(char op, ulong? threadId)
|
||||||
|
|
@ -251,7 +251,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
|
|
||||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||||
|
|
||||||
Processor.Reply(Debugger.WriteRegister(ctx, gdbRegId, ss) && ss.IsEmpty());
|
Processor.Reply(Debugger.WriteRegister(ctx, gdbRegId, ss) && ss.IsEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Step(ulong? newPc)
|
internal void Step(ulong? newPc)
|
||||||
|
|
|
||||||
|
|
@ -13,65 +13,56 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
*/
|
*/
|
||||||
private const uint FpcrMask = 0xfc1fffff;
|
private const uint FpcrMask = 0xfc1fffff;
|
||||||
|
|
||||||
public static string ReadRegister64(this IExecutionContext state, int gdbRegId)
|
public static string ReadRegister64(this IExecutionContext state, int registerId) =>
|
||||||
{
|
registerId switch
|
||||||
switch (gdbRegId)
|
|
||||||
{
|
{
|
||||||
case >= 0 and <= 31:
|
>= 0 and <= 31 => Helpers.ToHex(BitConverter.GetBytes(state.GetX(registerId))),
|
||||||
return Helpers.ToHex(BitConverter.GetBytes(state.GetX(gdbRegId)));
|
32 => Helpers.ToHex(BitConverter.GetBytes(state.DebugPc)),
|
||||||
case 32:
|
33 => Helpers.ToHex(BitConverter.GetBytes(state.Pstate)),
|
||||||
return Helpers.ToHex(BitConverter.GetBytes(state.DebugPc));
|
>= 34 and <= 65 => Helpers.ToHex(state.GetV(registerId - 34).ToArray()),
|
||||||
case 33:
|
66 => Helpers.ToHex(BitConverter.GetBytes((uint)state.Fpsr)),
|
||||||
return Helpers.ToHex(BitConverter.GetBytes(state.Pstate));
|
67 => Helpers.ToHex(BitConverter.GetBytes((uint)state.Fpcr)),
|
||||||
case >= 34 and <= 65:
|
_ => null
|
||||||
return Helpers.ToHex(state.GetV(gdbRegId - 34).ToArray());
|
};
|
||||||
case 66:
|
|
||||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.Fpsr));
|
|
||||||
case 67:
|
|
||||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.Fpcr));
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool WriteRegister64(this IExecutionContext state, int gdbRegId, StringStream ss)
|
public static bool WriteRegister64(this IExecutionContext state, int registerId, StringStream ss)
|
||||||
{
|
{
|
||||||
switch (gdbRegId)
|
switch (registerId)
|
||||||
{
|
{
|
||||||
case >= 0 and <= 31:
|
case >= 0 and <= 31:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(16);
|
ulong value = ss.ReadLengthAsLittleEndianHex(16);
|
||||||
state.SetX(gdbRegId, value);
|
state.SetX(registerId, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case 32:
|
case 32:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(16);
|
ulong value = ss.ReadLengthAsLittleEndianHex(16);
|
||||||
state.DebugPc = value;
|
state.DebugPc = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case 33:
|
case 33:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(8);
|
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||||
state.Pstate = (uint)value;
|
state.Pstate = (uint)value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case >= 34 and <= 65:
|
case >= 34 and <= 65:
|
||||||
{
|
{
|
||||||
ulong value0 = ss.ReadLengthAsLEHex(16);
|
ulong value0 = ss.ReadLengthAsLittleEndianHex(16);
|
||||||
ulong value1 = ss.ReadLengthAsLEHex(16);
|
ulong value1 = ss.ReadLengthAsLittleEndianHex(16);
|
||||||
state.SetV(gdbRegId - 34, new V128(value0, value1));
|
state.SetV(registerId - 34, new V128(value0, value1));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case 66:
|
case 66:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(8);
|
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||||
state.Fpsr = (uint)value;
|
state.Fpsr = (uint)value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case 67:
|
case 67:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(8);
|
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||||
state.Fpcr = (uint)value;
|
state.Fpcr = (uint)value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -80,65 +71,64 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ReadRegister32(this IExecutionContext state, int gdbRegId)
|
public static string ReadRegister32(this IExecutionContext state, int registerId)
|
||||||
{
|
{
|
||||||
switch (gdbRegId)
|
switch (registerId)
|
||||||
{
|
{
|
||||||
case >= 0 and <= 14:
|
case >= 0 and <= 14:
|
||||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.GetX(gdbRegId)));
|
return Helpers.ToHex(BitConverter.GetBytes((uint)state.GetX(registerId)));
|
||||||
case 15:
|
case 15:
|
||||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.DebugPc));
|
return Helpers.ToHex(BitConverter.GetBytes((uint)state.DebugPc));
|
||||||
case 16:
|
case 16:
|
||||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.Pstate));
|
return Helpers.ToHex(BitConverter.GetBytes(state.Pstate));
|
||||||
case >= 17 and <= 32:
|
case >= 17 and <= 32:
|
||||||
return Helpers.ToHex(state.GetV(gdbRegId - 17).ToArray());
|
return Helpers.ToHex(state.GetV(registerId - 17).ToArray());
|
||||||
case >= 33 and <= 64:
|
case >= 33 and <= 64:
|
||||||
int reg = (gdbRegId - 33);
|
int reg = (registerId - 33);
|
||||||
int n = reg / 2;
|
int n = reg / 2;
|
||||||
int shift = reg % 2;
|
int shift = reg % 2;
|
||||||
ulong value = state.GetV(n).Extract<ulong>(shift);
|
ulong value = state.GetV(n).Extract<ulong>(shift);
|
||||||
return Helpers.ToHex(BitConverter.GetBytes(value));
|
return Helpers.ToHex(BitConverter.GetBytes(value));
|
||||||
case 65:
|
case 65:
|
||||||
uint fpscr = (uint)state.Fpsr | (uint)state.Fpcr;
|
return Helpers.ToHex(BitConverter.GetBytes(state.Fpscr));
|
||||||
return Helpers.ToHex(BitConverter.GetBytes(fpscr));
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool WriteRegister32(this IExecutionContext state, int gdbRegId, StringStream ss)
|
public static bool WriteRegister32(this IExecutionContext state, int registerId, StringStream ss)
|
||||||
{
|
{
|
||||||
switch (gdbRegId)
|
switch (registerId)
|
||||||
{
|
{
|
||||||
case >= 0 and <= 14:
|
case >= 0 and <= 14:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(8);
|
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||||
state.SetX(gdbRegId, value);
|
state.SetX(registerId, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case 15:
|
case 15:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(8);
|
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||||
state.DebugPc = value;
|
state.DebugPc = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case 16:
|
case 16:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(8);
|
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||||
state.Pstate = (uint)value;
|
state.Pstate = (uint)value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case >= 17 and <= 32:
|
case >= 17 and <= 32:
|
||||||
{
|
{
|
||||||
ulong value0 = ss.ReadLengthAsLEHex(16);
|
ulong value0 = ss.ReadLengthAsLittleEndianHex(16);
|
||||||
ulong value1 = ss.ReadLengthAsLEHex(16);
|
ulong value1 = ss.ReadLengthAsLittleEndianHex(16);
|
||||||
state.SetV(gdbRegId - 17, new V128(value0, value1));
|
state.SetV(registerId - 17, new V128(value0, value1));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case >= 33 and <= 64:
|
case >= 33 and <= 64:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(16);
|
ulong value = ss.ReadLengthAsLittleEndianHex(16);
|
||||||
int regId = (gdbRegId - 33);
|
int regId = (registerId - 33);
|
||||||
int regNum = regId / 2;
|
int regNum = regId / 2;
|
||||||
int shift = regId % 2;
|
int shift = regId % 2;
|
||||||
V128 reg = state.GetV(regNum);
|
V128 reg = state.GetV(regNum);
|
||||||
|
|
@ -147,7 +137,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||||
}
|
}
|
||||||
case 65:
|
case 65:
|
||||||
{
|
{
|
||||||
ulong value = ss.ReadLengthAsLEHex(8);
|
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||||
state.Fpsr = (uint)value & FpcrMask;
|
state.Fpsr = (uint)value & FpcrMask;
|
||||||
state.Fpcr = (uint)value & ~FpcrMask;
|
state.Fpcr = (uint)value & ~FpcrMask;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ namespace Ryujinx.HLE.Debugger
|
||||||
void DebugContinue(KThread thread);
|
void DebugContinue(KThread thread);
|
||||||
bool DebugStep(KThread thread);
|
bool DebugStep(KThread thread);
|
||||||
KThread GetThread(ulong threadUid);
|
KThread GetThread(ulong threadUid);
|
||||||
DebugState GetDebugState();
|
|
||||||
bool IsThreadPaused(KThread thread);
|
bool IsThreadPaused(KThread thread);
|
||||||
ulong[] GetThreadUids();
|
|
||||||
public void DebugInterruptHandler(IExecutionContext ctx);
|
public void DebugInterruptHandler(IExecutionContext ctx);
|
||||||
IVirtualMemoryManager CpuMemory { get; }
|
IVirtualMemoryManager CpuMemory { get; }
|
||||||
|
ulong[] ThreadUids { get; }
|
||||||
|
DebugState DebugState { get; }
|
||||||
void InvalidateCacheRegion(ulong address, ulong size);
|
void InvalidateCacheRegion(ulong address, ulong size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
47
src/Ryujinx.HLE/Debugger/IMessage.cs
Normal file
47
src/Ryujinx.HLE/Debugger/IMessage.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
using Ryujinx.Cpu;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.Debugger
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Marker interface for debugger messages.
|
||||||
|
/// </summary>
|
||||||
|
interface IMessage;
|
||||||
|
|
||||||
|
public enum MessageType
|
||||||
|
{
|
||||||
|
Kill,
|
||||||
|
BreakIn,
|
||||||
|
SendNack
|
||||||
|
}
|
||||||
|
|
||||||
|
record struct StatelessMessage(MessageType Type) : IMessage
|
||||||
|
{
|
||||||
|
public static StatelessMessage Kill => new(MessageType.Kill);
|
||||||
|
public static StatelessMessage BreakIn => new(MessageType.BreakIn);
|
||||||
|
public static StatelessMessage SendNack => new(MessageType.SendNack);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CommandMessage : IMessage
|
||||||
|
{
|
||||||
|
public readonly string Command;
|
||||||
|
|
||||||
|
public CommandMessage(string cmd)
|
||||||
|
{
|
||||||
|
Command = cmd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ThreadBreakMessage : IMessage
|
||||||
|
{
|
||||||
|
public IExecutionContext Context { get; }
|
||||||
|
public ulong Address { get; }
|
||||||
|
public int Opcode { get; }
|
||||||
|
|
||||||
|
public ThreadBreakMessage(IExecutionContext context, ulong address, int opcode)
|
||||||
|
{
|
||||||
|
Context = context;
|
||||||
|
Address = address;
|
||||||
|
Opcode = opcode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
namespace Ryujinx.HLE.Debugger
|
|
||||||
{
|
|
||||||
struct BreakInMessage : IMessage
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
namespace Ryujinx.HLE.Debugger
|
|
||||||
{
|
|
||||||
struct CommandMessage : IMessage
|
|
||||||
{
|
|
||||||
public string Command;
|
|
||||||
|
|
||||||
public CommandMessage(string cmd)
|
|
||||||
{
|
|
||||||
Command = cmd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
namespace Ryujinx.HLE.Debugger
|
|
||||||
{
|
|
||||||
interface IMessage
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
namespace Ryujinx.HLE.Debugger
|
|
||||||
{
|
|
||||||
struct KillMessage : IMessage
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
namespace Ryujinx.HLE.Debugger
|
|
||||||
{
|
|
||||||
struct SendNackMessage : IMessage
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
using IExecutionContext = Ryujinx.Cpu.IExecutionContext;
|
|
||||||
|
|
||||||
namespace Ryujinx.HLE.Debugger
|
|
||||||
{
|
|
||||||
public class ThreadBreakMessage : IMessage
|
|
||||||
{
|
|
||||||
public IExecutionContext Context { get; }
|
|
||||||
public ulong Address { get; }
|
|
||||||
public int Opcode { get; }
|
|
||||||
|
|
||||||
public ThreadBreakMessage(IExecutionContext context, ulong address, int opcode)
|
|
||||||
{
|
|
||||||
Context = context;
|
|
||||||
Address = address;
|
|
||||||
Opcode = opcode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,63 +5,56 @@ namespace Ryujinx.HLE.Debugger
|
||||||
{
|
{
|
||||||
internal class StringStream
|
internal class StringStream
|
||||||
{
|
{
|
||||||
private readonly string Data;
|
private readonly string _data;
|
||||||
private int Position;
|
private int _position;
|
||||||
|
|
||||||
public StringStream(string s)
|
public StringStream(string s)
|
||||||
{
|
{
|
||||||
Data = s;
|
_data = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsEmpty => _position >= _data.Length;
|
||||||
|
|
||||||
public char ReadChar()
|
public char ReadChar() => _data[_position++];
|
||||||
{
|
|
||||||
return Data[Position++];
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ReadUntil(char needle)
|
public string ReadUntil(char needle)
|
||||||
{
|
{
|
||||||
int needlePos = Data.IndexOf(needle, Position);
|
int needlePos = _data.IndexOf(needle, _position);
|
||||||
|
|
||||||
if (needlePos == -1)
|
if (needlePos == -1)
|
||||||
{
|
{
|
||||||
needlePos = Data.Length;
|
needlePos = _data.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
string result = Data.Substring(Position, needlePos - Position);
|
string result = _data.Substring(_position, needlePos - _position);
|
||||||
Position = needlePos + 1;
|
_position = needlePos + 1;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReadLength(int len)
|
public string ReadLength(int len)
|
||||||
{
|
{
|
||||||
string result = Data.Substring(Position, len);
|
string result = _data.Substring(_position, len);
|
||||||
Position += len;
|
_position += len;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReadRemaining()
|
public string ReadRemaining()
|
||||||
{
|
{
|
||||||
string result = Data.Substring(Position);
|
string result = _data[_position..];
|
||||||
Position = Data.Length;
|
_position = _data.Length;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong ReadRemainingAsHex()
|
public ulong ReadRemainingAsHex()
|
||||||
{
|
=> ulong.Parse(ReadRemaining(), NumberStyles.HexNumber);
|
||||||
return ulong.Parse(ReadRemaining(), NumberStyles.HexNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong ReadUntilAsHex(char needle)
|
public ulong ReadUntilAsHex(char needle)
|
||||||
{
|
=> ulong.Parse(ReadUntil(needle), NumberStyles.HexNumber);
|
||||||
return ulong.Parse(ReadUntil(needle), NumberStyles.HexNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong ReadLengthAsHex(int len)
|
public ulong ReadLengthAsHex(int len)
|
||||||
{
|
=> ulong.Parse(ReadLength(len), NumberStyles.HexNumber);
|
||||||
return ulong.Parse(ReadLength(len), NumberStyles.HexNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong ReadLengthAsLEHex(int len)
|
public ulong ReadLengthAsLittleEndianHex(int len)
|
||||||
{
|
{
|
||||||
Debug.Assert(len % 2 == 0);
|
Debug.Assert(len % 2 == 0);
|
||||||
|
|
||||||
|
|
@ -83,9 +76,9 @@ namespace Ryujinx.HLE.Debugger
|
||||||
|
|
||||||
public bool ConsumePrefix(string prefix)
|
public bool ConsumePrefix(string prefix)
|
||||||
{
|
{
|
||||||
if (Data.Substring(Position).StartsWith(prefix))
|
if (_data[_position..].StartsWith(prefix))
|
||||||
{
|
{
|
||||||
Position += prefix.Length;
|
_position += prefix.Length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -93,17 +86,12 @@ namespace Ryujinx.HLE.Debugger
|
||||||
|
|
||||||
public bool ConsumeRemaining(string match)
|
public bool ConsumeRemaining(string match)
|
||||||
{
|
{
|
||||||
if (Data.Substring(Position) == match)
|
if (_data[_position..] == match)
|
||||||
{
|
{
|
||||||
Position += match.Length;
|
_position += match.Length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEmpty()
|
|
||||||
{
|
|
||||||
return Position >= Data.Length;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1338,22 +1338,24 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DebugState GetDebugState()
|
public DebugState DebugState => (DebugState)_parent.debugState;
|
||||||
{
|
|
||||||
return (DebugState)_parent.debugState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsThreadPaused(KThread target)
|
public bool IsThreadPaused(KThread target)
|
||||||
{
|
{
|
||||||
return (target.SchedFlags & ThreadSchedState.ThreadPauseFlag) != 0;
|
return (target.SchedFlags & ThreadSchedState.ThreadPauseFlag) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong[] GetThreadUids()
|
public ulong[] ThreadUids
|
||||||
{
|
{
|
||||||
lock (_parent._threadingLock)
|
get
|
||||||
{
|
{
|
||||||
var threads = _parent._threads.Where(x => !x.TerminationRequested).ToArray();
|
lock (_parent._threadingLock)
|
||||||
return threads.Select(x => x.ThreadUid).ToArray();
|
{
|
||||||
|
return _parent._threads
|
||||||
|
.Where(x => !x.TerminationRequested)
|
||||||
|
.Select(x => x.ThreadUid)
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1361,8 +1363,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
{
|
{
|
||||||
lock (_parent._threadingLock)
|
lock (_parent._threadingLock)
|
||||||
{
|
{
|
||||||
var threads = _parent._threads.Where(x => !x.TerminationRequested).ToArray();
|
return _parent._threads.Where(x => !x.TerminationRequested)
|
||||||
return threads.FirstOrDefault(x => x.ThreadUid == threadUid);
|
.FirstOrDefault(x => x.ThreadUid == threadUid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1379,7 +1381,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
_parent.InterruptHandler(ctx);
|
_parent.InterruptHandler(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IVirtualMemoryManager CpuMemory { get { return _parent.CpuMemory; } }
|
public IVirtualMemoryManager CpuMemory => _parent.CpuMemory;
|
||||||
|
|
||||||
public void InvalidateCacheRegion(ulong address, ulong size)
|
public void InvalidateCacheRegion(ulong address, ulong size)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||||
KThread selectedThread = _state.SelectedThread;
|
KThread selectedThread = _state.SelectedThread;
|
||||||
|
|
||||||
if (!currentThread.IsThreadNamed && currentThread.GetThreadName() != "")
|
if (!currentThread.IsThreadNamed && string.IsNullOrEmpty(currentThread.GetThreadName()))
|
||||||
{
|
{
|
||||||
currentThread.HostThread.Name = $"<{currentThread.GetThreadName()}>";
|
currentThread.HostThread.Name = $"<{currentThread.GetThreadName()}>";
|
||||||
currentThread.IsThreadNamed = true;
|
currentThread.IsThreadNamed = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue