Add support of not nested function name
This commit is contained in:
parent
8b2a602ba7
commit
8d7b095520
1 changed files with 37 additions and 27 deletions
|
@ -128,7 +128,7 @@ namespace Ryujinx.Core.OsHle.Diagnostics
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<string> ReadName(string mangled, List<string> compressionData, out int pos)
|
private static List<string> ReadName(string mangled, List<string> compressionData, out int pos, bool isNested = true)
|
||||||
{
|
{
|
||||||
List<string> res = new List<string>();
|
List<string> res = new List<string>();
|
||||||
string charCountString = null;
|
string charCountString = null;
|
||||||
|
@ -186,6 +186,8 @@ namespace Ryujinx.Core.OsHle.Diagnostics
|
||||||
i = i + charCount - 1;
|
i = i + charCount - 1;
|
||||||
charCount = 0;
|
charCount = 0;
|
||||||
charCountString = null;
|
charCountString = null;
|
||||||
|
if (!isNested)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.Count == 0)
|
if (res.Count == 0)
|
||||||
|
@ -370,23 +372,20 @@ namespace Ryujinx.Core.OsHle.Diagnostics
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Parse(string originalMangled)
|
private static string ParseFunctionName(string mangled)
|
||||||
{
|
{
|
||||||
string mangled = originalMangled;
|
|
||||||
List<string> compressionData = new List<string>();
|
List<string> compressionData = new List<string>();
|
||||||
string res = null;
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
string res;
|
||||||
|
bool isNested = mangled.StartsWith("N");
|
||||||
|
|
||||||
// We asume that we start with a function name
|
// If it's start with "N" it must be a nested function name
|
||||||
// TODO: support special names
|
if (isNested)
|
||||||
if (mangled.StartsWith("_ZN"))
|
mangled = mangled.Substring(1);
|
||||||
{
|
compressionData = ReadName(mangled, compressionData, out pos, isNested);
|
||||||
mangled = mangled.Substring(3);
|
|
||||||
compressionData = ReadName(mangled, compressionData, out pos);
|
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
return originalMangled;
|
return null;
|
||||||
res = compressionData[compressionData.Count - 1];
|
res = compressionData[compressionData.Count - 1];
|
||||||
|
|
||||||
compressionData.Remove(res);
|
compressionData.Remove(res);
|
||||||
mangled = mangled.Substring(pos + 1);
|
mangled = mangled.Substring(pos + 1);
|
||||||
|
|
||||||
|
@ -396,12 +395,23 @@ namespace Ryujinx.Core.OsHle.Diagnostics
|
||||||
List<string> parameters = ReadParameters(mangled, compressionData, out pos);
|
List<string> parameters = ReadParameters(mangled, compressionData, out pos);
|
||||||
// parameters parsing error, we return the original data to avoid information loss.
|
// parameters parsing error, we return the original data to avoid information loss.
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
return originalMangled;
|
return null;
|
||||||
parameters = parameters.Select(outer => outer.Trim()).ToList();
|
parameters = parameters.Select(outer => outer.Trim()).ToList();
|
||||||
res += "(" + String.Join(", ", parameters) + ")";
|
res += "(" + String.Join(", ", parameters) + ")";
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string Parse(string originalMangled)
|
||||||
|
{
|
||||||
|
if (originalMangled.StartsWith("_Z"))
|
||||||
|
{
|
||||||
|
// We assume that we have a name (TOOD: support special names)
|
||||||
|
string res = ParseFunctionName(originalMangled.Substring(2));
|
||||||
|
if (res == null)
|
||||||
|
return originalMangled;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
return originalMangled;
|
return originalMangled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue