Compare commits

..

10 Commits

Author SHA1 Message Date
Coxxs
0c165c3f62 Move ProcessInfo and Minidump to HleProcessDebugger (ryubing/ryujinx!187)
See merge request ryubing/ryujinx!187
2025-10-22 16:20:13 -05:00
GreemDev
91da244c02 gdb: some more cleanups 2025-10-22 15:04:03 -05:00
GreemDev
904d4a7eb0 gdb: Make waiting for a process to start more forgiving (200ms per poll 10x -> 500ms) 2025-10-22 01:07:19 -05:00
Coxxs
1248a054de gdb: Abort if unable to start GDB server (ryubing/ryujinx!186)
See merge request ryubing/ryujinx!186
2025-10-21 23:16:18 -05:00
GreemDev
1bb2af84ce gdb: Catch SocketException from TcpListener#Start 2025-10-21 22:15:14 -05:00
GreemDev
886981004d chore: I thought I removed these months ago lol 2025-10-21 20:33:35 -05:00
Coxxs
e551dda17e gdb: fix IsProcess32Bit throws exception if called too early (ryubing/ryujinx!185)
See merge request ryubing/ryujinx!185
2025-10-20 21:35:55 -05:00
GreemDev
ed67535227 chore: [si skip] fix in-code typos 2025-10-20 21:32:23 -05:00
GreemDev
7d65611b96 gdb: [ci skip] just had a brain wave 2025-10-20 21:20:41 -05:00
GreemDev
71eb844dd8 gdb: dynamic rcmd system & more cleanups 2025-10-20 21:18:16 -05:00
16 changed files with 237 additions and 281 deletions

View File

@@ -1,22 +0,0 @@
using SharpMetal;
using SharpMetal.Foundation;
using SharpMetal.ObjectiveCCore;
using SharpMetal.QuartzCore;
using System.Runtime.Versioning;
// ReSharper disable InconsistentNaming
namespace Ryujinx.Graphics.Metal.SharpMetalExtensions
{
[SupportedOSPlatform("macOS")]
public static class CAMetalLayerExtensions
{
private static readonly Selector sel_developerHUDProperties = "developerHUDProperties";
private static readonly Selector sel_setDeveloperHUDProperties = "setDeveloperHUDProperties:";
public static NSDictionary GetDeveloperHudProperties(this CAMetalLayer metalLayer)
=> new(ObjectiveCRuntime.IntPtr_objc_msgSend(metalLayer.NativePtr, sel_developerHUDProperties));
public static void SetDeveloperHudProperties(this CAMetalLayer metalLayer, NSDictionary dictionary)
=> ObjectiveCRuntime.objc_msgSend(metalLayer.NativePtr, sel_setDeveloperHUDProperties, dictionary);
}
}

View File

@@ -1,32 +0,0 @@
using SharpMetal.Foundation;
using SharpMetal.ObjectiveCCore;
using System.Runtime.Versioning;
// ReSharper disable InconsistentNaming
namespace Ryujinx.Graphics.Metal.SharpMetalExtensions
{
[SupportedOSPlatform("macOS")]
public static class NSHelper
{
private static readonly Selector sel_getCStringMaxLengthEncoding = "getCString:maxLength:encoding:";
private static readonly Selector sel_stringWithUTF8String = "stringWithUTF8String:";
public static unsafe string ToDotNetString(this NSString source)
{
char[] sourceBuffer = new char[source.Length];
fixed (char* pSourceBuffer = sourceBuffer)
{
ObjectiveC.bool_objc_msgSend(source,
sel_getCStringMaxLengthEncoding,
pSourceBuffer,
source.MaximumLengthOfBytes(NSStringEncoding.UTF16) + 1,
(ulong)NSStringEncoding.UTF16);
}
return new string(sourceBuffer);
}
public static NSString ToNSString(this string source)
=> new(ObjectiveC.IntPtr_objc_msgSend(new ObjectiveCClass(nameof(NSString)), sel_stringWithUTF8String, source));
}
}

View File

@@ -1,11 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SharpMetal" />
</ItemGroup>
</Project>

View File

@@ -1,5 +1,6 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.Debugger.Gdb;
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
@@ -9,11 +10,22 @@ namespace Ryujinx.HLE.Debugger
{
public partial class Debugger
{
private void DebuggerThreadMain()
private void MainLoop()
{
IPEndPoint endpoint = new(IPAddress.Any, GdbStubPort);
_listenerSocket = new TcpListener(endpoint);
_listenerSocket.Start();
try
{
_listenerSocket.Start();
}
catch (SocketException se)
{
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");
while (!_shuttingDown)
@@ -22,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;
}
@@ -31,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)
@@ -46,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");
@@ -64,7 +77,7 @@ namespace Ryujinx.HLE.Debugger
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
continue;
case '\x03':
_messages.Add(StatelessMessage.BreakIn);
_messages.Add(Message.BreakIn);
break;
case '$':
string cmd = string.Empty;
@@ -85,7 +98,7 @@ namespace Ryujinx.HLE.Debugger
}
else
{
_messages.Add(StatelessMessage.SendNack);
_messages.Add(Message.SendNack);
}
break;
@@ -105,7 +118,6 @@ namespace Ryujinx.HLE.Debugger
_writeStream = null;
_clientSocket.Close();
_clientSocket = null;
_commandProcessor = null;
_commands = null;
BreakpointManager.ClearAll();

View File

@@ -14,29 +14,29 @@ namespace Ryujinx.HLE.Debugger
{
switch (_messages.Take())
{
case StatelessMessage { Type: MessageType.BreakIn }:
case Message { Type: MessageType.BreakIn }:
Logger.Notice.Print(LogClass.GdbStub, "Break-in requested");
_commands.Interrupt();
break;
case StatelessMessage { Type: MessageType.SendNack }:
case Message { Type: MessageType.SendNack }:
_writeStream.WriteByte((byte)'-');
break;
case StatelessMessage { Type: MessageType.Kill }:
case Message { Type: MessageType.Kill }:
return;
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;
}
}

View File

@@ -1,13 +1,49 @@
using Gommon;
using JetBrains.Annotations;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Kernel.Process;
using Ryujinx.HLE.HOS.Kernel.Threading;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ryujinx.HLE.Debugger
{
public partial class Debugger
{
static Debugger()
{
_rcmdDelegates.Add(["help"],
_ => _rcmdDelegates.Keys
.Where(x => !x[0].Equals("help"))
.Select(x => x.JoinToString('\n'))
.JoinToString('\n') + '\n'
);
_rcmdDelegates.Add(["get info"], dbgr => dbgr.GetProcessInfo());
_rcmdDelegates.Add(["backtrace", "bt"], dbgr => dbgr.GetStackTrace());
_rcmdDelegates.Add(["registers", "reg"], dbgr => dbgr.GetRegisters());
_rcmdDelegates.Add(["minidump"], dbgr => dbgr.GetMinidump());
}
private static readonly Dictionary<string[], Func<Debugger, string>> _rcmdDelegates = new();
public static Func<Debugger, string> FindRcmdDelegate(string command)
{
Func<Debugger, string> searchResult = _ => $"Unknown command: {command}\n";
foreach ((string[] names, Func<Debugger, string> dlg) in _rcmdDelegates)
{
if (names.ContainsIgnoreCase(command.Trim()))
{
searchResult = dlg;
break;
}
}
return searchResult;
}
public string GetStackTrace()
{
if (GThread == null)
@@ -26,38 +62,16 @@ namespace Ryujinx.HLE.Debugger
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}]");
}
}
var 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()
@@ -67,32 +81,10 @@ namespace Ryujinx.HLE.Debugger
if (Process is not { } kProcess)
return "No application process found\n";
StringBuilder sb = new();
if (kProcess.Debugger is not { } debugger)
return $"Error getting process info: debugger is null\n";
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 debugger.GetProcessInfoPrintout();
}
catch (Exception e)
{

View File

@@ -4,10 +4,8 @@ using Ryujinx.HLE.HOS.Kernel.Process;
using Ryujinx.HLE.HOS.Kernel.Threading;
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using IExecutionContext = Ryujinx.Cpu.IExecutionContext;
@@ -20,7 +18,7 @@ namespace Ryujinx.HLE.Debugger
public ushort GdbStubPort { get; private set; }
private readonly BlockingCollection<IMessage> _messages = new(1);
private readonly BlockingCollection<Message.IMarker> _messages = new(1);
private readonly Thread _debuggerThread;
private readonly Thread _messageHandlerThread;
@@ -28,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;
@@ -47,7 +44,7 @@ namespace Ryujinx.HLE.Debugger
ARMeilleure.Optimizations.EnableDebugging = true;
_debuggerThread = new Thread(DebuggerThreadMain);
_debuggerThread = new Thread(MainLoop);
_debuggerThread.Start();
_messageHandlerThread = new Thread(MessageHandlerMain);
_messageHandlerThread.Start();
@@ -59,8 +56,8 @@ namespace Ryujinx.HLE.Debugger
internal KThread[] GetThreads() => DebugProcess.ThreadUids.Select(DebugProcess.GetThread).ToArray();
internal bool IsProcess32Bit => DebugProcess.GetThread(GThread.Value).Context.IsAarch32;
internal bool IsProcess32Bit => DebugProcess.GetThread(GThread ?? DebugProcess.ThreadUids.First()).Context.IsAarch32;
internal bool WriteRegister(IExecutionContext ctx, int registerId, StringStream ss) =>
IsProcess32Bit
? ctx.WriteRegister32(registerId, ss)
@@ -89,7 +86,7 @@ namespace Ryujinx.HLE.Debugger
_readStream?.Close();
_writeStream?.Close();
_debuggerThread.Join();
_messages.Add(StatelessMessage.Kill);
_messages.Add(Message.Kill);
_messageHandlerThread.Join();
_messages.Dispose();
_breakHandlerEvent.Dispose();

View File

@@ -20,6 +20,9 @@ namespace Ryujinx.HLE.Debugger.Gdb
Commands = commands;
}
public void ReplyHex(string data) => Reply(Helpers.ToHex(data));
public void ReplyHex(byte[] data) => Reply(Helpers.ToHex(data));
public void Reply(string cmd)
{
Logger.Debug?.Print(LogClass.GdbStub, $"Reply: {cmd}");
@@ -197,11 +200,10 @@ namespace Ryujinx.HLE.Debugger.Gdb
break;
}
Reply(Helpers.ToHex(
DebugProcess.IsThreadPaused(DebugProcess.GetThread(threadId.Value))
? "Paused"
: "Running"
)
ReplyHex(
DebugProcess.IsThreadPaused(DebugProcess.GetThread(threadId.Value))
? "Paused"
: "Running"
);
break;

View File

@@ -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))
{
@@ -197,7 +181,7 @@ namespace Ryujinx.HLE.Debugger.Gdb
{
byte[] data = new byte[len];
Debugger.DebugProcess.CpuMemory.Read(addr, data);
Processor.Reply(Helpers.ToHex(data));
Processor.ReplyHex(data);
}
catch (InvalidMemoryRegionException)
{
@@ -422,17 +406,9 @@ namespace Ryujinx.HLE.Debugger.Gdb
string command = Helpers.FromHex(hexCommand);
Logger.Debug?.Print(LogClass.GdbStub, $"Received Rcmd: {command}");
string response = command.Trim().ToLowerInvariant() switch
{
"help" => "backtrace\nbt\nregisters\nreg\nget info\nminidump\n",
"get info" => Debugger.GetProcessInfo(),
"backtrace" or "bt" => Debugger.GetStackTrace(),
"registers" or "reg" => Debugger.GetRegisters(),
"minidump" => Debugger.GetMinidump(),
_ => $"Unknown command: {command}\n"
};
Func<Debugger, string> rcmd = Debugger.FindRcmdDelegate(command);
Processor.Reply(Helpers.ToHex(response));
Processor.ReplyHex(rcmd(Debugger));
}
catch (Exception e)
{

View File

@@ -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,
@@ -20,8 +23,8 @@ namespace Ryujinx.HLE.Debugger.Gdb
32 => Helpers.ToHex(BitConverter.GetBytes(state.DebugPc)),
33 => Helpers.ToHex(BitConverter.GetBytes(state.Pstate)),
>= 34 and <= 65 => Helpers.ToHex(state.GetV(registerId - 34).ToArray()),
66 => Helpers.ToHex(BitConverter.GetBytes((uint)state.Fpsr)),
67 => Helpers.ToHex(BitConverter.GetBytes((uint)state.Fpcr)),
66 => Helpers.ToHex(BitConverter.GetBytes(state.Fpsr)),
67 => Helpers.ToHex(BitConverter.GetBytes(state.Fpcr)),
_ => null
};

View File

@@ -6,6 +6,10 @@ namespace Ryujinx.HLE.Debugger
{
internal interface IDebuggableProcess
{
IVirtualMemoryManager CpuMemory { get; }
ulong[] ThreadUids { get; }
DebugState DebugState { get; }
void DebugStop();
void DebugContinue();
void DebugContinue(KThread thread);
@@ -13,9 +17,6 @@ namespace Ryujinx.HLE.Debugger
KThread GetThread(ulong threadUid);
bool IsThreadPaused(KThread thread);
public void DebugInterruptHandler(IExecutionContext ctx);
IVirtualMemoryManager CpuMemory { get; }
ulong[] ThreadUids { get; }
DebugState DebugState { get; }
void InvalidateCacheRegion(ulong address, ulong size);
}
}

View File

@@ -2,11 +2,6 @@ using Ryujinx.Cpu;
namespace Ryujinx.HLE.Debugger
{
/// <summary>
/// Marker interface for debugger messages.
/// </summary>
interface IMessage;
public enum MessageType
{
Kill,
@@ -14,14 +9,19 @@ namespace Ryujinx.HLE.Debugger
SendNack
}
record struct StatelessMessage(MessageType Type) : IMessage
record struct Message(MessageType Type) : Message.IMarker
{
public static StatelessMessage Kill => new(MessageType.Kill);
public static StatelessMessage BreakIn => new(MessageType.BreakIn);
public static StatelessMessage SendNack => new(MessageType.SendNack);
/// <summary>
/// Marker interface for debugger messages.
/// </summary>
internal interface IMarker;
public static Message Kill => new(MessageType.Kill);
public static Message BreakIn => new(MessageType.BreakIn);
public static Message SendNack => new(MessageType.SendNack);
}
struct CommandMessage : IMessage
struct CommandMessage : Message.IMarker
{
public readonly string Command;
@@ -31,7 +31,7 @@ namespace Ryujinx.HLE.Debugger
}
}
public class ThreadBreakMessage : IMessage
public class ThreadBreakMessage : Message.IMarker
{
public IExecutionContext Context { get; }
public ulong Address { get; }

View File

@@ -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;

View File

@@ -83,23 +83,23 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlySpan<AtomicStorage<T>> ReadEntries(uint maxCount)
{
ulong countAvailaible = Math.Min(Math.Max(0, ReadCurrentCount()), maxCount);
ulong countAvailable = Math.Min(Math.Max(0, ReadCurrentCount()), maxCount);
if (countAvailaible == 0)
if (countAvailable == 0)
{
return ReadOnlySpan<AtomicStorage<T>>.Empty;
}
ulong index = ReadCurrentIndex();
AtomicStorage<T>[] result = new AtomicStorage<T>[countAvailaible];
AtomicStorage<T>[] result = new AtomicStorage<T>[countAvailable];
Span<AtomicStorage<T>> storageSpan = _storage.AsSpan();
for (ulong i = 0; i < countAvailaible; i++)
for (ulong i = 0; i < countAvailable; i++)
{
int inputEntryIndex = (int)((index + MaxEntries + 1 - countAvailaible + i) % MaxEntries);
int outputEntryIndex = (int)(countAvailaible - i - 1);
int inputEntryIndex = (int)((index + MaxEntries + 1 - countAvailable + i) % MaxEntries);
int outputEntryIndex = (int)(countAvailable - i - 1);
ulong samplingNumber0 = storageSpan[inputEntryIndex].ReadSamplingNumberAtomic();
result[outputEntryIndex] = storageSpan[inputEntryIndex];
@@ -107,9 +107,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common
if (samplingNumber0 != samplingNumber1 && (i > 0 && (result[outputEntryIndex].SamplingNumber - result[outputEntryIndex].SamplingNumber) != 1))
{
ulong tempCount = Math.Min(ReadCurrentCount(), countAvailaible);
ulong tempCount = Math.Min(ReadCurrentCount(), countAvailable);
countAvailaible = Math.Min(tempCount, maxCount);
countAvailable = Math.Min(tempCount, maxCount);
index = ReadCurrentIndex();
i -= 1;

View File

@@ -59,18 +59,18 @@ namespace Ryujinx.HLE.UI.Input
}
}
public void Update(bool supressEvents = false)
public void Update(bool suppressEvents = false)
{
int npadsCount = _device.Hid.SharedMemory.Npads.Length;
// Process each input individually.
for (int npadIndex = 0; npadIndex < npadsCount; npadIndex++)
{
UpdateNpad(npadIndex, supressEvents);
UpdateNpad(npadIndex, suppressEvents);
}
}
private void UpdateNpad(int npadIndex, bool supressEvents)
private void UpdateNpad(int npadIndex, bool suppressEvents)
{
const int MaxEntries = 1024;
@@ -103,7 +103,7 @@ namespace Ryujinx.HLE.UI.Input
break;
}
if (!supressEvents)
if (!suppressEvents)
{
ProcessNpadButtons(npadIndex, entry.Object.Buttons);
}

View File

@@ -1,72 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>1.0.0-dirty</Version>
<DefineConstants Condition=" '$(ExtraDefineConstants)' != '' ">$(DefineConstants);$(ExtraDefineConstants)</DefineConstants>
<SigningCertificate Condition=" '$(SigningCertificate)' == '' ">-</SigningCertificate>
<TieredPGO>true</TieredPGO>
<DefaultItemExcludes>$(DefaultItemExcludes);._*</DefaultItemExcludes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OpenTK.Core" />
<PackageReference Include="Ryujinx.Graphics.Nvdec.Dependencies" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<Exec Command="codesign --entitlements '$(ProjectDir)..\..\distribution\macos\entitlements.xml' -f -s $(SigningCertificate) '$(TargetDir)$(TargetName)'" />
</Target>
<ItemGroup>
<ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
<ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
<ProjectReference Include="..\Ryujinx.HLE\Ryujinx.HLE.csproj" />
<ProjectReference Include="..\ARMeilleure\ARMeilleure.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics.OpenGL\Ryujinx.Graphics.OpenGL.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics.Gpu\Ryujinx.Graphics.Gpu.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" />
<PackageReference Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'linux-arm64' AND '$(RuntimeIdentifier)' != 'win-x64'" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\distribution\legal\THIRDPARTY.md">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>THIRDPARTY.md</TargetPath>
</Content>
<Content Include="..\..\LICENSE.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>LICENSE.txt</TargetPath>
</Content>
</ItemGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-x64' OR '$(RuntimeIdentifier)' == 'linux-arm64' OR ('$(RuntimeIdentifier)' == '' AND $([MSBuild]::IsOSPlatform('Linux')))">
<Content Include="..\..\distribution\linux\Ryujinx.sh">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Ryujinx.bmp" />
</ItemGroup>
<!-- Due to .net core 3.1 embedded resource loading -->
<PropertyGroup>
<EmbeddedResourceUseDependentUponConvention>false</EmbeddedResourceUseDependentUponConvention>
<ApplicationIcon>..\Ryujinx\Ryujinx.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' != ''">
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>partial</TrimMode>
</PropertyGroup>
</Project>