From fbba87b41a8bc5ee49b740d9d50d424a4b63d302 Mon Sep 17 00:00:00 2001 From: Thog Date: Sat, 5 May 2018 19:28:18 +0200 Subject: [PATCH] Create Ryujinx.Core.OsHle.Diagnostics.Demangler and move DemangleName --- Ryujinx.Core/OsHle/Diagnostics/Demangler.cs | 57 +++++++++++++++++++++ Ryujinx.Core/OsHle/Process.cs | 54 +------------------ 2 files changed, 59 insertions(+), 52 deletions(-) create mode 100644 Ryujinx.Core/OsHle/Diagnostics/Demangler.cs diff --git a/Ryujinx.Core/OsHle/Diagnostics/Demangler.cs b/Ryujinx.Core/OsHle/Diagnostics/Demangler.cs new file mode 100644 index 0000000000..f83634a7eb --- /dev/null +++ b/Ryujinx.Core/OsHle/Diagnostics/Demangler.cs @@ -0,0 +1,57 @@ +using System; + +namespace Ryujinx.Core.OsHle.Diagnostics { + static class Demangler { + public static string ReadName(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); + } + } +} \ No newline at end of file diff --git a/Ryujinx.Core/OsHle/Process.cs b/Ryujinx.Core/OsHle/Process.cs index f9b90021e4..49ad281c58 100644 --- a/Ryujinx.Core/OsHle/Process.cs +++ b/Ryujinx.Core/OsHle/Process.cs @@ -5,6 +5,7 @@ using ChocolArm64.State; using Ryujinx.Core.Loaders; using Ryujinx.Core.Loaders.Executables; using Ryujinx.Core.Logging; +using Ryujinx.Core.OsHle.Diagnostics; using Ryujinx.Core.OsHle.Exceptions; using Ryujinx.Core.OsHle.Handles; using Ryujinx.Core.OsHle.Kernel; @@ -290,57 +291,6 @@ 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(); @@ -357,7 +307,7 @@ namespace Ryujinx.Core.OsHle } else if (SubName.StartsWith("_ZN")) { - SubName = DemangleName(SubName.Substring(3)); + SubName = Demangler.ReadName(SubName.Substring(3)); } Trace.AppendLine(" " + SubName + " (" + GetNsoNameAndAddress(Position) + ")");