Skip to content

Commit

Permalink
[debugger][exception] Debugger breaks on handled exceptions (mono/mon…
Browse files Browse the repository at this point in the history
…o#17106)

* If there is a perform_wait_callback in the stack there will be another catch generated by the owner thread, so we don't need to throw, we can continue and find the next catch.
Fixes mono/mono#17083

* Reverting unit test changed on commit 405d521.

* Fixing assert when calling mono_jit_info_get_method if it was a trampoline.


Commit migrated from mono/mono@18fac0a
  • Loading branch information
thaystg authored Oct 7, 2019
1 parent 6f69280 commit 779a566
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/mono/mono/mini/mini-exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,7 @@ typedef enum {
* return \c MONO_FIRST_PASS_CALLBACK_TO_NATIVE).
*/
static MonoFirstPassResult
handle_exception_first_pass (MonoContext *ctx, MonoObject *obj, gint32 *out_filter_idx, MonoJitInfo **out_ji, MonoJitInfo **out_prev_ji, MonoObject *non_exception, StackFrameInfo *catch_frame)
handle_exception_first_pass (MonoContext *ctx, MonoObject *obj, gint32 *out_filter_idx, MonoJitInfo **out_ji, MonoJitInfo **out_prev_ji, MonoObject *non_exception, StackFrameInfo *catch_frame, gboolean *has_perform_wait_callback_method)
{
ERROR_DECL (error);
MonoDomain *domain = mono_domain_get ();
Expand Down Expand Up @@ -2471,6 +2471,17 @@ handle_exception_first_pass (MonoContext *ctx, MonoObject *obj, gint32 *out_filt
frame.native_offset = (char*)ei->handler_start - (char*)ji->code_start;
*catch_frame = frame;
result = MONO_FIRST_PASS_HANDLED;
if (method->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE) {
//try to find threadpool_perform_wait_callback_method
unwind_res = unwinder_unwind_frame (&unwinder, domain, jit_tls, NULL, &new_ctx, &new_ctx, NULL, &lmf, NULL, &frame);
while (unwind_res) {
if (frame.ji && !frame.ji->is_trampoline && jinfo_get_method (frame.ji) == mono_defaults.threadpool_perform_wait_callback_method) {
*has_perform_wait_callback_method = TRUE;
break;
}
unwind_res = unwinder_unwind_frame (&unwinder, domain, jit_tls, NULL, &new_ctx, &new_ctx, NULL, &lmf, NULL, &frame);
}
}
return result;
}
mono_error_cleanup (isinst_error);
Expand Down Expand Up @@ -2675,7 +2686,8 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu

StackFrameInfo catch_frame;
MonoFirstPassResult res;
res = handle_exception_first_pass (&ctx_cp, obj, &first_filter_idx, &ji, &prev_ji, non_exception, &catch_frame);
gboolean has_perform_wait_callback_method = FALSE;
res = handle_exception_first_pass (&ctx_cp, obj, &first_filter_idx, &ji, &prev_ji, non_exception, &catch_frame, &has_perform_wait_callback_method);

if (res == MONO_FIRST_PASS_UNHANDLED) {
if (mono_aot_mode == MONO_AOT_MODE_LLVMONLY_INTERP) {
Expand Down Expand Up @@ -2715,7 +2727,8 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
if (unhandled)
mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, NULL, NULL);
else if (!ji || (jinfo_get_method (ji)->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE)) {
mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, NULL, NULL);
if (!has_perform_wait_callback_method)
mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, NULL, NULL);
mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, &ctx_cp, &catch_frame);
}
else if (res != MONO_FIRST_PASS_CALLBACK_TO_NATIVE)
Expand Down

0 comments on commit 779a566

Please sign in to comment.