mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-29 11:59:21 +01:00
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:
parent
b85914c54c
commit
8ff4662f1f
8 changed files with 101 additions and 13 deletions
|
|
@ -149,8 +149,16 @@ public sealed class EntryPoint
|
|||
LogLevelSwitch.MinimumLevel = configuration.LogLevel;
|
||||
|
||||
// Log any unhandled exception.
|
||||
if (!info.NoExceptionHandlers)
|
||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
||||
switch (info.UnhandledException)
|
||||
{
|
||||
case UnhandledExceptionHandlingMode.Default:
|
||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledExceptionDefault;
|
||||
break;
|
||||
case UnhandledExceptionHandlingMode.StallDebug:
|
||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledExceptionStallDebug;
|
||||
break;
|
||||
}
|
||||
|
||||
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
|
||||
|
||||
var unloadFailed = false;
|
||||
|
|
@ -199,8 +207,15 @@ public sealed class EntryPoint
|
|||
finally
|
||||
{
|
||||
TaskScheduler.UnobservedTaskException -= OnUnobservedTaskException;
|
||||
if (!info.NoExceptionHandlers)
|
||||
AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;
|
||||
switch (info.UnhandledException)
|
||||
{
|
||||
case UnhandledExceptionHandlingMode.Default:
|
||||
AppDomain.CurrentDomain.UnhandledException -= OnUnhandledExceptionDefault;
|
||||
break;
|
||||
case UnhandledExceptionHandlingMode.StallDebug:
|
||||
AppDomain.CurrentDomain.UnhandledException -= OnUnhandledExceptionStallDebug;
|
||||
break;
|
||||
}
|
||||
|
||||
Log.Information("Session has ended.");
|
||||
Log.CloseAndFlush();
|
||||
|
|
@ -248,7 +263,7 @@ public sealed class EntryPoint
|
|||
}
|
||||
}
|
||||
|
||||
private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs args)
|
||||
private static void OnUnhandledExceptionDefault(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
switch (args.ExceptionObject)
|
||||
{
|
||||
|
|
@ -308,6 +323,12 @@ public sealed class EntryPoint
|
|||
}
|
||||
}
|
||||
|
||||
private static void OnUnhandledExceptionStallDebug(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
while (!Debugger.IsAttached)
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
private static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs args)
|
||||
{
|
||||
if (!args.Observed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue