Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Mono.Android/Android.Runtime/JNIEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ static void ManualJavaObjectDispose (Java.Lang.Object obj)
GC.SuppressFinalize (obj);
}

static Action<Exception> mono_unhandled_exception = null!;
#if NETCOREAPP
internal static Action<Exception> mono_unhandled_exception = monodroid_debugger_unhandled_exception;
#else // NETCOREAPP
internal static Action<Exception> mono_unhandled_exception = null!;
#endif // NETCOREAPP

#if !NETCOREAPP
static Action<AppDomain, UnhandledExceptionEventArgs> AppDomain_DoUnhandledException = null!;
#endif // ndef NETCOREAPP
Expand Down Expand Up @@ -695,6 +700,11 @@ public static string GetClassNameFromInstance (IntPtr jobject)
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern unsafe IntPtr monodroid_typemap_managed_to_java (Type type, byte* mvid);

#if NETCOREAPP
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern unsafe void monodroid_debugger_unhandled_exception (Exception e);
#endif // NETCOREAPP

internal static void LogTypemapTrace (StackTrace st)
{
string? trace = st.ToString ()?.Trim ();
Expand Down
3 changes: 3 additions & 0 deletions src/Mono.Android/Android.Runtime/JNINativeWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ static void get_runtime_types ()
if (mono_unhandled_exception_method == null)
AndroidEnvironment.FailFast ("Cannot find System.Diagnostics.Debugger.Mono_UnhandledException");
#endif
#if NETCOREAPP
mono_unhandled_exception_method = JNIEnv.mono_unhandled_exception.Method;
#endif // NETCOREAPP
exception_handler_method = typeof (AndroidEnvironment).GetMethod (
"UnhandledException", BindingFlags.NonPublic | BindingFlags.Static);
if (exception_handler_method == null)
Expand Down
3 changes: 3 additions & 0 deletions src/monodroid/jni/monodroid-glue-internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ namespace xamarin::android::internal
static MonoReflectionType* typemap_java_to_managed (MonoString *java_type_name);

static const char* typemap_managed_to_java (MonoReflectionType *type, const uint8_t *mvid);
#if defined (NET6)
static void monodroid_debugger_unhandled_exception (MonoException *ex);
#endif

#if defined (DEBUG)
void set_debug_env_vars (void);
Expand Down
9 changes: 9 additions & 0 deletions src/monodroid/jni/monodroid-glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,14 @@ MonodroidRuntime::lookup_bridge_info (MonoDomain *domain, MonoImage *image, cons
}
#endif // ndef NET6

#if defined (NET6)
void
MonodroidRuntime::monodroid_debugger_unhandled_exception (MonoException *ex)
{
mono_debugger_agent_unhandled_exception (ex);
}
#endif

void
MonodroidRuntime::init_android_runtime (
#if !defined (NET6)
Expand All @@ -1011,6 +1019,7 @@ MonodroidRuntime::init_android_runtime (
mono_add_internal_call ("Java.Interop.TypeManager::monodroid_typemap_java_to_managed", reinterpret_cast<const void*>(typemap_java_to_managed));
mono_add_internal_call ("Android.Runtime.JNIEnv::monodroid_typemap_managed_to_java", reinterpret_cast<const void*>(typemap_managed_to_java));
#if defined (NET6)
mono_add_internal_call ("Android.Runtime.JNIEnv::monodroid_debugger_unhandled_exception", reinterpret_cast<const void*> (monodroid_debugger_unhandled_exception));
mono_add_internal_call ("Android.Runtime.JNIEnv::monodroid_unhandled_exception", reinterpret_cast<const void*>(monodroid_unhandled_exception));
#endif // def NET6

Expand Down