Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Source/Common/DeferredStackTracingImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ static long UpdateNewElement(ref AddrInfo info, long ret)
info.addr = ret;
info.stackUsage = stackUsage;

var rawName = Native.MethodNameFromAddr(ret, true); // Use the original instead of replacement for hashing
info.nameHash = rawName != null ? Native.GetMethodAggressiveInlining(ret) ? 0 : StableStringHash(rawName) : 1;
var normalizedMethodNameBetweenOS = Native.MethodNameNormalizedFromAddr(ret, true);

info.nameHash =
normalizedMethodNameBetweenOS == null ? 1 :
Native.GetMethodAggressiveInlining(ret) ? 0 :
StableStringHash(normalizedMethodNameBetweenOS);

hashtableEntries++;
if (hashtableEntries > hashtableSize * LoadFactor)
Expand Down
18 changes: 18 additions & 0 deletions Source/Common/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ public static unsafe void InitLmfPtr(NativeOS os)
return string.IsNullOrEmpty(name) ? null : name;
}

public static string? MethodNameNormalizedFromAddr(long addr, bool harmonyOriginals)
{
var name = MethodNameFromAddr(addr, harmonyOriginals);

if (name == null) return null;
if (name.Length == 0) return name;

int ilOffsetIndex = name.IndexOf(" [0x", StringComparison.Ordinal);
if (ilOffsetIndex >= 0)
name = name.Substring(0, ilOffsetIndex);

int mvidIndex = name.IndexOf(" in <", StringComparison.Ordinal);
if (mvidIndex >= 0)
name = name.Substring(0, mvidIndex);

return name.TrimEnd();
}

private static ConstructorInfo runtimeMethodHandleCtor = AccessTools.Constructor(typeof(RuntimeMethodHandle), new[]{typeof(IntPtr)});

public static bool GetMethodAggressiveInlining(long addr)
Expand Down
Loading