boot: implement --unhandled-exception=stalldebug (#1690)

Using this option will stall the crashed thread until the debugger
attaches, so that the newly attached debugger can be handed over the
exception, enabling breaking at correct stack location.

`--no-exception-handlers` injector option controlled whether Dalamud
Crash Handler would intercept exceptions before. Those are now either
`default` or `none` option for `--unhandled-exception`.
This commit is contained in:
srkizer 2024-04-21 13:20:11 +09:00 committed by GitHub
parent b85914c54c
commit 8ff4662f1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 101 additions and 13 deletions

View file

@ -99,7 +99,6 @@ namespace Dalamud.Injector
args.Remove("--no-plugin");
args.Remove("--no-3rd-plugin");
args.Remove("--crash-handler-console");
args.Remove("--no-exception-handlers");
var mainCommand = args[1].ToLowerInvariant();
if (mainCommand.Length > 0 && mainCommand.Length <= 6 && "inject"[..mainCommand.Length] == mainCommand)
@ -277,6 +276,7 @@ namespace Dalamud.Injector
var logName = startInfo.LogName;
var logPath = startInfo.LogPath;
var languageStr = startInfo.Language.ToString().ToLowerInvariant();
var unhandledExceptionStr = startInfo.UnhandledException.ToString().ToLowerInvariant();
var troubleshootingData = "{\"empty\": true, \"description\": \"No troubleshooting data supplied.\"}";
for (var i = 2; i < args.Count; i++)
@ -317,6 +317,10 @@ namespace Dalamud.Injector
{
logPath = args[i][key.Length..];
}
else if (args[i].StartsWith(key = "--unhandled-exception="))
{
unhandledExceptionStr = args[i][key.Length..];
}
else
{
continue;
@ -416,7 +420,14 @@ namespace Dalamud.Injector
startInfo.NoLoadThirdPartyPlugins = args.Contains("--no-3rd-plugin");
// startInfo.BootUnhookDlls = new List<string>() { "kernel32.dll", "ntdll.dll", "user32.dll" };
startInfo.CrashHandlerShow = args.Contains("--crash-handler-console");
startInfo.NoExceptionHandlers = args.Contains("--no-exception-handlers");
startInfo.UnhandledException =
Enum.TryParse<UnhandledExceptionHandlingMode>(
unhandledExceptionStr,
true,
out var parsedUnhandledException)
? parsedUnhandledException
: throw new CommandLineException(
$"\"{unhandledExceptionStr}\" is not a valid unhandled exception handling mode.");
return startInfo;
}
@ -458,7 +469,7 @@ namespace Dalamud.Injector
Console.WriteLine("Verbose logging:\t[-v]");
Console.WriteLine("Show Console:\t[--console] [--crash-handler-console]");
Console.WriteLine("Enable ETW:\t[--etw]");
Console.WriteLine("Enable VEH:\t[--veh], [--veh-full], [--no-exception-handlers]");
Console.WriteLine("Enable VEH:\t[--veh], [--veh-full], [--unhandled-exception=default|stalldebug|none]");
Console.WriteLine("Show messagebox:\t[--msgbox1], [--msgbox2], [--msgbox3]");
Console.WriteLine("No plugins:\t[--no-plugin] [--no-3rd-plugin]");
Console.WriteLine("Logging:\t[--logname=<logfile suffix>] [--logpath=<log base directory>]");