X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fexceptions-x86.c;h=aa10aaad593921b4ef331e96cd14143bbde88914;hb=bc1d754ec15285422b73d40d86cc85ddbd37ce16;hp=669f18330234eac828c89402bac5c8405efadfaa;hpb=457a8453f7a0b58d2eae114e3476e62765f9502a;p=mono.git diff --git a/mono/mini/exceptions-x86.c b/mono/mini/exceptions-x86.c index 669f1833023..aa10aaad593 100644 --- a/mono/mini/exceptions-x86.c +++ b/mono/mini/exceptions-x86.c @@ -32,7 +32,6 @@ #include "mini.h" #include "mini-x86.h" #include "tasklets.h" -#include "debug-mini.h" static gpointer signal_exception_trampoline; @@ -473,12 +472,8 @@ 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_get_restore_context (); - ctx.esp = regs [X86_ESP]; ctx.eip = eip; ctx.ebp = regs [X86_EBP]; @@ -500,29 +495,12 @@ mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc, 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); - restore_context (&ctx); + mono_restore_context (&ctx); g_assert_not_reached (); } @@ -823,10 +801,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, frame->type = FRAME_TYPE_MANAGED; - if (ji->from_aot) - unwind_info = mono_aot_get_unwind_info (ji, &unwind_info_len); - else - unwind_info = mono_get_cached_unwind_info (ji->used_regs, &unwind_info_len); + unwind_info = mono_jinfo_get_unwind_info (ji, &unwind_info_len); regs [X86_EAX] = new_ctx->eax; regs [X86_EBX] = new_ctx->ebx; @@ -859,20 +834,40 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, /* Adjust IP */ new_ctx->eip --; - if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) { - /* remove any unused lmf */ - *lmf = (gpointer)(((gsize)(*lmf)->previous_lmf) & ~3); + if (*lmf && ((*lmf) != jit_tls->first_lmf)) { + gboolean is_tramp = ((guint32)((*lmf)->previous_lmf) & 1); + gpointer lmf_esp; + + if (is_tramp) + /* lmf->esp is only set in trampoline frames */ + lmf_esp = (gpointer)(*lmf)->esp; + else + /* In non-trampoline frames, ebp is the frame pointer */ + lmf_esp = (gpointer)(*lmf)->ebp; + if (MONO_CONTEXT_GET_SP (ctx) >= lmf_esp) + /* remove any unused lmf */ + *lmf = (gpointer)(((gsize)(*lmf)->previous_lmf) & ~3); } /* Pop arguments off the stack */ - /* - * FIXME: LLVM doesn't push these, we can't use ji->from_llvm as it describes - * the callee. - */ -#ifndef ENABLE_LLVM - if (ji->has_arch_eh_info) - new_ctx->esp += mono_jit_info_get_arch_eh_info (ji)->stack_size; + if (ji->has_arch_eh_info) { + int stack_size; + + stack_size = mono_jit_info_get_arch_eh_info (ji)->stack_size; + + if (stack_size) { +#ifdef ENABLE_LLVM + MonoJitInfo *caller_ji; + + caller_ji = mini_jit_info_table_find (domain, (char*)new_ctx->eip, NULL); + /* LLVM doesn't push the arguments */ + if (caller_ji && !caller_ji->from_llvm) + new_ctx->esp += stack_size; +#else + new_ctx->esp += stack_size; #endif + } + } return TRUE; } else if (*lmf) { @@ -989,19 +984,12 @@ handle_signal_exception (gpointer obj) { MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id); MonoContext ctx; - static void (*restore_context) (MonoContext *); - - if (!restore_context) - restore_context = mono_get_restore_context (); memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext)); - if (mono_debugger_handle_exception (&ctx, (MonoObject *)obj)) - return; - mono_handle_exception (&ctx, obj); - restore_context (&ctx); + mono_restore_context (&ctx); } /* @@ -1109,9 +1097,6 @@ mono_arch_handle_exception (void *sigctx, gpointer obj) mono_arch_sigctx_to_monoctx (sigctx, &mctx); - if (mono_debugger_handle_exception (&mctx, (MonoObject *)obj)) - return TRUE; - mono_handle_exception (&mctx, obj); mono_arch_monoctx_to_sigctx (&mctx, sigctx); @@ -1149,22 +1134,14 @@ prepare_for_guard_pages (MonoContext *mctx) static void altstack_handle_and_restore (MonoContext *ctx, gpointer obj, gboolean stack_ovf) { - void (*restore_context) (MonoContext *); MonoContext mctx; - restore_context = mono_get_restore_context (); mctx = *ctx; - if (mono_debugger_handle_exception (&mctx, (MonoObject *)obj)) { - if (stack_ovf) - prepare_for_guard_pages (&mctx); - restore_context (&mctx); - } - mono_handle_exception (&mctx, obj); if (stack_ovf) prepare_for_guard_pages (&mctx); - restore_context (&mctx); + mono_restore_context (&mctx); } void