Compare commits
10 Commits
Canary-1.3
...
Canary-1.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 49cbe4b328 | |||
| 6fd67cdcb7 | |||
| 5ced2bf764 | |||
| 67e97d1a1a | |||
| 09d8a411c8 | |||
| 93516df7e6 | |||
| 0c165c3f62 | |||
| 91da244c02 | |||
| 904d4a7eb0 | |||
| 1248a054de |
@ -21,8 +21,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
}
|
||||
catch (SocketException se)
|
||||
{
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Failed to create TCP client for GDB client: {Enum.GetName(se.SocketErrorCode)}");
|
||||
return;
|
||||
Logger.Error?.Print(LogClass.GdbStub,
|
||||
$"Failed to create TCP server on {endpoint} for GDB client: {Enum.GetName(se.SocketErrorCode)}");
|
||||
throw;
|
||||
}
|
||||
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Currently waiting on {endpoint} for GDB client");
|
||||
@ -33,8 +34,10 @@ namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
_clientSocket = _listenerSocket.AcceptSocket();
|
||||
}
|
||||
catch (SocketException)
|
||||
catch (SocketException se)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub,
|
||||
$"Failed to accept incoming GDB client connection: {Enum.GetName(se.SocketErrorCode)}");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -42,7 +45,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
int retries = 10;
|
||||
while ((DebugProcess == null || GetThreads().Length == 0) && retries-- > 0)
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
if (DebugProcess == null || GetThreads().Length == 0)
|
||||
@ -57,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");
|
||||
|
||||
@ -116,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;
|
||||
GThreadId = CThreadId = ctx.ThreadUid;
|
||||
_breakHandlerEvent.Set();
|
||||
_commandProcessor.Reply($"T05thread:{ctx.ThreadUid:x};");
|
||||
_commands.Processor.Reply($"T05thread:{ctx.ThreadUid:x};");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,54 +46,32 @@ namespace Ryujinx.HLE.Debugger
|
||||
|
||||
public string GetStackTrace()
|
||||
{
|
||||
if (GThread == null)
|
||||
if (GThreadId == null)
|
||||
return "No thread selected\n";
|
||||
|
||||
return Process?.Debugger?.GetGuestStackTrace(DebugProcess.GetThread(GThread.Value)) ?? "No application process found\n";
|
||||
return Process?.Debugger?.GetGuestStackTrace(DebugProcess.GetThread(GThreadId.Value)) ?? "No application process found\n";
|
||||
}
|
||||
|
||||
public string GetRegisters()
|
||||
{
|
||||
if (GThread == null)
|
||||
if (GThreadId == null)
|
||||
return "No thread selected\n";
|
||||
|
||||
return Process?.Debugger?.GetCpuRegisterPrintout(DebugProcess.GetThread(GThread.Value)) ?? "No application process found\n";
|
||||
return Process?.Debugger?.GetCpuRegisterPrintout(DebugProcess.GetThread(GThreadId.Value)) ?? "No application process found\n";
|
||||
}
|
||||
|
||||
public string GetMinidump()
|
||||
{
|
||||
StringBuilder response = new();
|
||||
response.AppendLine("=== Begin Minidump ===\n");
|
||||
response.AppendLine(GetProcessInfo());
|
||||
if (Process is not { } kProcess)
|
||||
return "No application process found\n";
|
||||
|
||||
foreach (KThread 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}]");
|
||||
}
|
||||
if (kProcess.Debugger is not { } debugger)
|
||||
return "Error getting minidump: debugger is null\n";
|
||||
|
||||
try
|
||||
{
|
||||
string registers = Process.Debugger.GetCpuRegisterPrintout(thread);
|
||||
response.AppendLine(registers);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
response.AppendLine($"[Error getting registers: {e.Message}]");
|
||||
}
|
||||
}
|
||||
string response = debugger.GetMinidump();
|
||||
|
||||
response.AppendLine("=== End Minidump ===");
|
||||
|
||||
Logger.Info?.Print(LogClass.GdbStub, response.ToString());
|
||||
return response.ToString();
|
||||
Logger.Info?.Print(LogClass.GdbStub, response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public string GetProcessInfo()
|
||||
@ -103,32 +81,8 @@ namespace Ryujinx.HLE.Debugger
|
||||
if (Process is not { } kProcess)
|
||||
return "No application process found\n";
|
||||
|
||||
StringBuilder sb = new();
|
||||
|
||||
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:");
|
||||
HleProcessDebugger 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();
|
||||
return kProcess.Debugger?.GetProcessInfoPrintout()
|
||||
?? "Error getting process info: debugger is null\n";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
using Gommon;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.Debugger.Gdb;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
@ -26,15 +28,18 @@ namespace Ryujinx.HLE.Debugger
|
||||
private Socket _clientSocket;
|
||||
private NetworkStream _readStream;
|
||||
private NetworkStream _writeStream;
|
||||
|
||||
private GdbCommandProcessor _commandProcessor;
|
||||
|
||||
private GdbCommands _commands;
|
||||
|
||||
private bool _shuttingDown;
|
||||
private readonly ManualResetEventSlim _breakHandlerEvent = new(false);
|
||||
|
||||
internal ulong? CThread;
|
||||
internal ulong? GThread;
|
||||
internal ulong? CThreadId;
|
||||
internal ulong? GThreadId;
|
||||
|
||||
internal KThread CThread => CThreadId?.Into(DebugProcess.GetThread);
|
||||
|
||||
internal KThread GThread => GThreadId?.Into(DebugProcess.GetThread);
|
||||
|
||||
public readonly BreakpointManager BreakpointManager;
|
||||
|
||||
@ -57,7 +62,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
|
||||
internal KThread[] GetThreads() => DebugProcess.ThreadUids.Select(DebugProcess.GetThread).ToArray();
|
||||
|
||||
internal bool IsProcess32Bit => DebugProcess.GetThread(GThread ?? DebugProcess.ThreadUids.First()).Context.IsAarch32;
|
||||
internal bool IsProcess32Bit => DebugProcess.GetThread(GThreadId ?? DebugProcess.ThreadUids.First()).Context.IsAarch32;
|
||||
|
||||
internal bool WriteRegister(IExecutionContext ctx, int registerId, StringStream ss) =>
|
||||
IsProcess32Bit
|
||||
|
||||
@ -181,7 +181,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
if (ss.ConsumeRemaining("fThreadInfo"))
|
||||
{
|
||||
Reply(
|
||||
$"m{Debugger.DebugProcess.ThreadUids.Select(x => $"{x:x}").JoinToString(",")}");
|
||||
$"m{DebugProcess.ThreadUids.Select(x => $"{x:x}").JoinToString(",")}");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -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,52 +33,37 @@ 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.
|
||||
Debugger.DebugProcess.DebugStop();
|
||||
Debugger.GThread = Debugger.CThread = Debugger.DebugProcess.ThreadUids.First();
|
||||
Processor.Reply($"T05thread:{Debugger.CThread:x};");
|
||||
Debugger.GThreadId = Debugger.CThreadId = Debugger.DebugProcess.ThreadUids.First();
|
||||
Processor.Reply($"T05thread:{Debugger.CThreadId:x};");
|
||||
}
|
||||
|
||||
internal void Interrupt()
|
||||
{
|
||||
// GDB is requesting an interrupt. Stop everything.
|
||||
Debugger.DebugProcess.DebugStop();
|
||||
if (Debugger.GThread == null || Debugger.GetThreads().All(x => x.ThreadUid != Debugger.GThread.Value))
|
||||
if (Debugger.GThreadId == null || Debugger.GetThreads().All(x => x.ThreadUid != Debugger.GThreadId.Value))
|
||||
{
|
||||
Debugger.GThread = Debugger.CThread = Debugger.DebugProcess.ThreadUids.First();
|
||||
Debugger.GThreadId = Debugger.CThreadId = Debugger.DebugProcess.ThreadUids.First();
|
||||
}
|
||||
|
||||
Processor.Reply($"T02thread:{Debugger.GThread:x};");
|
||||
Processor.Reply($"T02thread:{Debugger.GThreadId:x};");
|
||||
}
|
||||
|
||||
internal void Continue(ulong? newPc)
|
||||
{
|
||||
if (newPc.HasValue)
|
||||
{
|
||||
if (Debugger.CThread == null)
|
||||
if (Debugger.CThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
Debugger.DebugProcess.GetThread(Debugger.CThread.Value).Context.DebugPc = newPc.Value;
|
||||
Debugger.CThread.Context.DebugPc = newPc.Value;
|
||||
}
|
||||
|
||||
Debugger.DebugProcess.DebugContinue();
|
||||
@ -94,24 +78,24 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
|
||||
internal void ReadRegisters()
|
||||
{
|
||||
if (Debugger.GThread == null)
|
||||
if (Debugger.GThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
IExecutionContext ctx = Debugger.GThread.Context;
|
||||
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);
|
||||
}
|
||||
@ -122,16 +106,16 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
|
||||
internal void WriteRegisters(StringStream ss)
|
||||
{
|
||||
if (Debugger.GThread == null)
|
||||
if (Debugger.GThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
IExecutionContext ctx = Debugger.GThread.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))
|
||||
{
|
||||
@ -178,11 +162,11 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
switch (op)
|
||||
{
|
||||
case 'c':
|
||||
Debugger.CThread = threadId;
|
||||
Debugger.CThreadId = threadId;
|
||||
Processor.ReplyOK();
|
||||
return;
|
||||
case 'g':
|
||||
Debugger.GThread = threadId;
|
||||
Debugger.GThreadId = threadId;
|
||||
Processor.ReplyOK();
|
||||
return;
|
||||
default:
|
||||
@ -230,13 +214,13 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
|
||||
internal void ReadRegister(int gdbRegId)
|
||||
{
|
||||
if (Debugger.GThread == null)
|
||||
if (Debugger.GThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
IExecutionContext ctx = Debugger.GThread.Context;
|
||||
string result = Debugger.ReadRegister(ctx, gdbRegId);
|
||||
|
||||
Processor.Reply(result != null, result);
|
||||
@ -244,26 +228,26 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
|
||||
internal void WriteRegister(int gdbRegId, StringStream ss)
|
||||
{
|
||||
if (Debugger.GThread == null)
|
||||
if (Debugger.GThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
|
||||
Processor.Reply(Debugger.WriteRegister(ctx, gdbRegId, ss) && ss.IsEmpty);
|
||||
Processor.Reply(
|
||||
success: Debugger.WriteRegister(Debugger.GThread.Context, gdbRegId, ss) && ss.IsEmpty
|
||||
);
|
||||
}
|
||||
|
||||
internal void Step(ulong? newPc)
|
||||
{
|
||||
if (Debugger.CThread == null)
|
||||
if (Debugger.CThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
KThread thread = Debugger.DebugProcess.GetThread(Debugger.CThread.Value);
|
||||
KThread thread = Debugger.CThread;
|
||||
|
||||
if (newPc.HasValue)
|
||||
{
|
||||
@ -276,7 +260,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
}
|
||||
else
|
||||
{
|
||||
Debugger.GThread = Debugger.CThread = thread.ThreadUid;
|
||||
Debugger.GThreadId = Debugger.CThreadId = thread.ThreadUid;
|
||||
Processor.Reply($"T05thread:{thread.ThreadUid:x};");
|
||||
}
|
||||
}
|
||||
@ -330,7 +314,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
_ => VContAction.None
|
||||
};
|
||||
|
||||
// Note: We don't support signals yet.
|
||||
// TODO: Note: We don't support signals yet.
|
||||
//ushort? signal = null;
|
||||
if (cmd is 'C' or 'S')
|
||||
{
|
||||
@ -339,24 +323,22 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
// since that method advances the underlying string position
|
||||
}
|
||||
|
||||
ulong? threadId = null;
|
||||
if (stream.ConsumePrefix(":"))
|
||||
{
|
||||
threadId = stream.ReadRemainingAsThreadUid();
|
||||
}
|
||||
ulong? threadId = stream.ConsumePrefix(":")
|
||||
? stream.ReadRemainingAsThreadUid()
|
||||
: null;
|
||||
|
||||
if (threadId.HasValue)
|
||||
{
|
||||
if (threadActionMap.ContainsKey(threadId.Value))
|
||||
{
|
||||
threadActionMap[threadId.Value] = new VContPendingAction(action/*, signal*/);
|
||||
threadActionMap[threadId.Value] = new VContPendingAction(action /*, signal*/);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (ulong thread in threadActionMap.Keys)
|
||||
{
|
||||
threadActionMap[thread] = new VContPendingAction(action/*, signal*/);
|
||||
threadActionMap[thread] = new VContPendingAction(action /*, signal*/);
|
||||
}
|
||||
|
||||
if (action == VContAction.Continue)
|
||||
@ -409,7 +391,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
{
|
||||
if (action.Action == VContAction.Step)
|
||||
{
|
||||
Debugger.GThread = Debugger.CThread = threadUid;
|
||||
Debugger.GThreadId = Debugger.CThreadId = threadUid;
|
||||
Processor.Reply($"T05thread:{threadUid:x};");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
@ -13,6 +16,8 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
*/
|
||||
private const uint FpcrMask = 0xfc1fffff;
|
||||
|
||||
#region 64-bit
|
||||
|
||||
public static string ReadRegister64(this IExecutionContext state, int registerId) =>
|
||||
registerId switch
|
||||
{
|
||||
@ -71,6 +76,10 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 32-bit
|
||||
|
||||
public static string ReadRegister32(this IExecutionContext state, int registerId)
|
||||
{
|
||||
switch (registerId)
|
||||
@ -146,5 +155,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
IVirtualMemoryManager CpuMemory { get; }
|
||||
ulong[] ThreadUids { get; }
|
||||
DebugState DebugState { get; }
|
||||
|
||||
|
||||
void DebugStop();
|
||||
void DebugContinue();
|
||||
void DebugContinue(KThread thread);
|
||||
|
||||
@ -26,11 +26,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
public readonly string Command;
|
||||
|
||||
public CommandMessage(string cmd)
|
||||
{
|
||||
Command = cmd;
|
||||
}
|
||||
=> Command = cmd;
|
||||
}
|
||||
|
||||
|
||||
public class ThreadBreakMessage : Message.IMarker
|
||||
{
|
||||
public IExecutionContext Context { get; }
|
||||
|
||||
@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
class RegisterInformation
|
||||
static class RegisterInformation
|
||||
{
|
||||
public static readonly Dictionary<string, string> Features = new()
|
||||
{
|
||||
|
||||
@ -161,6 +161,116 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string GetProcessInfoPrintout()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
|
||||
sb.AppendLine($"Process: {_owner.Name}, PID: {_owner.Pid}");
|
||||
sb.AppendLine($"Program Id: 0x{_owner.TitleId:x16}");
|
||||
sb.AppendLine($"Application: {(_owner.IsApplication ? 1 : 0)}");
|
||||
|
||||
sb.AppendLine("Layout:");
|
||||
sb.AppendLine(
|
||||
$" Alias: 0x{_owner.MemoryManager.AliasRegionStart:x10} - 0x{_owner.MemoryManager.AliasRegionEnd - 1:x10}");
|
||||
sb.AppendLine(
|
||||
$" Heap: 0x{_owner.MemoryManager.HeapRegionStart:x10} - 0x{_owner.MemoryManager.HeapRegionEnd - 1:x10}");
|
||||
sb.AppendLine(
|
||||
$" Aslr: 0x{_owner.MemoryManager.AslrRegionStart:x10} - 0x{_owner.MemoryManager.AslrRegionEnd - 1:x10}");
|
||||
sb.AppendLine(
|
||||
$" Stack: 0x{_owner.MemoryManager.StackRegionStart:x10} - 0x{_owner.MemoryManager.StackRegionEnd - 1:x10}");
|
||||
|
||||
sb.AppendLine("Modules:");
|
||||
|
||||
foreach (Image image in GetLoadedImages())
|
||||
{
|
||||
ulong endAddress = image.BaseAddress + image.Size - 1;
|
||||
sb.AppendLine($" 0x{image.BaseAddress:x10} - 0x{endAddress:x10} {image.Name}");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string GetMinidump()
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
|
||||
result.AppendLine("=== Begin Minidump ===\n");
|
||||
try
|
||||
{
|
||||
result.AppendLine(GetProcessInfoPrintout());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting process info: {e.Message}]");
|
||||
}
|
||||
|
||||
var debugInterface = _owner?.DebugInterface;
|
||||
|
||||
if (debugInterface != null)
|
||||
{
|
||||
ulong[] threadUids;
|
||||
|
||||
try
|
||||
{
|
||||
threadUids = debugInterface.ThreadUids ?? [];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting thread uids: {e.Message}]");
|
||||
threadUids = [];
|
||||
}
|
||||
|
||||
foreach (ulong threadUid in threadUids)
|
||||
{
|
||||
result.AppendLine($"=== Thread {threadUid} ===");
|
||||
|
||||
KThread thread;
|
||||
|
||||
try
|
||||
{
|
||||
thread = debugInterface.GetThread(threadUid);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting thread: {e.Message}]");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (thread == null)
|
||||
{
|
||||
result.AppendLine("[Thread not found]");
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
result.AppendLine(GetGuestStackTrace(thread));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting stack trace: {e.Message}]");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
result.AppendLine(GetCpuRegisterPrintout(thread));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting registers: {e.Message}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.AppendLine("[Error generating minidump: debugInterface is null]");
|
||||
}
|
||||
|
||||
result.AppendLine("=== End Minidump ===");
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
private static bool TryGetSubName(Image image, ulong address, out ElfSymbol symbol)
|
||||
{
|
||||
address -= image.BaseAddress;
|
||||
|
||||
@ -889,7 +889,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
[Svc(1)]
|
||||
public Result SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size)
|
||||
{
|
||||
if ((size & 0xfffffffd001fffff) != 0)
|
||||
if ((size & 0xfffffffc001fffff) != 0)
|
||||
{
|
||||
address = 0;
|
||||
|
||||
|
||||
@ -221,10 +221,7 @@ namespace Ryujinx.Ava
|
||||
}
|
||||
|
||||
// When you first load the program, copy to remember the path for the global configuration
|
||||
if (GlobalConfigurationPath == null)
|
||||
{
|
||||
GlobalConfigurationPath = ConfigurationPath;
|
||||
}
|
||||
GlobalConfigurationPath ??= ConfigurationPath;
|
||||
|
||||
UseHardwareAcceleration = ConfigurationState.Instance.EnableHardwareAcceleration;
|
||||
|
||||
|
||||
@ -318,9 +318,9 @@ namespace Ryujinx.Ava.Systems.AppLibrary
|
||||
}
|
||||
catch (HorizonResultException)
|
||||
{
|
||||
foreach (DirectoryEntryEx entry in controlFs.EnumerateEntries("/", "*"))
|
||||
foreach (DirectoryEntryEx entry in controlFs.EnumerateEntries("/", "*", SearchOptions.Default))
|
||||
{
|
||||
if (entry.Name == "control.nacp")
|
||||
if (entry.Name == "control.nacp" || entry.Type == DirectoryEntryType.Directory)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -56,6 +56,7 @@ namespace Ryujinx.Ava.Systems.Configuration
|
||||
|
||||
Logger.EnableFileLog.Value = cff.EnableFileLog;
|
||||
Logger.EnableDebug.Value = cff.LoggingEnableDebug;
|
||||
Logger.EnableAvaloniaLog.Value = cff.LoggingEnableAvalonia;
|
||||
Logger.EnableStub.Value = cff.LoggingEnableStub;
|
||||
Logger.EnableInfo.Value = cff.LoggingEnableInfo;
|
||||
Logger.EnableWarn.Value = cff.LoggingEnableWarn;
|
||||
|
||||
@ -176,7 +176,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
.Sort(GetComparer())
|
||||
.OnItemAdded(_ => OnPropertyChanged(nameof(AppsObservableList)))
|
||||
.OnItemRemoved(_ => OnPropertyChanged(nameof(AppsObservableList)))
|
||||
.Bind(out _appsObservableList);
|
||||
.Bind(out _appsObservableList)
|
||||
.Subscribe();
|
||||
|
||||
_rendererWaitEvent = new AutoResetEvent(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user