Debugger: Add replies for qGDBServerVersion, qHostInfo, qProcessInfo, qfThreadInfo, qsThreadInfo

This commit is contained in:
merry 2022-02-09 16:16:45 +00:00 committed by svc64
parent deccf05e60
commit 1bb8f6381c
1 changed files with 39 additions and 6 deletions

View File

@ -1,4 +1,5 @@
using Ryujinx.Common.Logging; using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.Memory; using Ryujinx.Memory;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -133,7 +134,7 @@ namespace Ryujinx.HLE.Debugger
case '!': case '!':
if (!ss.IsEmpty()) if (!ss.IsEmpty())
{ {
goto default; goto unknownCommand;
} }
// Enable extended mode // Enable extended mode
Reply("OK"); Reply("OK");
@ -141,7 +142,7 @@ namespace Ryujinx.HLE.Debugger
case '?': case '?':
if (!ss.IsEmpty()) if (!ss.IsEmpty())
{ {
goto default; goto unknownCommand;
} }
CommandQuery(); CommandQuery();
break; break;
@ -151,14 +152,14 @@ namespace Ryujinx.HLE.Debugger
case 'D': case 'D':
if (!ss.IsEmpty()) if (!ss.IsEmpty())
{ {
goto default; goto unknownCommand;
} }
CommandDetach(); CommandDetach();
break; break;
case 'g': case 'g':
if (!ss.IsEmpty()) if (!ss.IsEmpty())
{ {
goto default; goto unknownCommand;
} }
CommandReadGeneralRegisters(); CommandReadGeneralRegisters();
break; break;
@ -203,6 +204,28 @@ namespace Ryujinx.HLE.Debugger
CommandWriteGeneralRegister((int)gdbRegId, value); CommandWriteGeneralRegister((int)gdbRegId, value);
break; break;
} }
case 'q':
switch (ss.ReadUntil(':'))
{
case "GDBServerVersion":
Reply($"name:Ryujinx;version:{ReleaseInformations.GetVersion()};");
break;
case "HostInfo":
Reply($"triple:{ToHex("aarch64-none-elf")};endian:little;ptrsize:8;hostname:{ToHex("Ryujinx")};");
break;
case "ProcessInfo":
Reply("pid:1;cputype:100000c;cpusubtype:0;ostype:unknown;vendor:none;endian:little;ptrsize:8;");
break;
case "fThreadInfo":
Reply($"m {string.Join(",", GetThreadIds().Select(x => $"{x:x}"))}");
break;
case "sThreadInfo":
Reply("l");
break;
default:
goto unknownCommand;
}
break;
default: default:
Logger.Notice.Print(LogClass.GdbStub, $"Unknown command: {cmd}"); Logger.Notice.Print(LogClass.GdbStub, $"Unknown command: {cmd}");
Reply(""); Reply("");
@ -280,7 +303,7 @@ namespace Ryujinx.HLE.Debugger
{ {
var data = new byte[len]; var data = new byte[len];
GetMemory().Read(addr, data); GetMemory().Read(addr, data);
Reply(string.Join("", data.Select(x => $"{x:x2}"))); Reply(ToHex(data));
} }
void CommandWriteMemory(ulong addr, ulong len, StringStream ss) void CommandWriteMemory(ulong addr, ulong len, StringStream ss)
@ -384,6 +407,16 @@ namespace Ryujinx.HLE.Debugger
return checksum; return checksum;
} }
private string ToHex(byte[] bytes)
{
return string.Join("", bytes.Select(x => $"{x:x2}"));
}
private string ToHex(string str)
{
return ToHex(Encoding.ASCII.GetBytes(str));
}
public void Dispose() public void Dispose()
{ {
Dispose(true); Dispose(true);