Skip to content

Commit

Permalink
Include patches into Involved
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Apr 11, 2024
1 parent f8b577d commit 75e60fe
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/BUTR.CrashReport.Renderer.Html/CrashReportHtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private static void AddInvolvedPlugins(CrashReportModel crashReport, StringBuild
private static string GetInvolvedHtml(CrashReportModel crashReport)
{
var sb = new StringBuilder();
sb.Append("Based on Stacktrace:")
sb.Append("Based on Stacktrace (From highest probability to lowest):")
.Append("<ul>");
AddInvolvedModules(crashReport, sb);
AddInvolvedPlugins(crashReport, sb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

using ImGuiNET;

using System;
using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -146,7 +145,7 @@ private void RenderInvolvedPlugins()

private void RenderInvolvedModulesAndPlugins()
{
_imgui.Text("Based on Stacktrace:\0"u8);
_imgui.Text("Based on Stacktrace (From highest probability to lowest):\0"u8);
_imgui.Indent();
RenderInvolvedModules();
RenderInvolvedPlugins();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

using ImGuiNET;

using System;

namespace BUTR.CrashReport.Renderer.ImGui.Renderer;

partial class ImGuiRenderer
Expand Down
64 changes: 46 additions & 18 deletions src/BUTR.CrashReport/Utils/CrashReportModelUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,31 @@ static bool IsProtected(AssemblyModel? assembly) => assembly is not null &&
public static List<InvolvedModuleOrPluginModel> GetInvolvedModules(CrashReportInfo crashReport)
{
var involvedModels = new List<InvolvedModuleOrPluginModel>();
foreach (var stacktrace in crashReport.FilteredStacktrace.GroupBy(m => m.ModuleInfo))
foreach (var stacktraces in crashReport.FilteredStacktrace.GroupBy(m => m.ModuleInfo))
{
var module = stacktrace.Key;
if (module is null) continue;

involvedModels.Add(new()
if (stacktraces.Key is { } module)
{
ModuleOrLoaderPluginId = module.Id,
EnhancedStacktraceFrameName = stacktrace.Last().StackFrameDescription,
AdditionalMetadata = Array.Empty<MetadataModel>(),
});
involvedModels.Add(new()
{
ModuleOrLoaderPluginId = module.Id,
EnhancedStacktraceFrameName = stacktraces.Last().StackFrameDescription,
AdditionalMetadata = Array.Empty<MetadataModel>(),
});
}
}
foreach (var stacktrace in crashReport.FilteredStacktrace)
{
foreach (var patch in stacktrace.PatchMethods)
{
if (patch.ModuleInfo is null) continue;

involvedModels.Add(new()
{
ModuleOrLoaderPluginId = patch.ModuleInfo.Id,
EnhancedStacktraceFrameName = stacktrace.StackFrameDescription,
AdditionalMetadata = Array.Empty<MetadataModel>(),
});
}
}
return involvedModels;
}
Expand All @@ -165,17 +179,31 @@ public static List<InvolvedModuleOrPluginModel> GetInvolvedModules(CrashReportIn
public static List<InvolvedModuleOrPluginModel> GetInvolvedPlugins(CrashReportInfo crashReport)
{
var involvedPluginModels = new List<InvolvedModuleOrPluginModel>();
foreach (var stacktrace in crashReport.FilteredStacktrace.GroupBy(m => m.LoaderPluginInfo))
foreach (var stacktraces in crashReport.FilteredStacktrace.GroupBy(m => m.LoaderPluginInfo))
{
var loaderPlugin = stacktrace.Key;
if (loaderPlugin is null) continue;

involvedPluginModels.Add(new()
if (stacktraces.Key is { } loaderPlugin)
{
ModuleOrLoaderPluginId = loaderPlugin.Id,
EnhancedStacktraceFrameName = stacktrace.Last().StackFrameDescription,
AdditionalMetadata = Array.Empty<MetadataModel>(),
});
involvedPluginModels.Add(new()
{
ModuleOrLoaderPluginId = loaderPlugin.Id,
EnhancedStacktraceFrameName = stacktraces.Last().StackFrameDescription,
AdditionalMetadata = Array.Empty<MetadataModel>(),
});
}
}
foreach (var stacktrace in crashReport.FilteredStacktrace)
{
foreach (var patch in stacktrace.PatchMethods)
{
if (patch.LoaderPluginInfo is null) continue;

involvedPluginModels.Add(new()
{
ModuleOrLoaderPluginId = patch.LoaderPluginInfo.Id,
EnhancedStacktraceFrameName = stacktrace.StackFrameDescription,
AdditionalMetadata = Array.Empty<MetadataModel>(),
});
}
}
return involvedPluginModels;
}
Expand Down

0 comments on commit 75e60fe

Please sign in to comment.