mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-10-17 22:55:01 +00:00
Compare commits
17 Commits
Canary-1.3
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2a2ab523cb | ||
![]() |
8e941e4a8f | ||
![]() |
9aacf9b37b | ||
![]() |
2b159dbca8 | ||
![]() |
c33a97f01c | ||
![]() |
fdbdb05cb5 | ||
![]() |
7268acbfb4 | ||
![]() |
d4107ac05f | ||
![]() |
1d409f7127 | ||
![]() |
2434c55266 | ||
![]() |
99126603ba | ||
![]() |
a62716002e | ||
![]() |
47559cd311 | ||
![]() |
51584a083b | ||
![]() |
ceec9617ef | ||
![]() |
1865be47cf | ||
![]() |
ef9810582a |
@ -40,7 +40,7 @@
|
||||
<PackageVersion Include="Ryujinx.Audio.OpenAL.Dependencies" Version="1.21.0.1" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Nvdec.Dependencies.AllArch" Version="6.1.2-build3" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" />
|
||||
<PackageVersion Include="Ryujinx.LibHac" Version="0.21.0-alpha.116" />
|
||||
<PackageVersion Include="Ryujinx.LibHac" Version="0.21.0-alpha.117" />
|
||||
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" />
|
||||
<PackageVersion Include="Ryujinx.UpdateClient" Version="1.0.44" />
|
||||
<PackageVersion Include="Ryujinx.Systems.Update.Common" Version="1.0.44" />
|
||||
|
@ -3629,7 +3629,7 @@
|
||||
"he_IL": "ממשק קלאסי (הפעלה מחדש דרושה)",
|
||||
"it_IT": "Interfaccia classica (Riavvio necessario)",
|
||||
"ja_JP": "クラシックインターフェース(再起動必要)",
|
||||
"ko_KR": "클래식 인터페이스 (재시작 필요)",
|
||||
"ko_KR": "클래식 인터페이스(다시 시작 필요)",
|
||||
"no_NO": "Klassisk grensesnitt (Krever omstart)",
|
||||
"pl_PL": "Klasyczny interfejs (Wymaga restartu)",
|
||||
"pt_BR": "Interface Clássica (Reinício necessário)",
|
||||
@ -6445,26 +6445,27 @@
|
||||
{
|
||||
"ID": "SettingsButtonResetConfirm",
|
||||
"Translations": {
|
||||
"ar_SA": "أريد إعادة تعيين إعداداتي",
|
||||
"de_DE": "Ich möchte meine Einstellungen zurücksetzen",
|
||||
"el_GR": "Θέλω να επαναφέρω τις ρυθμίσεις μου",
|
||||
"en_US": "I Want To Reset My Settings",
|
||||
"es_ES": "Quiero Restablecer Mi Configuración",
|
||||
"fr_FR": "Je Veux Réinitialiser Mes Paramètres",
|
||||
"he_IL": "אני רוצה לאפס את ההגדרות שלי",
|
||||
"it_IT": "Voglio reimpostare le mie impostazioni",
|
||||
"ja_JP": "設定をリセットしたいです",
|
||||
"ko_KR": "설정을 초기화하고 싶습니다",
|
||||
"no_NO": "Jeg vil tilbakestille innstillingene mine",
|
||||
"pl_PL": "Chcę zresetować moje ustawienia",
|
||||
"pt_BR": "Quero redefinir minhas configurações",
|
||||
"ru_RU": "Я хочу сбросить свои настройки",
|
||||
"sv_SE": "Jag vill nollställa mina inställningar",
|
||||
"th_TH": "ฉันต้องการรีเซ็ตการตั้งค่าของฉัน",
|
||||
"tr_TR": "Ayarlarımı sıfırlamak istiyorum",
|
||||
"uk_UA": "Я хочу скинути налаштування",
|
||||
"zh_CN": "我要重置我的设置",
|
||||
"zh_TW": "我想重設我的設定"
|
||||
"ar_SA": "",
|
||||
"de_DE": "",
|
||||
"el_GR": "",
|
||||
"en_US": "I want to reset my settings.",
|
||||
"es_ES": "Quiero restablecer mi Configuración.",
|
||||
"fr_FR": "Je veux réinitialiser mes paramètres.",
|
||||
"he_IL": "",
|
||||
"it_IT": "Voglio ripristinare le mie impostazioni.",
|
||||
"ja_JP": "",
|
||||
"ko_KR": "설정을 초기화하고 싶습니다.",
|
||||
"no_NO": "Jeg vil tilbakestille innstillingene mine.",
|
||||
"pl_PL": "",
|
||||
"pt_BR": "Quero redefinir minhas configurações.",
|
||||
"ru_RU": "Я хочу сбросить свои настройки.",
|
||||
"sv_SE": "Jag vill nollställa mina inställningar.",
|
||||
"th_TH": "",
|
||||
"tr_TR": "",
|
||||
"uk_UA": "Я хочу скинути налаштування.",
|
||||
"zh_CN": "我要重置我的设置。",
|
||||
"zh_TW": "我想重設我的設定。"
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -2280,6 +2280,7 @@
|
||||
01008F6008C5E000,"Pokémon™ Violet",gpu;nvdec;ldn-works;amd-vendor-bug;mac-bug,ingame,2024-07-30 02:51:48
|
||||
0100187003A36000,"Pokémon™: Let’s Go, Eevee!",crash;nvdec;online-broken;ldn-broken,ingame,2024-06-01 15:03:04
|
||||
010003F003A34000,"Pokémon™: Let’s Go, Pikachu!",crash;nvdec;online-broken;ldn-broken,ingame,2024-03-15 07:55:41
|
||||
0100F43008C44000,"Pokémon Legends: Z-A",gpu;crash;ldn-broken,ingame,2025-10-16 19:13:00
|
||||
0100B3F000BE2000,"Pokkén Tournament™ DX",nvdec;ldn-works;opengl-backend-bug;LAN;amd-vendor-bug;intel-vendor-bug,playable,2024-07-18 23:11:08
|
||||
010030D005AE6000,"Pokkén Tournament™ DX Demo",demo;opengl-backend-bug,playable,2022-08-10 12:03:19
|
||||
0100A3500B4EC000,"Polandball: Can Into Space",,playable,2020-06-25 15:13:26
|
||||
|
|
@ -201,11 +201,7 @@ namespace ARMeilleure.Instructions
|
||||
|
||||
ExecutionContext context = GetContext();
|
||||
|
||||
// If debugging, we'll handle interrupts outside
|
||||
if (!Optimizations.EnableDebugging)
|
||||
{
|
||||
context.CheckInterrupt();
|
||||
}
|
||||
context.CheckInterrupt();
|
||||
|
||||
Statistics.ResumeTimer();
|
||||
|
||||
|
@ -187,6 +187,17 @@ namespace Ryujinx.Common.Logging
|
||||
}
|
||||
}
|
||||
|
||||
public static void Flush()
|
||||
{
|
||||
foreach (ILogTarget target in _logTargets)
|
||||
{
|
||||
if (target is AsyncLogTargetWrapper asyncTarget)
|
||||
{
|
||||
asyncTarget.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
Updated = null;
|
||||
|
@ -27,6 +27,17 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
|
||||
private readonly int _overflowTimeout;
|
||||
|
||||
private sealed class FlushEventArgs : LogEventArgs
|
||||
{
|
||||
public readonly ManualResetEventSlim SignalEvent;
|
||||
|
||||
public FlushEventArgs(ManualResetEventSlim signalEvent)
|
||||
: base(LogLevel.Notice, TimeSpan.Zero, string.Empty, string.Empty)
|
||||
{
|
||||
SignalEvent = signalEvent;
|
||||
}
|
||||
}
|
||||
|
||||
string ILogTarget.Name => _target.Name;
|
||||
|
||||
public AsyncLogTargetWrapper(ILogTarget target, int queueLimit = -1, AsyncLogTargetOverflowAction overflowAction = AsyncLogTargetOverflowAction.Block)
|
||||
@ -41,7 +52,15 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
{
|
||||
try
|
||||
{
|
||||
_target.Log(this, _messageQueue.Take());
|
||||
LogEventArgs item = _messageQueue.Take();
|
||||
|
||||
if (item is FlushEventArgs flush)
|
||||
{
|
||||
flush.SignalEvent.Set();
|
||||
continue;
|
||||
}
|
||||
|
||||
_target.Log(this, item);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
@ -68,6 +87,26 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
}
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
if (_messageQueue.Count == 0 || _messageQueue.IsAddingCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var signal = new ManualResetEventSlim(false);
|
||||
try
|
||||
{
|
||||
_messageQueue.Add(new FlushEventArgs(signal));
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
signal.Wait();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
@ -106,6 +106,7 @@ namespace Ryujinx.Common
|
||||
"0100b3f000be2000", // Pokkén Tournament DX
|
||||
"0100187003a36000", // Pokémon: Let's Go Eevee!
|
||||
"010003f003a34000", // Pokémon: Let's Go Pikachu!
|
||||
"0100f43008c44000", // Pokémon Legends: Z-A
|
||||
|
||||
//Splatoon Franchise
|
||||
"0100f8f0000a2000", // Splatoon 2 (EU)
|
||||
|
@ -11,12 +11,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public byte[] OriginalData { get; }
|
||||
|
||||
public bool IsStep { get; }
|
||||
|
||||
public Breakpoint(byte[] originalData, bool isStep)
|
||||
public Breakpoint(byte[] originalData)
|
||||
{
|
||||
OriginalData = originalData;
|
||||
IsStep = isStep;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,9 +25,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
private readonly Debugger _debugger;
|
||||
private readonly ConcurrentDictionary<ulong, Breakpoint> _breakpoints = new();
|
||||
|
||||
private static readonly byte[] _aarch64BreakInstruction = { 0x00, 0x00, 0x20, 0xD4 }; // BRK #0
|
||||
private static readonly byte[] _aarch32BreakInstruction = { 0xFE, 0xDE, 0xFF, 0xE7 }; // TRAP
|
||||
private static readonly byte[] _aarch32ThumbBreakInstruction = { 0x80, 0xB6 };
|
||||
private static readonly byte[] _aarch64BreakInstruction = [0x00, 0x00, 0x20, 0xD4]; // BRK #0
|
||||
private static readonly byte[] _aarch32BreakInstruction = [0xFE, 0xDE, 0xFF, 0xE7]; // TRAP
|
||||
private static readonly byte[] _aarch32ThumbBreakInstruction = [0x80, 0xB6];
|
||||
|
||||
public BreakpointManager(Debugger debugger)
|
||||
{
|
||||
@ -44,7 +41,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
/// <param name="length">The length of the instruction to replace.</param>
|
||||
/// <param name="isStep">Indicates if this is a single-step breakpoint.</param>
|
||||
/// <returns>True if the breakpoint was set successfully; otherwise, false.</returns>
|
||||
public bool SetBreakPoint(ulong address, ulong length, bool isStep = false)
|
||||
public bool SetBreakPoint(ulong address, ulong length)
|
||||
{
|
||||
if (_breakpoints.ContainsKey(address))
|
||||
{
|
||||
@ -71,7 +68,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
return false;
|
||||
}
|
||||
|
||||
var breakpoint = new Breakpoint(originalInstruction, isStep);
|
||||
var breakpoint = new Breakpoint(originalInstruction);
|
||||
if (_breakpoints.TryAdd(address, breakpoint))
|
||||
{
|
||||
Logger.Debug?.Print(LogClass.GdbStub, $"Breakpoint set at 0x{address:X16}");
|
||||
@ -124,33 +121,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
Logger.Debug?.Print(LogClass.GdbStub, "All breakpoints cleared.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all currently set single-step software breakpoints.
|
||||
/// </summary>
|
||||
public void ClearAllStepBreakpoints()
|
||||
{
|
||||
var stepBreakpoints = _breakpoints.Where(p => p.Value.IsStep).ToList();
|
||||
|
||||
if (stepBreakpoints.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var bp in stepBreakpoints)
|
||||
{
|
||||
if (_breakpoints.TryRemove(bp.Key, out Breakpoint removedBreakpoint))
|
||||
{
|
||||
WriteMemory(bp.Key, removedBreakpoint.OriginalData);
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Debug?.Print(LogClass.GdbStub, "All step breakpoints cleared.");
|
||||
}
|
||||
|
||||
|
||||
private byte[] GetBreakInstruction(ulong length)
|
||||
{
|
||||
if (_debugger.IsProcessAarch32)
|
||||
if (_debugger.IsProcess32Bit)
|
||||
{
|
||||
if (length == 2)
|
||||
{
|
||||
|
115
src/Ryujinx.HLE/Debugger/Debugger.MainThread.cs
Normal file
115
src/Ryujinx.HLE/Debugger/Debugger.MainThread.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.Debugger.Gdb;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public partial class Debugger
|
||||
{
|
||||
private void DebuggerThreadMain()
|
||||
{
|
||||
IPEndPoint endpoint = new(IPAddress.Any, GdbStubPort);
|
||||
_listenerSocket = new TcpListener(endpoint);
|
||||
_listenerSocket.Start();
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Currently waiting on {endpoint} for GDB client");
|
||||
|
||||
while (!_shuttingDown)
|
||||
{
|
||||
try
|
||||
{
|
||||
_clientSocket = _listenerSocket.AcceptSocket();
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user connects before the application is running, wait for the application to start.
|
||||
int retries = 10;
|
||||
while ((DebugProcess == null || GetThreads().Length == 0) && retries-- > 0)
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
|
||||
if (DebugProcess == null || GetThreads().Length == 0)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.GdbStub,
|
||||
"Application is not running, cannot accept GDB client connection");
|
||||
_clientSocket.Close();
|
||||
continue;
|
||||
}
|
||||
|
||||
_clientSocket.NoDelay = true;
|
||||
_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");
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (_readStream.ReadByte())
|
||||
{
|
||||
case -1:
|
||||
goto EndOfLoop;
|
||||
case '+':
|
||||
continue;
|
||||
case '-':
|
||||
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
|
||||
continue;
|
||||
case '\x03':
|
||||
_messages.Add(new BreakInMessage());
|
||||
break;
|
||||
case '$':
|
||||
string cmd = "";
|
||||
while (true)
|
||||
{
|
||||
int x = _readStream.ReadByte();
|
||||
if (x == -1)
|
||||
goto EndOfLoop;
|
||||
if (x == '#')
|
||||
break;
|
||||
cmd += (char)x;
|
||||
}
|
||||
|
||||
string checksum = $"{(char)_readStream.ReadByte()}{(char)_readStream.ReadByte()}";
|
||||
if (checksum == $"{Helpers.CalculateChecksum(cmd):x2}")
|
||||
{
|
||||
_messages.Add(new CommandMessage(cmd));
|
||||
}
|
||||
else
|
||||
{
|
||||
_messages.Add(new SendNackMessage());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
goto EndOfLoop;
|
||||
}
|
||||
}
|
||||
|
||||
EndOfLoop:
|
||||
Logger.Notice.Print(LogClass.GdbStub, "GDB client lost connection");
|
||||
_readStream.Close();
|
||||
_readStream = null;
|
||||
_writeStream.Close();
|
||||
_writeStream = null;
|
||||
_clientSocket.Close();
|
||||
_clientSocket = null;
|
||||
_commandProcessor = null;
|
||||
_commands = null;
|
||||
|
||||
BreakpointManager.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
407
src/Ryujinx.HLE/Debugger/Gdb/CommandProcessor.cs
Normal file
407
src/Ryujinx.HLE/Debugger/Gdb/CommandProcessor.cs
Normal file
@ -0,0 +1,407 @@
|
||||
using Gommon;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger.Gdb
|
||||
{
|
||||
class GdbCommandProcessor
|
||||
{
|
||||
public readonly GdbCommands Commands;
|
||||
|
||||
private Debugger Debugger => Commands.Debugger;
|
||||
private BreakpointManager BreakpointManager => Commands.Debugger.BreakpointManager;
|
||||
private IDebuggableProcess DebugProcess => Commands.Debugger.DebugProcess;
|
||||
|
||||
public GdbCommandProcessor(GdbCommands commands)
|
||||
{
|
||||
Commands = commands;
|
||||
}
|
||||
|
||||
public void Reply(string cmd)
|
||||
{
|
||||
Logger.Debug?.Print(LogClass.GdbStub, $"Reply: {cmd}");
|
||||
Commands.WriteStream.Write(Encoding.ASCII.GetBytes($"${cmd}#{Helpers.CalculateChecksum(cmd):x2}"));
|
||||
}
|
||||
|
||||
public void ReplyOK() => Reply("OK");
|
||||
|
||||
public void ReplyError() => Reply("E01");
|
||||
|
||||
public void Reply(bool success)
|
||||
{
|
||||
if (success)
|
||||
ReplyOK();
|
||||
else ReplyError();
|
||||
}
|
||||
|
||||
public void Reply(bool success, string cmd)
|
||||
{
|
||||
if (success)
|
||||
Reply(cmd);
|
||||
else ReplyError();
|
||||
}
|
||||
|
||||
private string _previousThreadListXml = string.Empty;
|
||||
|
||||
public void Process(string cmd)
|
||||
{
|
||||
StringStream ss = new(cmd);
|
||||
|
||||
switch (ss.ReadChar())
|
||||
{
|
||||
case '!':
|
||||
if (!ss.IsEmpty())
|
||||
{
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
// Enable extended mode
|
||||
ReplyOK();
|
||||
break;
|
||||
case '?':
|
||||
if (!ss.IsEmpty())
|
||||
{
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
Commands.Query();
|
||||
break;
|
||||
case 'c':
|
||||
Commands.Continue(ss.IsEmpty() ? null : ss.ReadRemainingAsHex());
|
||||
break;
|
||||
case 'D':
|
||||
if (!ss.IsEmpty())
|
||||
{
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
Commands.Detach();
|
||||
break;
|
||||
case 'g':
|
||||
if (!ss.IsEmpty())
|
||||
{
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
Commands.ReadRegisters();
|
||||
break;
|
||||
case 'G':
|
||||
Commands.WriteRegisters(ss);
|
||||
break;
|
||||
case 'H':
|
||||
{
|
||||
char op = ss.ReadChar();
|
||||
ulong? threadId = ss.ReadRemainingAsThreadUid();
|
||||
Commands.SetThread(op, threadId);
|
||||
break;
|
||||
}
|
||||
case 'k':
|
||||
Logger.Notice.Print(LogClass.GdbStub, "Kill request received, detach instead");
|
||||
Reply(string.Empty);
|
||||
Commands.Detach();
|
||||
break;
|
||||
case 'm':
|
||||
{
|
||||
ulong addr = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadRemainingAsHex();
|
||||
Commands.ReadMemory(addr, len);
|
||||
break;
|
||||
}
|
||||
case 'M':
|
||||
{
|
||||
ulong addr = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadUntilAsHex(':');
|
||||
Commands.WriteMemory(addr, len, ss);
|
||||
break;
|
||||
}
|
||||
case 'p':
|
||||
{
|
||||
ulong gdbRegId = ss.ReadRemainingAsHex();
|
||||
Commands.ReadRegister((int)gdbRegId);
|
||||
break;
|
||||
}
|
||||
case 'P':
|
||||
{
|
||||
ulong gdbRegId = ss.ReadUntilAsHex('=');
|
||||
Commands.WriteRegister((int)gdbRegId, ss);
|
||||
break;
|
||||
}
|
||||
case 'q':
|
||||
if (ss.ConsumeRemaining("GDBServerVersion"))
|
||||
{
|
||||
Reply($"name:Ryujinx;version:{ReleaseInformation.Version};");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("HostInfo"))
|
||||
{
|
||||
Reply(
|
||||
Debugger.IsProcess32Bit
|
||||
? $"triple:{Helpers.ToHex("arm-unknown-linux-android")};endian:little;ptrsize:4;hostname:{Helpers.ToHex("Ryujinx")};"
|
||||
: $"triple:{Helpers.ToHex("aarch64-unknown-linux-android")};endian:little;ptrsize:8;hostname:{Helpers.ToHex("Ryujinx")};");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("ProcessInfo"))
|
||||
{
|
||||
Reply(
|
||||
Debugger.IsProcess32Bit
|
||||
? $"pid:1;cputype:12;cpusubtype:0;triple:{Helpers.ToHex("arm-unknown-linux-android")};ostype:unknown;vendor:none;endian:little;ptrsize:4;"
|
||||
: $"pid:1;cputype:100000c;cpusubtype:0;triple:{Helpers.ToHex("aarch64-unknown-linux-android")};ostype:unknown;vendor:none;endian:little;ptrsize:8;");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("Supported:") || ss.ConsumeRemaining("Supported"))
|
||||
{
|
||||
Reply("PacketSize=10000;qXfer:features:read+;qXfer:threads:read+;vContSupported+");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("Rcmd,"))
|
||||
{
|
||||
string hexCommand = ss.ReadRemaining();
|
||||
Commands.Q_Rcmd(hexCommand);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("fThreadInfo"))
|
||||
{
|
||||
Reply(
|
||||
$"m{Debugger.DebugProcess.GetThreadUids().Select(x => $"{x:x}").JoinToString(",")}");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("sThreadInfo"))
|
||||
{
|
||||
Reply("l");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("ThreadExtraInfo,"))
|
||||
{
|
||||
ulong? threadId = ss.ReadRemainingAsThreadUid();
|
||||
if (threadId == null)
|
||||
{
|
||||
ReplyError();
|
||||
break;
|
||||
}
|
||||
|
||||
Reply(Helpers.ToHex(
|
||||
DebugProcess.IsThreadPaused(DebugProcess.GetThread(threadId.Value))
|
||||
? "Paused"
|
||||
: "Running"
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("Xfer:threads:read:"))
|
||||
{
|
||||
ss.ReadUntil(':');
|
||||
ulong offset = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadRemainingAsHex();
|
||||
|
||||
string data;
|
||||
if (offset > 0)
|
||||
{
|
||||
data = _previousThreadListXml;
|
||||
}
|
||||
else
|
||||
{
|
||||
_previousThreadListXml = data = GetThreadListXml();
|
||||
}
|
||||
|
||||
if (offset >= (ulong)data.Length)
|
||||
{
|
||||
Reply("l");
|
||||
break;
|
||||
}
|
||||
|
||||
if (len >= (ulong)data.Length - offset)
|
||||
{
|
||||
Reply("l" + Helpers.ToBinaryFormat(data.Substring((int)offset)));
|
||||
}
|
||||
else
|
||||
{
|
||||
Reply("m" + Helpers.ToBinaryFormat(data.Substring((int)offset, (int)len)));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("Xfer:features:read:"))
|
||||
{
|
||||
string feature = ss.ReadUntil(':');
|
||||
ulong offset = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadRemainingAsHex();
|
||||
|
||||
if (feature == "target.xml")
|
||||
{
|
||||
feature = Debugger.IsProcess32Bit ? "target32.xml" : "target64.xml";
|
||||
}
|
||||
|
||||
if (!RegisterInformation.Features.TryGetValue(feature, out string data))
|
||||
{
|
||||
Reply("E00"); // Invalid annex
|
||||
break;
|
||||
}
|
||||
|
||||
if (offset >= (ulong)data.Length)
|
||||
{
|
||||
Reply("l");
|
||||
break;
|
||||
}
|
||||
|
||||
if (len >= (ulong)data.Length - offset)
|
||||
{
|
||||
Reply("l" + Helpers.ToBinaryFormat(data[(int)offset..]));
|
||||
}
|
||||
else
|
||||
{
|
||||
Reply("m" + Helpers.ToBinaryFormat(data.Substring((int)offset, (int)len)));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
goto unknownCommand;
|
||||
case 'Q':
|
||||
goto unknownCommand;
|
||||
case 's':
|
||||
Commands.Step(ss.IsEmpty() ? null : ss.ReadRemainingAsHex());
|
||||
break;
|
||||
case 'T':
|
||||
{
|
||||
ulong? threadId = ss.ReadRemainingAsThreadUid();
|
||||
Commands.IsAlive(threadId);
|
||||
break;
|
||||
}
|
||||
case 'v':
|
||||
if (ss.ConsumePrefix("Cont"))
|
||||
{
|
||||
if (ss.ConsumeRemaining("?"))
|
||||
{
|
||||
Reply("vCont;c;C;s;S");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix(";"))
|
||||
{
|
||||
Commands.VCont(ss);
|
||||
break;
|
||||
}
|
||||
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("MustReplyEmpty"))
|
||||
{
|
||||
Reply(string.Empty);
|
||||
break;
|
||||
}
|
||||
|
||||
goto unknownCommand;
|
||||
case 'Z':
|
||||
{
|
||||
string type = ss.ReadUntil(',');
|
||||
ulong addr = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadLengthAsHex(1);
|
||||
string extra = ss.ReadRemaining();
|
||||
|
||||
if (extra.Length > 0)
|
||||
{
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Unsupported Z command extra data: {extra}");
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "0": // Software breakpoint
|
||||
if (!BreakpointManager.SetBreakPoint(addr, len))
|
||||
{
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
ReplyOK();
|
||||
return;
|
||||
// ReSharper disable RedundantCaseLabel
|
||||
case "1": // Hardware breakpoint
|
||||
case "2": // Write watchpoint
|
||||
case "3": // Read watchpoint
|
||||
case "4": // Access watchpoint
|
||||
// ReSharper restore RedundantCaseLabel
|
||||
default:
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
case 'z':
|
||||
{
|
||||
string type = ss.ReadUntil(',');
|
||||
ss.ConsumePrefix(",");
|
||||
ulong addr = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadLengthAsHex(1);
|
||||
string extra = ss.ReadRemaining();
|
||||
|
||||
if (extra.Length > 0)
|
||||
{
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Unsupported z command extra data: {extra}");
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "0": // Software breakpoint
|
||||
if (!BreakpointManager.ClearBreakPoint(addr, len))
|
||||
{
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
ReplyOK();
|
||||
return;
|
||||
// ReSharper disable RedundantCaseLabel
|
||||
case "1": // Hardware breakpoint
|
||||
case "2": // Write watchpoint
|
||||
case "3": // Read watchpoint
|
||||
case "4": // Access watchpoint
|
||||
// ReSharper restore RedundantCaseLabel
|
||||
default:
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
default:
|
||||
unknownCommand:
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Unknown command: {cmd}");
|
||||
Reply(string.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetThreadListXml()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.Append("<?xml version=\"1.0\"?><threads>\n");
|
||||
|
||||
foreach (KThread thread in Debugger.GetThreads())
|
||||
{
|
||||
string threadName = System.Security.SecurityElement.Escape(thread.GetThreadName());
|
||||
sb.Append(
|
||||
$"<thread id=\"{thread.ThreadUid:x}\" name=\"{threadName}\">{(DebugProcess.IsThreadPaused(thread) ? "Paused" : "Running")}</thread>\n");
|
||||
}
|
||||
|
||||
sb.Append("</threads>");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
451
src/Ryujinx.HLE/Debugger/Gdb/Commands.cs
Normal file
451
src/Ryujinx.HLE/Debugger/Gdb/Commands.cs
Normal file
@ -0,0 +1,451 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
|
||||
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; }
|
||||
|
||||
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)
|
||||
{
|
||||
ListenerSocket = listenerSocket;
|
||||
ClientSocket = clientSocket;
|
||||
ReadStream = readStream;
|
||||
WriteStream = writeStream;
|
||||
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.GetThreadUids().First();
|
||||
Processor.Reply($"T05thread:{Debugger.CThread: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))
|
||||
{
|
||||
Debugger.GThread = Debugger.CThread = Debugger.DebugProcess.GetThreadUids().First();
|
||||
}
|
||||
|
||||
Processor.Reply($"T02thread:{Debugger.GThread:x};");
|
||||
}
|
||||
|
||||
internal void Continue(ulong? newPc)
|
||||
{
|
||||
if (newPc.HasValue)
|
||||
{
|
||||
if (Debugger.CThread == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
Debugger.DebugProcess.GetThread(Debugger.CThread.Value).Context.DebugPc = newPc.Value;
|
||||
}
|
||||
|
||||
Debugger.DebugProcess.DebugContinue();
|
||||
}
|
||||
|
||||
internal void Detach()
|
||||
{
|
||||
Debugger.BreakpointManager.ClearAll();
|
||||
Continue(null);
|
||||
}
|
||||
|
||||
internal void ReadRegisters()
|
||||
{
|
||||
if (Debugger.GThread == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
string registers = string.Empty;
|
||||
if (Debugger.IsProcess32Bit)
|
||||
{
|
||||
for (int i = 0; i < GdbRegisterCount32; i++)
|
||||
{
|
||||
registers += GdbRegisters.Read32(ctx, i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < GdbRegisterCount64; i++)
|
||||
{
|
||||
registers += GdbRegisters.Read64(ctx, i);
|
||||
}
|
||||
}
|
||||
|
||||
Processor.Reply(registers);
|
||||
}
|
||||
|
||||
internal void WriteRegisters(StringStream ss)
|
||||
{
|
||||
if (Debugger.GThread == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
if (Debugger.IsProcess32Bit)
|
||||
{
|
||||
for (int i = 0; i < GdbRegisterCount32; i++)
|
||||
{
|
||||
if (!GdbRegisters.Write32(ctx, i, ss))
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < GdbRegisterCount64; i++)
|
||||
{
|
||||
if (!GdbRegisters.Write64(ctx, i, ss))
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Processor.Reply(ss.IsEmpty());
|
||||
}
|
||||
|
||||
internal void SetThread(char op, ulong? threadId)
|
||||
{
|
||||
if (threadId is 0 or null)
|
||||
{
|
||||
KThread[] threads = Debugger.GetThreads();
|
||||
if (threads.Length == 0)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
threadId = threads.First().ThreadUid;
|
||||
}
|
||||
|
||||
if (Debugger.DebugProcess.GetThread(threadId.Value) == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case 'c':
|
||||
Debugger.CThread = threadId;
|
||||
Processor.ReplyOK();
|
||||
return;
|
||||
case 'g':
|
||||
Debugger.GThread = threadId;
|
||||
Processor.ReplyOK();
|
||||
return;
|
||||
default:
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReadMemory(ulong addr, ulong len)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = new byte[len];
|
||||
Debugger.DebugProcess.CpuMemory.Read(addr, data);
|
||||
Processor.Reply(Helpers.ToHex(data));
|
||||
}
|
||||
catch (InvalidMemoryRegionException)
|
||||
{
|
||||
// InvalidAccessHandler will show an error message, we log it again to tell user the error is from GDB (which can be ignored)
|
||||
// TODO: Do not let InvalidAccessHandler show the error message
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"GDB failed to read memory at 0x{addr:X16}");
|
||||
Processor.ReplyError();
|
||||
}
|
||||
}
|
||||
|
||||
internal void WriteMemory(ulong addr, ulong len, StringStream ss)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = new byte[len];
|
||||
for (ulong i = 0; i < len; i++)
|
||||
{
|
||||
data[i] = (byte)ss.ReadLengthAsHex(2);
|
||||
}
|
||||
|
||||
Debugger.DebugProcess.CpuMemory.Write(addr, data);
|
||||
Debugger.DebugProcess.InvalidateCacheRegion(addr, len);
|
||||
Processor.ReplyOK();
|
||||
}
|
||||
catch (InvalidMemoryRegionException)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReadRegister(int gdbRegId)
|
||||
{
|
||||
if (Debugger.GThread == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
string result = Debugger.IsProcess32Bit
|
||||
? GdbRegisters.Read32(ctx, gdbRegId)
|
||||
: GdbRegisters.Read64(ctx, gdbRegId);
|
||||
|
||||
Processor.Reply(result != null, result);
|
||||
}
|
||||
|
||||
internal void WriteRegister(int gdbRegId, StringStream ss)
|
||||
{
|
||||
if (Debugger.GThread == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.DebugProcess.GetThread(Debugger.GThread.Value).Context;
|
||||
if (Debugger.IsProcess32Bit)
|
||||
{
|
||||
Processor.Reply(GdbRegisters.Write32(ctx, gdbRegId, ss) && ss.IsEmpty());
|
||||
}
|
||||
else
|
||||
{
|
||||
Processor.Reply(GdbRegisters.Write64(ctx, gdbRegId, ss) && ss.IsEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
internal void Step(ulong? newPc)
|
||||
{
|
||||
if (Debugger.CThread == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
KThread thread = Debugger.DebugProcess.GetThread(Debugger.CThread.Value);
|
||||
|
||||
if (newPc.HasValue)
|
||||
{
|
||||
thread.Context.DebugPc = newPc.Value;
|
||||
}
|
||||
|
||||
if (!Debugger.DebugProcess.DebugStep(thread))
|
||||
{
|
||||
Processor.ReplyError();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debugger.GThread = Debugger.CThread = thread.ThreadUid;
|
||||
Processor.Reply($"T05thread:{thread.ThreadUid:x};");
|
||||
}
|
||||
}
|
||||
|
||||
internal void IsAlive(ulong? threadId)
|
||||
{
|
||||
if (Debugger.GetThreads().Any(x => x.ThreadUid == threadId))
|
||||
{
|
||||
Processor.ReplyOK();
|
||||
}
|
||||
else
|
||||
{
|
||||
Processor.Reply("E00");
|
||||
}
|
||||
}
|
||||
|
||||
enum VContAction
|
||||
{
|
||||
None,
|
||||
Continue,
|
||||
Stop,
|
||||
Step
|
||||
}
|
||||
|
||||
record VContPendingAction(VContAction Action/*, ushort? Signal = null*/);
|
||||
|
||||
internal void VCont(StringStream ss)
|
||||
{
|
||||
string[] rawActions = ss.ReadRemaining().Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
Dictionary<ulong, VContPendingAction> threadActionMap = new();
|
||||
foreach (KThread thread in Debugger.GetThreads())
|
||||
{
|
||||
threadActionMap[thread.ThreadUid] = new VContPendingAction(VContAction.None);
|
||||
}
|
||||
|
||||
VContAction defaultAction = VContAction.None;
|
||||
|
||||
// For each inferior thread, the *leftmost* action with a matching thread-id is applied.
|
||||
for (int i = rawActions.Length - 1; i >= 0; i--)
|
||||
{
|
||||
string rawAction = rawActions[i];
|
||||
StringStream stream = new(rawAction);
|
||||
|
||||
char cmd = stream.ReadChar();
|
||||
VContAction action = cmd switch
|
||||
{
|
||||
'c' or 'C' => VContAction.Continue,
|
||||
's' or 'S' => VContAction.Step,
|
||||
't' => VContAction.Stop,
|
||||
_ => VContAction.None
|
||||
};
|
||||
|
||||
// Note: We don't support signals yet.
|
||||
//ushort? signal = null;
|
||||
if (cmd is 'C' or 'S')
|
||||
{
|
||||
/*signal = (ushort)*/stream.ReadLengthAsHex(2);
|
||||
// we still call the read length method even if we have signals commented
|
||||
// since that method advances the underlying string position
|
||||
}
|
||||
|
||||
ulong? threadId = null;
|
||||
if (stream.ConsumePrefix(":"))
|
||||
{
|
||||
threadId = stream.ReadRemainingAsThreadUid();
|
||||
}
|
||||
|
||||
if (threadId.HasValue)
|
||||
{
|
||||
if (threadActionMap.ContainsKey(threadId.Value))
|
||||
{
|
||||
threadActionMap[threadId.Value] = new VContPendingAction(action/*, signal*/);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (ulong thread in threadActionMap.Keys)
|
||||
{
|
||||
threadActionMap[thread] = new VContPendingAction(action/*, signal*/);
|
||||
}
|
||||
|
||||
if (action == VContAction.Continue)
|
||||
{
|
||||
defaultAction = action;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.GdbStub,
|
||||
$"Received vCont command with unsupported default action: {rawAction}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hasError = false;
|
||||
|
||||
foreach ((ulong threadUid, VContPendingAction action) in threadActionMap)
|
||||
{
|
||||
if (action.Action == VContAction.Step)
|
||||
{
|
||||
KThread thread = Debugger.DebugProcess.GetThread(threadUid);
|
||||
if (!Debugger.DebugProcess.DebugStep(thread))
|
||||
{
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we receive "vCont;c", just continue the process.
|
||||
// If we receive something like "vCont;c:2e;c:2f" (IDA Pro will send commands like this), continue these threads.
|
||||
// For "vCont;s:2f;c", `DebugProcess.DebugStep()` will continue and suspend other threads if needed, so we don't do anything here.
|
||||
if (threadActionMap.Values.All(a => a.Action == VContAction.Continue))
|
||||
{
|
||||
Debugger.DebugProcess.DebugContinue();
|
||||
}
|
||||
else if (defaultAction == VContAction.None)
|
||||
{
|
||||
foreach ((ulong threadUid, VContPendingAction action) in threadActionMap)
|
||||
{
|
||||
if (action.Action == VContAction.Continue)
|
||||
{
|
||||
Debugger.DebugProcess.DebugContinue(Debugger.DebugProcess.GetThread(threadUid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Processor.Reply(!hasError);
|
||||
|
||||
foreach ((ulong threadUid, VContPendingAction action) in threadActionMap)
|
||||
{
|
||||
if (action.Action == VContAction.Step)
|
||||
{
|
||||
Debugger.GThread = Debugger.CThread = threadUid;
|
||||
Processor.Reply($"T05thread:{threadUid:x};");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void Q_Rcmd(string hexCommand)
|
||||
{
|
||||
try
|
||||
{
|
||||
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"
|
||||
};
|
||||
|
||||
Processor.Reply(Helpers.ToHex(response));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub, $"Error processing Rcmd: {e.Message}");
|
||||
Processor.ReplyError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
160
src/Ryujinx.HLE/Debugger/Gdb/Registers.cs
Normal file
160
src/Ryujinx.HLE/Debugger/Gdb/Registers.cs
Normal file
@ -0,0 +1,160 @@
|
||||
using ARMeilleure.State;
|
||||
using Ryujinx.Cpu;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger.Gdb
|
||||
{
|
||||
static class GdbRegisters
|
||||
{
|
||||
/*
|
||||
FPCR = FPSR & ~FpcrMask
|
||||
All of FPCR's bits are reserved in FPCR and vice versa,
|
||||
see ARM's documentation.
|
||||
*/
|
||||
private const uint FpcrMask = 0xfc1fffff;
|
||||
|
||||
public static string Read64(IExecutionContext state, int gdbRegId)
|
||||
{
|
||||
switch (gdbRegId)
|
||||
{
|
||||
case >= 0 and <= 31:
|
||||
return Helpers.ToHex(BitConverter.GetBytes(state.GetX(gdbRegId)));
|
||||
case 32:
|
||||
return Helpers.ToHex(BitConverter.GetBytes(state.DebugPc));
|
||||
case 33:
|
||||
return Helpers.ToHex(BitConverter.GetBytes(state.Pstate));
|
||||
case >= 34 and <= 65:
|
||||
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 Write64(IExecutionContext state, int gdbRegId, StringStream ss)
|
||||
{
|
||||
switch (gdbRegId)
|
||||
{
|
||||
case >= 0 and <= 31:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(16);
|
||||
state.SetX(gdbRegId, value);
|
||||
return true;
|
||||
}
|
||||
case 32:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(16);
|
||||
state.DebugPc = value;
|
||||
return true;
|
||||
}
|
||||
case 33:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(8);
|
||||
state.Pstate = (uint)value;
|
||||
return true;
|
||||
}
|
||||
case >= 34 and <= 65:
|
||||
{
|
||||
ulong value0 = ss.ReadLengthAsLEHex(16);
|
||||
ulong value1 = ss.ReadLengthAsLEHex(16);
|
||||
state.SetV(gdbRegId - 34, new V128(value0, value1));
|
||||
return true;
|
||||
}
|
||||
case 66:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(8);
|
||||
state.Fpsr = (uint)value;
|
||||
return true;
|
||||
}
|
||||
case 67:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(8);
|
||||
state.Fpcr = (uint)value;
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Read32(IExecutionContext state, int gdbRegId)
|
||||
{
|
||||
switch (gdbRegId)
|
||||
{
|
||||
case >= 0 and <= 14:
|
||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.GetX(gdbRegId)));
|
||||
case 15:
|
||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.DebugPc));
|
||||
case 16:
|
||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.Pstate));
|
||||
case >= 17 and <= 32:
|
||||
return Helpers.ToHex(state.GetV(gdbRegId - 17).ToArray());
|
||||
case >= 33 and <= 64:
|
||||
int reg = (gdbRegId - 33);
|
||||
int n = reg / 2;
|
||||
int shift = reg % 2;
|
||||
ulong value = state.GetV(n).Extract<ulong>(shift);
|
||||
return Helpers.ToHex(BitConverter.GetBytes(value));
|
||||
case 65:
|
||||
uint fpscr = (uint)state.Fpsr | (uint)state.Fpcr;
|
||||
return Helpers.ToHex(BitConverter.GetBytes(fpscr));
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Write32(IExecutionContext state, int gdbRegId, StringStream ss)
|
||||
{
|
||||
switch (gdbRegId)
|
||||
{
|
||||
case >= 0 and <= 14:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(8);
|
||||
state.SetX(gdbRegId, value);
|
||||
return true;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(8);
|
||||
state.DebugPc = value;
|
||||
return true;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(8);
|
||||
state.Pstate = (uint)value;
|
||||
return true;
|
||||
}
|
||||
case >= 17 and <= 32:
|
||||
{
|
||||
ulong value0 = ss.ReadLengthAsLEHex(16);
|
||||
ulong value1 = ss.ReadLengthAsLEHex(16);
|
||||
state.SetV(gdbRegId - 17, new V128(value0, value1));
|
||||
return true;
|
||||
}
|
||||
case >= 33 and <= 64:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(16);
|
||||
int regId = (gdbRegId - 33);
|
||||
int regNum = regId / 2;
|
||||
int shift = regId % 2;
|
||||
V128 reg = state.GetV(regNum);
|
||||
reg.Insert(shift, value);
|
||||
return true;
|
||||
}
|
||||
case 65:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLEHex(8);
|
||||
state.Fpsr = (uint)value & FpcrMask;
|
||||
state.Fpcr = (uint)value & ~FpcrMask;
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
src/Ryujinx.HLE/Debugger/Helpers.cs
Normal file
50
src/Ryujinx.HLE/Debugger/Helpers.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Gommon;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public static class Helpers
|
||||
{
|
||||
public static byte CalculateChecksum(string cmd)
|
||||
{
|
||||
byte checksum = 0;
|
||||
foreach (char x in cmd)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
checksum += (byte)x;
|
||||
}
|
||||
}
|
||||
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public static string FromHex(string hexString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hexString))
|
||||
return string.Empty;
|
||||
|
||||
byte[] bytes = Convert.FromHexString(hexString);
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
|
||||
public static string ToHex(byte[] bytes) => string.Join("", bytes.Select(x => $"{x:x2}"));
|
||||
|
||||
public static string ToHex(string str) => ToHex(Encoding.ASCII.GetBytes(str));
|
||||
|
||||
public static string ToBinaryFormat(string str) => ToBinaryFormat(Encoding.ASCII.GetBytes(str));
|
||||
public static string ToBinaryFormat(byte[] bytes) =>
|
||||
bytes.Select(x =>
|
||||
x switch
|
||||
{
|
||||
(byte)'#' => "}\x03",
|
||||
(byte)'$' => "}\x04",
|
||||
(byte)'*' => "}\x0a",
|
||||
(byte)'}' => "}\x5d",
|
||||
_ => Convert.ToChar(x).ToString()
|
||||
}
|
||||
).JoinToString(string.Empty);
|
||||
}
|
||||
}
|
@ -17,8 +17,8 @@ namespace Ryujinx.HLE.Debugger
|
||||
|
||||
private static string GetEmbeddedResourceContent(string resourceName)
|
||||
{
|
||||
Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.HLE.Debugger.GdbXml." + resourceName);
|
||||
StreamReader reader = new StreamReader(stream);
|
||||
Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.HLE.Debugger.Gdb.Xml." + resourceName);
|
||||
StreamReader reader = new(stream);
|
||||
string result = reader.ReadToEnd();
|
||||
reader.Dispose();
|
||||
stream.Dispose();
|
||||
|
@ -3,7 +3,7 @@ using System.Globalization;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
class StringStream
|
||||
internal class StringStream
|
||||
{
|
||||
private readonly string Data;
|
||||
private int Position;
|
||||
|
@ -29,6 +29,7 @@ namespace Ryujinx.HLE.HOS.Kernel
|
||||
capabilities,
|
||||
context.ResourceLimit,
|
||||
MemoryRegion.Service,
|
||||
context.Device.Configuration.MemoryConfiguration,
|
||||
null,
|
||||
customThreadStart);
|
||||
|
||||
|
@ -102,6 +102,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
ProcessCreationFlags flags,
|
||||
bool fromBack,
|
||||
MemoryRegion memRegion,
|
||||
MemoryConfiguration memConfig,
|
||||
ulong address,
|
||||
ulong size,
|
||||
KMemoryBlockSlabManager slabManager)
|
||||
@ -117,6 +118,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
addrSpaceBase,
|
||||
addrSpaceSize,
|
||||
memRegion,
|
||||
memConfig,
|
||||
address,
|
||||
size,
|
||||
slabManager);
|
||||
@ -159,6 +161,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
ulong addrSpaceStart,
|
||||
ulong addrSpaceEnd,
|
||||
MemoryRegion memRegion,
|
||||
MemoryConfiguration memConfig,
|
||||
ulong address,
|
||||
ulong size,
|
||||
KMemoryBlockSlabManager slabManager)
|
||||
@ -193,7 +196,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
case ProcessCreationFlags.AddressSpace64BitDeprecated:
|
||||
aliasRegion.Size = 0x180000000;
|
||||
heapRegion.Size = 0x180000000;
|
||||
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
|
||||
stackRegion.Size = 0;
|
||||
tlsIoRegion.Size = 0;
|
||||
CodeRegionStart = 0x8000000;
|
||||
@ -223,7 +226,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
int addressSpaceWidth = (int)ulong.Log2(_reservedAddressSpaceSize);
|
||||
|
||||
aliasRegion.Size = 1UL << (addressSpaceWidth - 3);
|
||||
heapRegion.Size = 0x180000000;
|
||||
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
|
||||
stackRegion.Size = 1UL << (addressSpaceWidth - 8);
|
||||
tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3);
|
||||
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
||||
@ -237,7 +240,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
else
|
||||
{
|
||||
aliasRegion.Size = 0x1000000000;
|
||||
heapRegion.Size = 0x180000000;
|
||||
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
|
||||
stackRegion.Size = 0x80000000;
|
||||
tlsIoRegion.Size = 0x1000000000;
|
||||
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
||||
|
@ -124,6 +124,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
KPageList pageList,
|
||||
KResourceLimit resourceLimit,
|
||||
MemoryRegion memRegion,
|
||||
MemoryConfiguration memConfig,
|
||||
IProcessContextFactory contextFactory,
|
||||
ThreadStart customThreadStart = null)
|
||||
{
|
||||
@ -153,6 +154,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
creationInfo.Flags,
|
||||
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
||||
memRegion,
|
||||
memConfig,
|
||||
codeAddress,
|
||||
codeSize,
|
||||
slabManager);
|
||||
@ -189,6 +191,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
ReadOnlySpan<uint> capabilities,
|
||||
KResourceLimit resourceLimit,
|
||||
MemoryRegion memRegion,
|
||||
MemoryConfiguration memConfig,
|
||||
IProcessContextFactory contextFactory,
|
||||
ThreadStart customThreadStart = null)
|
||||
{
|
||||
@ -252,6 +255,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
creationInfo.Flags,
|
||||
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
||||
memRegion,
|
||||
memConfig,
|
||||
codeAddress,
|
||||
codeSize,
|
||||
slabManager);
|
||||
@ -1088,21 +1092,25 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
MemoryManager = new KPageTable(KernelContext, CpuMemory, Context.AddressSpaceSize);
|
||||
}
|
||||
|
||||
private bool InvalidAccessHandler(ulong va)
|
||||
private static bool InvalidAccessHandler(ulong va)
|
||||
{
|
||||
KernelStatic.GetCurrentThread()?.PrintGuestStackTrace();
|
||||
KernelStatic.GetCurrentThread()?.PrintGuestRegisterPrintout();
|
||||
|
||||
Logger.Error?.Print(LogClass.Cpu, $"Invalid memory access at virtual address 0x{va:X16}.");
|
||||
|
||||
Logger.Flush();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UndefinedInstructionHandler(IExecutionContext context, ulong address, int opCode)
|
||||
private static void UndefinedInstructionHandler(IExecutionContext context, ulong address, int opCode)
|
||||
{
|
||||
KernelStatic.GetCurrentThread().PrintGuestStackTrace();
|
||||
KernelStatic.GetCurrentThread()?.PrintGuestRegisterPrintout();
|
||||
|
||||
Logger.Flush();
|
||||
|
||||
throw new UndefinedInstructionException(address, opCode);
|
||||
}
|
||||
|
||||
@ -1200,16 +1208,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
private class DebuggerInterface : IDebuggableProcess
|
||||
{
|
||||
private Barrier StepBarrier;
|
||||
private readonly Barrier _stepBarrier;
|
||||
private readonly KProcess _parent;
|
||||
private readonly KernelContext _kernelContext;
|
||||
private KThread steppingThread;
|
||||
private KThread _steppingThread;
|
||||
|
||||
public DebuggerInterface(KProcess p)
|
||||
{
|
||||
_parent = p;
|
||||
_kernelContext = p.KernelContext;
|
||||
StepBarrier = new(2);
|
||||
_stepBarrier = new(2);
|
||||
}
|
||||
|
||||
public void DebugStop()
|
||||
@ -1277,7 +1285,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
|
||||
_kernelContext.CriticalSection.Enter();
|
||||
steppingThread = target;
|
||||
_steppingThread = target;
|
||||
bool waiting = target.MutexOwner != null || target.WaitingSync || target.WaitingInArbitration;
|
||||
target.Context.RequestDebugStep();
|
||||
if (waiting)
|
||||
@ -1297,14 +1305,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
_kernelContext.CriticalSection.Leave();
|
||||
|
||||
bool stepTimedOut = false;
|
||||
if (!StepBarrier.SignalAndWait(TimeSpan.FromMilliseconds(2000)))
|
||||
if (!_stepBarrier.SignalAndWait(TimeSpan.FromMilliseconds(2000)))
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Kernel, $"Failed to step thread {target.ThreadUid} in time.");
|
||||
stepTimedOut = true;
|
||||
}
|
||||
|
||||
_kernelContext.CriticalSection.Enter();
|
||||
steppingThread = null;
|
||||
_steppingThread = null;
|
||||
if (waiting)
|
||||
{
|
||||
lock (_parent._threadingLock)
|
||||
@ -1326,7 +1334,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return false;
|
||||
}
|
||||
|
||||
StepBarrier.SignalAndWait();
|
||||
_stepBarrier.SignalAndWait();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1361,12 +1369,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
public void DebugInterruptHandler(IExecutionContext ctx)
|
||||
{
|
||||
_kernelContext.CriticalSection.Enter();
|
||||
bool stepping = steppingThread != null;
|
||||
bool stepping = _steppingThread != null;
|
||||
_kernelContext.CriticalSection.Leave();
|
||||
if (stepping)
|
||||
{
|
||||
StepBarrier.SignalAndWait();
|
||||
StepBarrier.SignalAndWait();
|
||||
_stepBarrier.SignalAndWait();
|
||||
_stepBarrier.SignalAndWait();
|
||||
}
|
||||
_parent.InterruptHandler(ctx);
|
||||
}
|
||||
|
@ -137,6 +137,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
capabilities,
|
||||
resourceLimit,
|
||||
memRegion,
|
||||
_context.Device.Configuration.MemoryConfiguration,
|
||||
contextFactory,
|
||||
customThreadStart);
|
||||
|
||||
@ -888,7 +889,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
[Svc(1)]
|
||||
public Result SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size)
|
||||
{
|
||||
if ((size & 0xfffffffe001fffff) != 0)
|
||||
if ((size & 0xfffffffd001fffff) != 0)
|
||||
{
|
||||
address = 0;
|
||||
|
||||
@ -1893,6 +1894,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Error?.Print(LogClass.KernelSvc, "The guest program broke execution!");
|
||||
Logger.Flush();
|
||||
|
||||
// TODO: Debug events.
|
||||
currentThread.Owner.TerminateCurrentProcess();
|
||||
|
||||
|
@ -293,6 +293,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||
KThread selectedThread = _state.SelectedThread;
|
||||
|
||||
if (!currentThread.IsThreadNamed && currentThread.GetThreadName() != "")
|
||||
{
|
||||
currentThread.HostThread.Name = $"<{currentThread.GetThreadName()}>";
|
||||
currentThread.IsThreadNamed = true;
|
||||
}
|
||||
|
||||
// If the thread is already scheduled and running on the core, we have nothing to do.
|
||||
if (currentThread == selectedThread)
|
||||
{
|
||||
|
@ -53,6 +53,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
public ulong AffinityMask { get; set; }
|
||||
|
||||
public ulong ThreadUid { get; private set; }
|
||||
|
||||
public bool IsThreadNamed { get; set; }
|
||||
|
||||
private long _totalTimeRunning;
|
||||
|
||||
|
@ -189,7 +189,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
codeAddress,
|
||||
codeSize);
|
||||
|
||||
result = process.InitializeKip(creationInfo, kip.Capabilities, pageList, context.ResourceLimit, memoryRegion, processContextFactory);
|
||||
result = process.InitializeKip(creationInfo, kip.Capabilities, pageList, context.ResourceLimit, memoryRegion, context.Device.Configuration.MemoryConfiguration, processContextFactory);
|
||||
if (result != Result.Success)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Loader, $"Process initialization returned error \"{result}\".");
|
||||
@ -389,6 +389,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
MemoryMarshal.Cast<byte, uint>(npdm.KernelCapabilityData),
|
||||
resourceLimit,
|
||||
memoryRegion,
|
||||
context.Device.Configuration.MemoryConfiguration,
|
||||
processContextFactory);
|
||||
|
||||
if (result != Result.Success)
|
||||
|
@ -33,12 +33,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Debugger\GdbXml\aarch64-core.xml" />
|
||||
<None Remove="Debugger\GdbXml\aarch64-fpu.xml" />
|
||||
<None Remove="Debugger\GdbXml\arm-core.xml" />
|
||||
<None Remove="Debugger\GdbXml\arm-neon.xml" />
|
||||
<None Remove="Debugger\GdbXml\target64.xml" />
|
||||
<None Remove="Debugger\GdbXml\target32.xml" />
|
||||
<None Remove="Debugger\Gdb\Xml\aarch64-core.xml" />
|
||||
<None Remove="Debugger\Gdb\Xml\aarch64-fpu.xml" />
|
||||
<None Remove="Debugger\Gdb\Xml\arm-core.xml" />
|
||||
<None Remove="Debugger\Gdb\Xml\arm-neon.xml" />
|
||||
<None Remove="Debugger\Gdb\Xml\target64.xml" />
|
||||
<None Remove="Debugger\Gdb\Xml\target32.xml" />
|
||||
<None Remove="Homebrew.npdm" />
|
||||
<None Remove="HOS\Applets\SoftwareKeyboard\Resources\Logo_Ryujinx.png" />
|
||||
<None Remove="HOS\Applets\SoftwareKeyboard\Resources\Icon_BtnA.png" />
|
||||
@ -48,12 +48,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Debugger\GdbXml\aarch64-core.xml" />
|
||||
<EmbeddedResource Include="Debugger\GdbXml\aarch64-fpu.xml" />
|
||||
<EmbeddedResource Include="Debugger\GdbXml\arm-core.xml" />
|
||||
<EmbeddedResource Include="Debugger\GdbXml\arm-neon.xml" />
|
||||
<EmbeddedResource Include="Debugger\GdbXml\target64.xml" />
|
||||
<EmbeddedResource Include="Debugger\GdbXml\target32.xml" />
|
||||
<EmbeddedResource Include="Debugger\Gdb\Xml\aarch64-core.xml" />
|
||||
<EmbeddedResource Include="Debugger\Gdb\Xml\aarch64-fpu.xml" />
|
||||
<EmbeddedResource Include="Debugger\Gdb\Xml\arm-core.xml" />
|
||||
<EmbeddedResource Include="Debugger\Gdb\Xml\arm-neon.xml" />
|
||||
<EmbeddedResource Include="Debugger\Gdb\Xml\target32.xml" />
|
||||
<EmbeddedResource Include="Debugger\Gdb\Xml\target64.xml" />
|
||||
<EmbeddedResource Include="Homebrew.npdm" />
|
||||
<EmbeddedResource Include="HOS\Applets\SoftwareKeyboard\Resources\Logo_Ryujinx.png" />
|
||||
<EmbeddedResource Include="HOS\Applets\SoftwareKeyboard\Resources\Icon_BtnA.png" />
|
||||
|
@ -351,7 +351,10 @@ namespace Ryujinx.Ava
|
||||
|
||||
|
||||
if (isTerminating)
|
||||
{
|
||||
Logger.Flush();
|
||||
Exit();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void Exit()
|
||||
|
@ -11,11 +11,13 @@ using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Systems.PlayReport;
|
||||
using Ryujinx.Ava.Utilities;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Ryujinx.Ava.Systems.AppLibrary
|
||||
@ -84,6 +86,32 @@ namespace Ryujinx.Ava.Systems.AppLibrary
|
||||
|
||||
public LocaleKeys? PlayabilityStatus => Compatibility.Convert(x => x.Status).OrElse(null);
|
||||
|
||||
public bool HasPtcCacheFiles
|
||||
{
|
||||
get
|
||||
{
|
||||
DirectoryInfo mainDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, IdString, "cache", "cpu", "0"));
|
||||
DirectoryInfo backupDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, IdString, "cache", "cpu", "1"));
|
||||
|
||||
return (mainDir.Exists && (mainDir.EnumerateFiles("*.cache").Any() || mainDir.EnumerateFiles("*.info").Any())) ||
|
||||
(backupDir.Exists && (backupDir.EnumerateFiles("*.cache").Any() || backupDir.EnumerateFiles("*.info").Any()));
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasShaderCacheFiles
|
||||
{
|
||||
get
|
||||
{
|
||||
DirectoryInfo shaderCacheDir = new(System.IO.Path.Combine(AppDataManager.GamesDirPath, IdString, "cache", "shader"));
|
||||
|
||||
if (!shaderCacheDir.Exists) return false;
|
||||
|
||||
return shaderCacheDir.EnumerateDirectories("*").Any() ||
|
||||
shaderCacheDir.GetFiles("*.toc").Length != 0 ||
|
||||
shaderCacheDir.GetFiles("*.data").Length != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public string LocalizedStatusTooltip =>
|
||||
Compatibility.Convert(x =>
|
||||
#pragma warning disable CS8509 // It is exhaustive for all possible values this can contain.
|
||||
|
@ -120,13 +120,13 @@
|
||||
CommandParameter="{Binding}"
|
||||
Header="{ext:Locale GameListContextMenuCacheManagementNukePptc}"
|
||||
Icon="{ext:Icon fa-solid fa-trash-can}"
|
||||
IsEnabled="{Binding HasPtcCacheFiles}" />
|
||||
IsEnabled="{Binding SelectedApplication.HasPtcCacheFiles, FallbackValue=False}" />
|
||||
<MenuItem
|
||||
Command="{Binding PurgeShaderCache}"
|
||||
CommandParameter="{Binding}"
|
||||
Header="{ext:Locale GameListContextMenuCacheManagementPurgeShaderCache}"
|
||||
Icon="{ext:Icon fa-solid fa-trash-can}"
|
||||
IsEnabled="{Binding HasShaderCacheFiles}" />
|
||||
IsEnabled="{Binding SelectedApplication.HasShaderCacheFiles, FallbackValue=False}" />
|
||||
<Separator/>
|
||||
<MenuItem
|
||||
Command="{Binding OpenPtcDirectory}"
|
||||
|
@ -354,8 +354,8 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
primary,
|
||||
secondaryText,
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterShowChangelogMessage],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||
(int)Symbol.Help,
|
||||
UserResult.Yes);
|
||||
|
||||
|
@ -6,6 +6,7 @@ using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Common.Models.Amiibo;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.Windows;
|
||||
using Ryujinx.Ava.Utilities;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
@ -250,6 +251,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Unable to read data from '{_amiiboJsonPath}': {exception}");
|
||||
localIsValid = false;
|
||||
}
|
||||
|
||||
if (!localIsValid || await NeedsUpdate(amiiboJson.LastUpdated))
|
||||
@ -280,11 +282,59 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
return amiiboJson;
|
||||
}
|
||||
|
||||
private async Task<AmiiboJson?> ReadLocalJsonFileAsync()
|
||||
{
|
||||
bool isValid = false;
|
||||
AmiiboJson amiiboJson = new();
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(_amiiboJsonPath))
|
||||
{
|
||||
isValid = TryGetAmiiboJson(await File.ReadAllTextAsync(_amiiboJsonPath), out amiiboJson);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Unable to read data from '{_amiiboJsonPath}': {exception}");
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (!isValid)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Couldn't get valid amiibo data: {exception}");
|
||||
|
||||
// Neither local file is not valid JSON, close window.
|
||||
await ShowInfoDialog();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
return amiiboJson;
|
||||
}
|
||||
|
||||
private async Task LoadContentAsync()
|
||||
{
|
||||
AmiiboJson amiiboJson = await GetMostRecentAmiiboListOrDefaultJson();
|
||||
AmiiboJson? amiiboJson;
|
||||
|
||||
_amiiboList = amiiboJson.Amiibo.OrderBy(amiibo => amiibo.AmiiboSeries).ToList();
|
||||
if (CommandLineState.OnlyLocalAmiibo)
|
||||
amiiboJson = await ReadLocalJsonFileAsync();
|
||||
else
|
||||
amiiboJson = await GetMostRecentAmiiboListOrDefaultJson();
|
||||
|
||||
if (!amiiboJson.HasValue)
|
||||
return;
|
||||
|
||||
_amiiboList = amiiboJson.Value.Amiibo.OrderBy(amiibo => amiibo.AmiiboSeries).ToList();
|
||||
|
||||
ParseAmiiboData();
|
||||
}
|
||||
|
@ -2121,8 +2121,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
});
|
||||
|
||||
public static AsyncRelayCommand<MainWindowViewModel> NukePtcCache { get; } =
|
||||
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null &&
|
||||
vm.HasPtcCacheFiles(),
|
||||
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication?.HasPtcCacheFiles ?? false,
|
||||
async viewModel =>
|
||||
{
|
||||
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(
|
||||
@ -2171,22 +2170,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
});
|
||||
|
||||
private bool HasPtcCacheFiles()
|
||||
{
|
||||
if (this.SelectedApplication == null) return false;
|
||||
|
||||
DirectoryInfo mainDir = new DirectoryInfo(Path.Combine(AppDataManager.GamesDirPath,
|
||||
this.SelectedApplication.IdString, "cache", "cpu", "0"));
|
||||
DirectoryInfo backupDir = new DirectoryInfo(Path.Combine(AppDataManager.GamesDirPath,
|
||||
this.SelectedApplication.IdString, "cache", "cpu", "1"));
|
||||
|
||||
return (mainDir.Exists && (mainDir.EnumerateFiles("*.cache").Any() || mainDir.EnumerateFiles("*.info").Any())) ||
|
||||
(backupDir.Exists && (backupDir.EnumerateFiles("*.cache").Any() || backupDir.EnumerateFiles("*.info").Any()));
|
||||
}
|
||||
|
||||
public static AsyncRelayCommand<MainWindowViewModel> PurgeShaderCache { get; } =
|
||||
Commands.CreateConditional<MainWindowViewModel>(
|
||||
vm => vm?.SelectedApplication != null && vm.HasShaderCacheFiles(),
|
||||
vm => vm?.SelectedApplication?.HasShaderCacheFiles ?? false,
|
||||
async viewModel =>
|
||||
{
|
||||
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(
|
||||
@ -2243,20 +2229,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
});
|
||||
|
||||
private bool HasShaderCacheFiles()
|
||||
{
|
||||
if (this.SelectedApplication == null) return false;
|
||||
|
||||
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath,
|
||||
this.SelectedApplication.IdString, "cache", "shader"));
|
||||
|
||||
if (!shaderCacheDir.Exists) return false;
|
||||
|
||||
return shaderCacheDir.EnumerateDirectories("*").Any() ||
|
||||
shaderCacheDir.GetFiles("*.toc").Any() ||
|
||||
shaderCacheDir.GetFiles("*.data").Any();
|
||||
}
|
||||
|
||||
public static RelayCommand<MainWindowViewModel> OpenPtcDirectory { get; } =
|
||||
Commands.CreateConditional<MainWindowViewModel>(vm => vm?.SelectedApplication != null,
|
||||
viewModel =>
|
||||
|
@ -35,7 +35,7 @@
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
<Setter Property="CornerRadius" Value="15" />
|
||||
<Setter Property="CornerRadius" Value="4" />
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem:selected /template/ Rectangle#SelectionIndicator">
|
||||
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).GridItemSelectorSize}" />
|
||||
@ -53,7 +53,7 @@
|
||||
Classes.normal="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridMedium}"
|
||||
Classes.small="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridSmall}"
|
||||
ClipToBounds="True"
|
||||
CornerRadius="12.5">
|
||||
CornerRadius="4">
|
||||
<Grid RowDefinitions="Auto,Auto">
|
||||
<Image
|
||||
Grid.Row="0"
|
||||
|
@ -34,9 +34,6 @@
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="CornerRadius" Value="15" />
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem:selected /template/ Rectangle#SelectionIndicator">
|
||||
<Setter Property="MinHeight" Value="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).ListItemSelectorSize}" />
|
||||
</Style>
|
||||
@ -49,11 +46,9 @@
|
||||
Padding="10"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ClipToBounds="True">
|
||||
ClipToBounds="True"
|
||||
CornerRadius="5">
|
||||
<Grid ColumnDefinitions="Auto,10,*,150,100">
|
||||
<Border
|
||||
ClipToBounds="True"
|
||||
CornerRadius="7">
|
||||
<Image
|
||||
Grid.RowSpan="3"
|
||||
Grid.Column="0"
|
||||
@ -63,7 +58,6 @@
|
||||
Classes.normal="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridMedium}"
|
||||
Classes.small="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridSmall}"
|
||||
Source="{Binding Icon, Converter={x:Static helpers:BitmapArrayValueConverter.Instance}}" />
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Grid.Column="2"
|
||||
|
@ -25,6 +25,7 @@ namespace Ryujinx.Ava.Utilities
|
||||
public static string LaunchApplicationId { get; private set; }
|
||||
public static bool StartFullscreenArg { get; private set; }
|
||||
public static bool HideAvailableUpdates { get; private set; }
|
||||
public static bool OnlyLocalAmiibo { get; private set; }
|
||||
|
||||
public static void ParseArguments(string[] args)
|
||||
{
|
||||
@ -130,6 +131,10 @@ namespace Ryujinx.Ava.Utilities
|
||||
|
||||
OverridePPTC = args[++i];
|
||||
break;
|
||||
case "-la":
|
||||
case "--local-only-amiibo":
|
||||
OnlyLocalAmiibo = true;
|
||||
break;
|
||||
case "-m":
|
||||
case "--memory-manager-mode":
|
||||
if (i + 1 >= args.Length)
|
||||
|
Loading…
Reference in New Issue
Block a user