static void throw_exception (MonoObject *exc, gpointer sp, gpointer ip, gboolean rethrow) { MonoContext ctx; static void (*restore_context) (MonoContext *); gpointer *window; if (!restore_context) restore_context = mono_arch_get_restore_context (); window = MONO_SPARC_WINDOW_ADDR (sp); ctx.sp = (gpointer*)sp; ctx.ip = ip; ctx.fp = (gpointer*)(MONO_SPARC_WINDOW_ADDR (sp) [sparc_i6 - 16]); if (mono_object_isinst (exc, mono_defaults.exception_class)) { MonoException *mono_ex = (MonoException*)exc; if (!rethrow) mono_ex->stack_trace = NULL; } mono_handle_exception (&ctx, exc, ip, FALSE); restore_context (&ctx); g_assert_not_reached (); }
/* * mono_x86_throw_exception: * * C function called from the throw trampolines. */ static void mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc, mgreg_t eip, gboolean rethrow) { static void (*restore_context) (MonoContext *); MonoContext ctx; if (!restore_context) restore_context = mono_arch_get_restore_context (); ctx.esp = regs [X86_ESP]; ctx.eip = eip; ctx.ebp = regs [X86_EBP]; ctx.edi = regs [X86_EDI]; ctx.esi = regs [X86_ESI]; ctx.ebx = regs [X86_EBX]; ctx.edx = regs [X86_EDX]; ctx.ecx = regs [X86_ECX]; ctx.eax = regs [X86_EAX]; #ifdef __APPLE__ /* The OSX ABI specifies 16 byte alignment at call sites */ g_assert ((ctx.esp % MONO_ARCH_FRAME_ALIGNMENT) == 0); #endif if (mono_object_isinst (exc, mono_defaults.exception_class)) { MonoException *mono_ex = (MonoException*)exc; if (!rethrow) mono_ex->stack_trace = NULL; } if (mono_debug_using_mono_debugger ()) { guint8 buf [16], *code; mono_breakpoint_clean_code (NULL, (gpointer)eip, 8, buf, sizeof (buf)); code = buf + 8; if (buf [3] == 0xe8) { MonoContext ctx_cp = ctx; ctx_cp.eip = eip - 5; if (mono_debugger_handle_exception (&ctx_cp, exc)) { restore_context (&ctx_cp); g_assert_not_reached (); } } } /* adjust eip so that it point into the call instruction */ ctx.eip -= 1; mono_handle_exception (&ctx, exc, (gpointer)eip, FALSE); restore_context (&ctx); g_assert_not_reached (); }
static void altstack_handle_and_restore (void *sigctx, gpointer obj, gboolean stack_ovf) { void (*restore_context) (MonoContext *); MonoContext mctx; restore_context = mono_arch_get_restore_context (); mono_arch_sigctx_to_monoctx (sigctx, &mctx); if (mono_debugger_handle_exception (&mctx, (MonoObject *)obj)) { if (stack_ovf) prepare_for_guard_pages (&mctx); restore_context (&mctx); } mono_handle_exception (&mctx, obj, (gpointer)mctx.eip, FALSE); if (stack_ovf) prepare_for_guard_pages (&mctx); restore_context (&mctx); }