mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 07:36:59 +00:00
Move ProcessInfo and Minidump to HleProcessDebugger (ryubing/ryujinx!187)
See merge request ryubing/ryujinx!187
This commit is contained in:
parent
91da244c02
commit
0c165c3f62
2 changed files with 120 additions and 54 deletions
|
|
@ -62,38 +62,16 @@ namespace Ryujinx.HLE.Debugger
|
||||||
|
|
||||||
public string GetMinidump()
|
public string GetMinidump()
|
||||||
{
|
{
|
||||||
StringBuilder response = new();
|
if (Process is not { } kProcess)
|
||||||
response.AppendLine("=== Begin Minidump ===\n");
|
return "No application process found\n";
|
||||||
response.AppendLine(GetProcessInfo());
|
|
||||||
|
|
||||||
foreach (KThread thread in GetThreads())
|
if (kProcess.Debugger is not { } debugger)
|
||||||
{
|
return $"Error getting minidump: debugger is null\n";
|
||||||
response.AppendLine($"=== Thread {thread.ThreadUid} ===");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string stackTrace = Process.Debugger.GetGuestStackTrace(thread);
|
|
||||||
response.AppendLine(stackTrace);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
response.AppendLine($"[Error getting stack trace: {e.Message}]");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
var response = debugger.GetMinidump();
|
||||||
{
|
|
||||||
string registers = Process.Debugger.GetCpuRegisterPrintout(thread);
|
|
||||||
response.AppendLine(registers);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
response.AppendLine($"[Error getting registers: {e.Message}]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response.AppendLine("=== End Minidump ===");
|
Logger.Info?.Print(LogClass.GdbStub, response);
|
||||||
|
return response;
|
||||||
Logger.Info?.Print(LogClass.GdbStub, response.ToString());
|
|
||||||
return response.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetProcessInfo()
|
public string GetProcessInfo()
|
||||||
|
|
@ -103,32 +81,10 @@ namespace Ryujinx.HLE.Debugger
|
||||||
if (Process is not { } kProcess)
|
if (Process is not { } kProcess)
|
||||||
return "No application process found\n";
|
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}");
|
return debugger.GetProcessInfoPrintout();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,116 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
return sb.ToString();
|
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)
|
private static bool TryGetSubName(Image image, ulong address, out ElfSymbol symbol)
|
||||||
{
|
{
|
||||||
address -= image.BaseAddress;
|
address -= image.BaseAddress;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue