Skip to content

Commit

Permalink
[runtime] Call mono_debugger_agent_unhandled_exception when an except…
Browse files Browse the repository at this point in the history
…ion is marshalled.

This means the debugger will be notified of all marshalled exceptions, and
consider them unhandled (and break the debugged app into the debugger).

There's no corresponding change for CoreCLR, because we have no configuration
where we can attach a debugger to a CoreCLR-based app (VSCode doesn't support
macOS, and NativeAOT doesn't support debugging).

Partial fix for #15037.
Fixes dotnet/maui#7176.
Ref: dotnet/android#6106
  • Loading branch information
rolfbjarne committed Dec 9, 2024
1 parent f29834a commit b1545b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions runtime/exports.t4
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,12 @@
XamarinRuntime = RuntimeMode.MonoVM,
},

new Export ("void", "mono_debugger_agent_unhandled_exception",
"MonoException *", "e"
) {
XamarinRuntime = RuntimeMode.MonoVM,
},

#endregion

#region mini/mono-private-unstable.
Expand Down
5 changes: 5 additions & 0 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,11 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
if (exception == NULL)
return;

#if !defined (CORECLR_RUNTIME)
if (mono_is_debugger_attached ())
mono_debugger_agent_unhandled_exception ((MonoException *) exception);
#endif

MarshalManagedExceptionMode mode;
GCHandle exception_gchandle = INVALID_GCHANDLE;

Expand Down

0 comments on commit b1545b6

Please sign in to comment.