From fc9fcf299f17a2d0a9f62d6b578e0e89eecca3e7 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 af2d1057359ad..45b1cc4de18bb 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 b37cd6b5e046e..909444ea2f1ff 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 7ba23bd560f92..36400c7e9fdbb 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 01eea79443a4a35dee9e229469bee2cd55b4930c 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 b07e58569160c..a5f61c9ac9099 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -305,6 +305,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 b130ed4ae54dc9a9a2153d22acdcf74155f4164b 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 8ecdf8edc589f..795eb53d72429 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 a5f61c9ac9099..b07e58569160c 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -305,7 +305,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 45b1cc4de18bb..2fc584c5ad949 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 909444ea2f1ff..b37cd6b5e046e 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