mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-15 17:10:51 -10:00
[debugger] Debugger doesn't break on unhandled exceptions (#15234)
* When the catch found is in a MONO_WRAPPER_RUNTIME_INVOKE the exception should be treated as an UNHANDLED by the debugger. * Adding unit test. * trying to fix side effect. * I've tested the MonoTests.DebuggerTests.UnhandledException_2 test on VsWin using .net Framework and I think the test is wrong because the first break is in throw and the next break will be on breakpoint. In our implementation we were ignoring the unhandled exception and stopping only on breakpoint.
This commit is contained in:
1 parent
b4e43abbcc
commit
405d521149
3 files changed
+32
No files matched your search
@@ -414,6 +414,10 @@ public class Tests : TestsBase, ITest2
|
||||
unhandled_exception ();
|
||||
return 0;
|
||||
}
|
||||
if (args.Length >0 && args [0] == "unhandled-exception-wrapper") {
|
||||
unhandled_exception_wrapper ();
|
||||
return 0;
|
||||
}
|
||||
if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
|
||||
unhandled_exception_endinvoke ();
|
||||
return 0;
|
||||
@@ -1483,6 +1487,10 @@ public class Tests : TestsBase, ITest2
|
||||
Thread.Sleep (10000);
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void unhandled_exception_wrapper () {
|
||||
throw new ArgumentException("test");
|
||||
}
|
||||
[MethodImplAttribute (MethodImplOptions.NoInlining)]
|
||||
public static void unhandled_exception_endinvoke_2 () {
|
||||
}
|
||||
|
||||
@@ -4218,6 +4218,8 @@ public class DebuggerTests
|
||||
var e = run_until ("unhandled_exception_endinvoke");
|
||||
vm.Resume ();
|
||||
|
||||
var e1 = GetNextEvent (); //this should be the exception
|
||||
vm.Resume ();
|
||||
var e2 = GetNextEvent ();
|
||||
Assert.IsFalse (e2 is ExceptionEvent);
|
||||
|
||||
@@ -4246,6 +4248,24 @@ public class DebuggerTests
|
||||
vm = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnhandledException3 () {
|
||||
vm.Exit (0);
|
||||
|
||||
Start (dtest_app_path, "unhandled-exception-wrapper");
|
||||
|
||||
var req = vm.CreateExceptionRequest (null, false, true);
|
||||
req.Enable ();
|
||||
|
||||
var e = run_until ("unhandled_exception_wrapper");
|
||||
vm.Resume ();
|
||||
|
||||
var e2 = GetNextEvent ();
|
||||
Assert.IsTrue (e2 is ExceptionEvent);
|
||||
vm.Exit (0);
|
||||
vm = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GCWhileSuspended () {
|
||||
// Check that objects are kept alive during suspensions
|
||||
|
||||
@@ -2668,6 +2668,10 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
|
||||
|
||||
if (unhandled)
|
||||
mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, NULL, NULL);
|
||||
else if (jinfo_get_method (ji)->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE) {
|
||||
mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, NULL, NULL);
|
||||
mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, &ctx_cp, &catch_frame);
|
||||
}
|
||||
else if (res != MONO_FIRST_PASS_CALLBACK_TO_NATIVE)
|
||||
mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, &ctx_cp, &catch_frame);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user