From f6524f9337f56068c39f34785e36941ee58a1f24 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Thu, 11 Apr 2024 10:42:39 +0300 Subject: [PATCH] Simplified involved rendering --- .../CrashReportHtml.cs | 74 ++------------ ...GuiRenderer.4.InvolvedModulesAndPlugins.cs | 98 +++---------------- 2 files changed, 23 insertions(+), 149 deletions(-) diff --git a/src/BUTR.CrashReport.Renderer.Html/CrashReportHtml.cs b/src/BUTR.CrashReport.Renderer.Html/CrashReportHtml.cs index 8498ecc..f644b7b 100644 --- a/src/BUTR.CrashReport.Renderer.Html/CrashReportHtml.cs +++ b/src/BUTR.CrashReport.Renderer.Html/CrashReportHtml.cs @@ -220,89 +220,31 @@ private static string GetEnhancedStacktraceHtml(CrashReportModel crashReport) private static void AddInvolvedModules(CrashReportModel crashReport, StringBuilder sbMain) { - foreach (var grouping in crashReport.EnhancedStacktrace.GroupBy(x => x.ExecutingMethod.ModuleId ?? "UNKNOWN")) + foreach (var involvedModule in crashReport.InvolvedLoaderPlugins.GroupBy(x => x.ModuleOrLoaderPluginId)) { - var moduleId = grouping.Key; - if (moduleId == "UNKNOWN") continue; - sbMain.Append("
  • ") - .Append("Module Id: ").Append("").Append(moduleId).Append("").Append("
    "); + .Append("Module Id: ").Append("").Append(involvedModule.Key).Append("").Append("
    "); - foreach (var stacktrace in grouping) + foreach (var involved in involvedModule) { - sbMain.Append("Method: ").Append(stacktrace.ExecutingMethod.MethodFullDescription.EscapeGenerics()).Append("
    ") - .Append("Frame: ").Append(stacktrace.FrameDescription.EscapeGenerics()).Append("
    "); - - if (stacktrace.PatchMethods.Count > 0) - { - sbMain.Append("Patches:").Append("
    ") - .Append(""); - } - - sbMain.Append("
    "); - + sbMain.Append("Frame: ").Append(involved.EnhancedStacktraceFrameName.EscapeGenerics()).Append("
    "); sbMain.Append("
  • "); } - sbMain.Append(""); } } private static void AddInvolvedPlugins(CrashReportModel crashReport, StringBuilder sbMain) { - foreach (var grouping in crashReport.EnhancedStacktrace.GroupBy(x => x.ExecutingMethod.LoaderPluginId ?? "UNKNOWN")) + foreach (var involvedPlugin in crashReport.InvolvedLoaderPlugins.GroupBy(x => x.ModuleOrLoaderPluginId)) { - var pluginId = grouping.Key; - if (pluginId == "UNKNOWN") continue; - sbMain.Append("
  • ") - .Append("Plugin Id: ").Append("").Append(pluginId).Append("").Append("
    "); + .Append("Plugin Id: ").Append("").Append(involvedPlugin.Key).Append("").Append("
    "); - foreach (var stacktrace in grouping) + foreach (var involved in involvedPlugin) { - sbMain.Append("Method: ").Append(stacktrace.ExecutingMethod.MethodFullDescription.EscapeGenerics()).Append("
    ") - .Append("Frame: ").Append(stacktrace.FrameDescription.EscapeGenerics()).Append("
    "); - - if (stacktrace.PatchMethods.Count > 0) - { - sbMain.Append("Patches:").Append("
    ") - .Append(""); - } - - sbMain.Append("
    "); - + sbMain.Append("Frame: ").Append(involved.EnhancedStacktraceFrameName.EscapeGenerics()).Append("
    "); sbMain.Append("
  • "); } - sbMain.Append(""); } } diff --git a/src/BUTR.CrashReport.Renderer.ImGui/Renderer/ImGuiRenderer.4.InvolvedModulesAndPlugins.cs b/src/BUTR.CrashReport.Renderer.ImGui/Renderer/ImGuiRenderer.4.InvolvedModulesAndPlugins.cs index 66af009..99b86fe 100644 --- a/src/BUTR.CrashReport.Renderer.ImGui/Renderer/ImGuiRenderer.4.InvolvedModulesAndPlugins.cs +++ b/src/BUTR.CrashReport.Renderer.ImGui/Renderer/ImGuiRenderer.4.InvolvedModulesAndPlugins.cs @@ -1,7 +1,4 @@ using BUTR.CrashReport.Models; -using BUTR.CrashReport.Renderer.ImGui.Extensions; - -using HonkPerf.NET.RefLinq; using ImGuiNET; @@ -12,19 +9,19 @@ namespace BUTR.CrashReport.Renderer.ImGui.Renderer; partial class ImGuiRenderer { - private KeyValuePair[] _enhancedStacktraceGroupedByModuleId = []; - private KeyValuePair[] _enhancedStacktraceGroupedByLoaderPluginIdId = []; + private KeyValuePair[] _enhancedStacktraceGroupedByModuleId = []; + private KeyValuePair[] _enhancedStacktraceGroupedByLoaderPluginIdId = []; private void InitializeInvolved() { - _enhancedStacktraceGroupedByModuleId = _crashReport.EnhancedStacktrace - .GroupBy(x => x.ExecutingMethod.ModuleId ?? "UNKNOWN") - .Select(x => new KeyValuePair(x.Key, x.ToArray())) + _enhancedStacktraceGroupedByModuleId = _crashReport.InvolvedModules + .GroupBy(x => x.ModuleOrLoaderPluginId) + .Select(x => new KeyValuePair(x.Key, x.ToArray())) .ToArray(); - _enhancedStacktraceGroupedByLoaderPluginIdId = _crashReport.EnhancedStacktrace - .GroupBy(x => x.ExecutingMethod.LoaderPluginId ?? "UNKNOWN") - .Select(x => new KeyValuePair(x.Key, x.ToArray())) + _enhancedStacktraceGroupedByLoaderPluginIdId = _crashReport.InvolvedLoaderPlugins + .GroupBy(x => x.ModuleOrLoaderPluginId) + .Select(x => new KeyValuePair(x.Key, x.ToArray())) .ToArray(); } @@ -32,51 +29,19 @@ private void RenderInvolvedModules() { foreach (var kv in _enhancedStacktraceGroupedByModuleId) { - if (kv.Key == "UNKNOWN") continue; - if (_imgui.TreeNode(kv.Key, ImGuiTreeNodeFlags.DefaultOpen)) { _imgui.RenderId("Module Id:\0"u8, kv.Key); for (var j = 0; j < kv.Value.Length; j++) { - var stacktrace = kv.Value[j]; + var involved = kv.Value[j]; _imgui.Bullet(); _imgui.Indent(); - _imgui.TextSameLine("Method: \0"u8); - _imgui.Text(stacktrace.ExecutingMethod.MethodFullDescription); _imgui.TextSameLine("Frame: \0"u8); - _imgui.Text(stacktrace.FrameDescription); - - if (stacktrace.PatchMethods.Count > 0) - { - _imgui.Text("Patches:\0"u8); - - _imgui.Bullet(); - _imgui.Indent(); - for (var k = 0; k < stacktrace.PatchMethods.Count; k++) - { - var method = stacktrace.PatchMethods[k]; - var harmonyPatchType = method.AdditionalMetadata.ToRefLinq().Where(x => x.Key == "HarmonyPatchType").FirstOrDefault(); - - // Ignore blank transpilers used to force the jitter to skip inlining - if (method.MethodName == "BlankTranspiler") continue; - var moduleId2 = method.ModuleId ?? "UNKNOWN"; - - if (moduleId2 == "UNKNOWN") _imgui.RenderId("Module Id:\0"u8, kv.Key); - _imgui.TextSameLine("Method: \0"u8); - _imgui.Text(method.MethodFullDescription); - if (harmonyPatchType is not null) - { - _imgui.TextSameLine("Harmony Patch Type: }\0"u8); - _imgui.Text(harmonyPatchType.Value); - } - } - - _imgui.Unindent(); - } - + _imgui.Text(involved.EnhancedStacktraceFrameName); + _imgui.Unindent(); } @@ -89,52 +54,19 @@ private void RenderInvolvedPlugins() { foreach (var kv in _enhancedStacktraceGroupedByLoaderPluginIdId) { - if (kv.Key == "UNKNOWN") continue; - if (_imgui.TreeNode(kv.Key, ImGuiTreeNodeFlags.DefaultOpen)) { _imgui.RenderId("Plugin Id:\0"u8, kv.Key); for (var j = 0; j < kv.Value.Length; j++) { - var stacktrace = kv.Value[j]; + var involved = kv.Value[j]; _imgui.Bullet(); _imgui.Indent(); - _imgui.TextSameLine("Method: \0"u8); - _imgui.Text(stacktrace.ExecutingMethod.MethodFullDescription); _imgui.TextSameLine("Frame: \0"u8); - _imgui.Text(stacktrace.FrameDescription); - - if (stacktrace.PatchMethods.Count > 0) - { - _imgui.Text("Patches:\0"u8); - - _imgui.Bullet(); - _imgui.Indent(); - - for (var k = 0; k < stacktrace.PatchMethods.Count; k++) - { - var method = stacktrace.PatchMethods[k]; - var harmonyPatchType = method.AdditionalMetadata.ToRefLinq().Where(x => x.Key == "HarmonyPatchType").FirstOrDefault(); - - // Ignore blank transpilers used to force the jitter to skip inlining - if (method.MethodName == "BlankTranspiler") continue; - var pluginId2 = method.LoaderPluginId ?? "UNKNOWN"; - - if (pluginId2 == "UNKNOWN") _imgui.RenderId("Plugin Id:\0"u8, kv.Key); - _imgui.TextSameLine("Method: \0"u8); - _imgui.Text(method.MethodFullDescription); - if (harmonyPatchType is not null) - { - _imgui.TextSameLine("Harmony Patch Type: \0"u8); - _imgui.Text(harmonyPatchType.Value); - } - } - - _imgui.Unindent(); - } - + _imgui.Text(involved.EnhancedStacktraceFrameName); + _imgui.Unindent(); } @@ -145,7 +77,7 @@ private void RenderInvolvedPlugins() private void RenderInvolvedModulesAndPlugins() { - _imgui.Text("Based on Stacktrace (From highest probability to lowest):\0"u8); + _imgui.Text("From highest probability to lowest:\0"u8); _imgui.Indent(); RenderInvolvedModules(); RenderInvolvedPlugins();