From 374cc2f0525ee125acce88fe7ed22aa7ab75861b Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 19 Jul 2021 17:48:39 -0300 Subject: [PATCH 1/3] Avoid regressing behavior that we had on mono/mono. Xamarin Android team will be able to use mono_debugger_agent_unhandled_exception, and do not use Debugger.Mono_UnhandledException(as it does not exist on net6). --- src/mono/mono/mini/debugger-agent-external.c | 7 +++++++ src/mono/mono/mini/debugger-agent-external.h | 3 +++ src/mono/mono/mini/mini-runtime.c | 5 ----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mono/mono/mini/debugger-agent-external.c b/src/mono/mono/mini/debugger-agent-external.c index af2d1057359ad0..45b1cc4de18bb6 100644 --- a/src/mono/mono/mini/debugger-agent-external.c +++ b/src/mono/mono/mini/debugger-agent-external.c @@ -5,6 +5,7 @@ #include #include #include "debugger-agent-external.h" +#include #ifndef DISABLE_SDB @@ -59,4 +60,10 @@ mono_debugger_agent_get_sdb_options (void) { return sdb_options; } + +void +mono_debugger_agent_unhandled_exception (MonoObject *e) +{ + MONO_EXTERNAL_ONLY_VOID (mono_component_debugger ()->unhandled_exception ((MonoException*)e)); +} #endif /* DISABLE_SDB */ diff --git a/src/mono/mono/mini/debugger-agent-external.h b/src/mono/mono/mini/debugger-agent-external.h index b37cd6b5e046ef..909444ea2f1ff3 100644 --- a/src/mono/mono/mini/debugger-agent-external.h +++ b/src/mono/mono/mini/debugger-agent-external.h @@ -26,4 +26,7 @@ mono_debugger_agent_get_transports (int *ntrans); MONO_COMPONENT_API char * mono_debugger_agent_get_sdb_options (void); +MONO_API MONO_RT_EXTERNAL_ONLY void +mono_debugger_agent_unhandled_exception (MonoObject *e); + #endif diff --git a/src/mono/mono/mini/mini-runtime.c b/src/mono/mono/mini/mini-runtime.c index 7ba23bd560f920..36400c7e9fdbbe 100644 --- a/src/mono/mono/mini/mini-runtime.c +++ b/src/mono/mono/mini/mini-runtime.c @@ -4607,11 +4607,6 @@ register_icalls (void) mono_add_internal_call_internal ("Mono.Runtime::mono_runtime_install_handlers", mono_runtime_install_handlers); -#if defined(HOST_ANDROID) || defined(TARGET_ANDROID) - mono_add_internal_call_internal ("System.Diagnostics.Debugger::Mono_UnhandledException_internal", - mono_component_debugger ()->unhandled_exception); -#endif - /* * It's important that we pass `TRUE` as the last argument here, as * it causes the JIT to omit a wrapper for these icalls. If the JIT From 318ca26905ac2c79863ceffb6105b9ea05ca4c77 Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 20 Jul 2021 15:31:09 -0300 Subject: [PATCH 2/3] Exporting headers --- src/mono/mono/mini/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 841bff5f566cf9..997d0a98b154f6 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -303,6 +303,7 @@ endif() set(mini_public_headers_base jit.h + debugger-agent-external.h mono-private-unstable.h) addprefix(mini_public_headers ../mini "${mini_public_headers_base}") From 7bb5b39bfb974e6bc8ea114378cf6312243906da Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 20 Jul 2021 18:14:19 -0300 Subject: [PATCH 3/3] Fixing implementation. --- src/mono/mono/metadata/debug-helpers.h | 3 +++ src/mono/mono/mini/CMakeLists.txt | 1 - src/mono/mono/mini/debugger-agent-external.c | 6 ++++-- src/mono/mono/mini/debugger-agent-external.h | 3 --- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mono/mono/metadata/debug-helpers.h b/src/mono/mono/metadata/debug-helpers.h index 8ecdf8edc589f6..795eb53d72429f 100644 --- a/src/mono/mono/metadata/debug-helpers.h +++ b/src/mono/mono/metadata/debug-helpers.h @@ -48,6 +48,9 @@ MONO_API char* mono_method_get_reflection_name (MonoMethod *method); MONO_API char* mono_field_full_name (MonoClassField *field); +MONO_API MONO_RT_EXTERNAL_ONLY void +mono_debugger_agent_unhandled_exception (MonoException *e); + MONO_END_DECLS #endif /* __MONO_DEBUG_HELPERS_H__ */ diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 997d0a98b154f6..841bff5f566cf9 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -303,7 +303,6 @@ endif() set(mini_public_headers_base jit.h - debugger-agent-external.h mono-private-unstable.h) addprefix(mini_public_headers ../mini "${mini_public_headers_base}") diff --git a/src/mono/mono/mini/debugger-agent-external.c b/src/mono/mono/mini/debugger-agent-external.c index 45b1cc4de18bb6..2fc584c5ad9497 100644 --- a/src/mono/mono/mini/debugger-agent-external.c +++ b/src/mono/mono/mini/debugger-agent-external.c @@ -62,8 +62,10 @@ mono_debugger_agent_get_sdb_options (void) } void -mono_debugger_agent_unhandled_exception (MonoObject *e) +mono_debugger_agent_unhandled_exception (MonoException *e) { - MONO_EXTERNAL_ONLY_VOID (mono_component_debugger ()->unhandled_exception ((MonoException*)e)); + MONO_ENTER_GC_UNSAFE; + MONO_EXTERNAL_ONLY_VOID (mono_component_debugger ()->unhandled_exception (e)); + MONO_EXIT_GC_UNSAFE; } #endif /* DISABLE_SDB */ diff --git a/src/mono/mono/mini/debugger-agent-external.h b/src/mono/mono/mini/debugger-agent-external.h index 909444ea2f1ff3..b37cd6b5e046ef 100644 --- a/src/mono/mono/mini/debugger-agent-external.h +++ b/src/mono/mono/mini/debugger-agent-external.h @@ -26,7 +26,4 @@ mono_debugger_agent_get_transports (int *ntrans); MONO_COMPONENT_API char * mono_debugger_agent_get_sdb_options (void); -MONO_API MONO_RT_EXTERNAL_ONLY void -mono_debugger_agent_unhandled_exception (MonoObject *e); - #endif