Add a C++ demangler for PrintStackTrace
This is a simple C++ demangler (only supporting name demangling) that will probably be enough for any stacktrace cases.
This commit is contained in:
parent
4546d1b9be
commit
e237c7a371
1 changed files with 55 additions and 0 deletions
|
@ -290,6 +290,57 @@ namespace Ryujinx.Core.OsHle
|
|||
Ns.Log.PrintDebug(LogClass.Cpu, $"Executing at 0x{e.Position:x16} {e.SubName} {NsoName}");
|
||||
}
|
||||
|
||||
private string DemangleName(string mangled)
|
||||
{
|
||||
string result = null;
|
||||
string charCountTemp = null;
|
||||
int charCount = 0;
|
||||
foreach(var chr in mangled)
|
||||
{
|
||||
if (charCount == 0)
|
||||
{
|
||||
if (charCountTemp == null)
|
||||
{
|
||||
if (chr == 'r' || chr == 'V' || chr == 'K')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (chr == 'E')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Char.IsDigit(chr))
|
||||
{
|
||||
charCountTemp += chr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!int.TryParse(charCountTemp, out charCount))
|
||||
{
|
||||
return mangled;
|
||||
}
|
||||
result += chr;
|
||||
charCount--;
|
||||
charCountTemp = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result += chr;
|
||||
charCount--;
|
||||
if (charCount == 0)
|
||||
{
|
||||
result += "::";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
return mangled;
|
||||
}
|
||||
return result.Substring(0, result.Length - 2);
|
||||
}
|
||||
public void PrintStackTrace(AThreadState ThreadState)
|
||||
{
|
||||
long[] Positions = ThreadState.GetCallStack();
|
||||
|
@ -304,6 +355,10 @@ namespace Ryujinx.Core.OsHle
|
|||
{
|
||||
SubName = $"Sub{Position:x16}";
|
||||
}
|
||||
else if (SubName.StartsWith("_ZN"))
|
||||
{
|
||||
SubName = DemangleName(SubName.Substring(3));
|
||||
}
|
||||
|
||||
Trace.AppendLine(" " + SubName + " (" + GetNsoNameAndAddress(Position) + ")");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue