Skip to content

Commit f8620a1

Browse files
monojenkinsthaystg
andauthored
[debugger] Revert Removing unhandled_exception which was used for android (#40027)
This reverts commit 60643c36f5d4e349276e5dcce0e7fc3dc1d72f74. To investigate error on android tests. Co-authored-by: thaystg <[email protected]>
1 parent 0f87686 commit f8620a1

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

src/mono/mono/mini/debugger-agent-stubs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ stub_debugger_agent_debug_log_is_enabled (void)
7373
return FALSE;
7474
}
7575

76+
static void
77+
stub_debugger_agent_unhandled_exception (MonoException *exc)
78+
{
79+
g_assert_not_reached ();
80+
}
81+
7682
static void
7783
stub_debugger_agent_single_step_from_context (MonoContext *ctx)
7884
{
@@ -104,6 +110,7 @@ mono_debugger_agent_stub_init (void)
104110
cbs.single_step_from_context = stub_debugger_agent_single_step_from_context;
105111
cbs.breakpoint_from_context = stub_debugger_agent_breakpoint_from_context;
106112
cbs.free_domain_info = stub_debugger_agent_free_domain_info;
113+
cbs.unhandled_exception = stub_debugger_agent_unhandled_exception;
107114
cbs.handle_exception = stub_debugger_agent_handle_exception;
108115
cbs.begin_exception_filter = stub_debugger_agent_begin_exception_filter;
109116
cbs.end_exception_filter = stub_debugger_agent_end_exception_filter;

src/mono/mono/mini/debugger-agent.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5286,6 +5286,26 @@ debugger_agent_debug_log_is_enabled (void)
52865286
return agent_config.enabled;
52875287
}
52885288

5289+
static void
5290+
debugger_agent_unhandled_exception (MonoException *exc)
5291+
{
5292+
int suspend_policy;
5293+
GSList *events;
5294+
EventInfo ei;
5295+
5296+
if (!inited)
5297+
return;
5298+
5299+
memset (&ei, 0, sizeof (ei));
5300+
ei.exc = (MonoObject*)exc;
5301+
5302+
mono_loader_lock ();
5303+
events = create_event_list (EVENT_KIND_EXCEPTION, NULL, NULL, &ei, &suspend_policy);
5304+
mono_loader_unlock ();
5305+
5306+
process_event (EVENT_KIND_EXCEPTION, &ei, 0, NULL, events, suspend_policy);
5307+
}
5308+
52895309
static void
52905310
debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx,
52915311
MonoContext *catch_ctx, StackFrameInfo *catch_frame)
@@ -10400,6 +10420,7 @@ mono_debugger_agent_init (void)
1040010420
cbs.single_step_from_context = debugger_agent_single_step_from_context;
1040110421
cbs.breakpoint_from_context = debugger_agent_breakpoint_from_context;
1040210422
cbs.free_domain_info = debugger_agent_free_domain_info;
10423+
cbs.unhandled_exception = debugger_agent_unhandled_exception;
1040310424
cbs.handle_exception = debugger_agent_handle_exception;
1040410425
cbs.begin_exception_filter = debugger_agent_begin_exception_filter;
1040510426
cbs.end_exception_filter = debugger_agent_end_exception_filter;

src/mono/mono/mini/debugger-agent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct _MonoDebuggerCallbacks {
2121
void (*single_step_from_context) (MonoContext *ctx);
2222
void (*breakpoint_from_context) (MonoContext *ctx);
2323
void (*free_domain_info) (MonoDomain *domain);
24+
void (*unhandled_exception) (MonoException *exc);
2425
void (*handle_exception) (MonoException *exc, MonoContext *throw_ctx,
2526
MonoContext *catch_ctx, StackFrameInfo *catch_frame);
2627
void (*begin_exception_filter) (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx);

src/mono/mono/mini/mini-exceptions.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,15 +2366,8 @@ handle_exception_first_pass (MonoContext *ctx, MonoObject *obj, gint32 *out_filt
23662366
if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED && ftnptr_eh_callback) {
23672367
result = MONO_FIRST_PASS_CALLBACK_TO_NATIVE;
23682368
}
2369-
2370-
#if defined(HOST_ANDROID) || defined(TARGET_ANDROID)
2371-
//ignore the try catch in the .. icall_wrapper call
2372-
if (method->wrapper_type == WRAPPER_SUBTYPE_ICALL_WRAPPER) {
2373-
*ctx = new_ctx;
2374-
continue;
2375-
}
2376-
#endif
2377-
2369+
2370+
23782371
for (i = clause_index_start; i < ji->num_clauses; i++) {
23792372
MonoJitExceptionInfo *ei = &ji->clauses [i];
23802373
gboolean filtered = FALSE;

src/mono/mono/mini/mini-runtime.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4646,6 +4646,11 @@ register_icalls (void)
46464646
mono_add_internal_call_internal ("Mono.Runtime::mono_runtime_cleanup_handlers",
46474647
mono_runtime_cleanup_handlers);
46484648

4649+
#if defined(HOST_ANDROID) || defined(TARGET_ANDROID)
4650+
mono_add_internal_call_internal ("System.Diagnostics.Debugger::Mono_UnhandledException_internal",
4651+
mini_get_dbg_callbacks ()->unhandled_exception);
4652+
#endif
4653+
46494654
/*
46504655
* It's important that we pass `TRUE` as the last argument here, as
46514656
* it causes the JIT to omit a wrapper for these icalls. If the JIT

0 commit comments

Comments
 (0)