X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fexceptions-mips.c;h=710125dcfd14d48f2ff00f39f0c73b251c323833;hb=5600f484aa032bddfe71c1d85a80a33a32ae4a92;hp=a0b11913613147d5950e4f948afc1a8b6e352785;hpb=c8bd643c7204f15f79c1c63ae7988bf4451434da;p=mono.git diff --git a/mono/mini/exceptions-mips.c b/mono/mini/exceptions-mips.c index a0b11913613..710125dcfd1 100644 --- a/mono/mini/exceptions-mips.c +++ b/mono/mini/exceptions-mips.c @@ -31,10 +31,6 @@ #define GENERIC_EXCEPTION_SIZE 256 -#ifdef CUSTOM_EXCEPTION_HANDLING -static gboolean arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean test_only); -#endif - /* XXX */ #if 1 #define restore_regs_from_context(ctx_reg,ip_reg,tmp_reg) do { \ @@ -62,7 +58,7 @@ static gboolean arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean * The first argument in a0 is the pointer to the MonoContext. */ gpointer -mono_arch_get_restore_context (void) +mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot) { int i; guint8 *code; @@ -70,6 +66,10 @@ mono_arch_get_restore_context (void) static int inited = 0; guint32 iregs_to_restore; + g_assert (!aot); + if (info) + *info = NULL; + if (inited) return start; inited = 1; @@ -79,7 +79,7 @@ mono_arch_get_restore_context (void) | (1 << mips_sp) | (1 << mips_ra)); for (i = 0; i < MONO_SAVED_GREGS; ++i) { if (iregs_to_restore & (1 << i)) { - mips_lw (code, i, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[i])); + MIPS_LW (code, i, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[i])); } } @@ -112,7 +112,7 @@ mono_arch_get_restore_context (void) * handler (void) */ gpointer -mono_arch_get_call_filter (void) +mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot) { static guint8 start [320]; static int inited = 0; @@ -120,6 +120,10 @@ mono_arch_get_call_filter (void) int alloc_size; int offset; + g_assert (!aot); + if (info) + *info = NULL; + if (inited) return start; @@ -134,26 +138,26 @@ mono_arch_get_call_filter (void) /* Save global registers on stack (s0 - s7) */ offset = 16; - mips_sw (code, mips_s0, mips_sp, offset); offset += 4; - mips_sw (code, mips_s1, mips_sp, offset); offset += 4; - mips_sw (code, mips_s2, mips_sp, offset); offset += 4; - mips_sw (code, mips_s3, mips_sp, offset); offset += 4; - mips_sw (code, mips_s4, mips_sp, offset); offset += 4; - mips_sw (code, mips_s5, mips_sp, offset); offset += 4; - mips_sw (code, mips_s6, mips_sp, offset); offset += 4; - mips_sw (code, mips_s7, mips_sp, offset); offset += 4; - mips_sw (code, mips_fp, mips_sp, offset); offset += 4; + MIPS_SW (code, mips_s0, mips_sp, offset); offset += IREG_SIZE; + MIPS_SW (code, mips_s1, mips_sp, offset); offset += IREG_SIZE; + MIPS_SW (code, mips_s2, mips_sp, offset); offset += IREG_SIZE; + MIPS_SW (code, mips_s3, mips_sp, offset); offset += IREG_SIZE; + MIPS_SW (code, mips_s4, mips_sp, offset); offset += IREG_SIZE; + MIPS_SW (code, mips_s5, mips_sp, offset); offset += IREG_SIZE; + MIPS_SW (code, mips_s6, mips_sp, offset); offset += IREG_SIZE; + MIPS_SW (code, mips_s7, mips_sp, offset); offset += IREG_SIZE; + MIPS_SW (code, mips_fp, mips_sp, offset); offset += IREG_SIZE; /* Restore global registers from MonoContext, including the frame pointer */ - mips_lw (code, mips_s0, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s0])); - mips_lw (code, mips_s1, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s1])); - mips_lw (code, mips_s2, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s2])); - mips_lw (code, mips_s3, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s3])); - mips_lw (code, mips_s4, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s4])); - mips_lw (code, mips_s5, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s5])); - mips_lw (code, mips_s6, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s6])); - mips_lw (code, mips_s7, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s7])); - mips_lw (code, mips_fp, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_fp])); + MIPS_LW (code, mips_s0, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s0])); + MIPS_LW (code, mips_s1, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s1])); + MIPS_LW (code, mips_s2, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s2])); + MIPS_LW (code, mips_s3, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s3])); + MIPS_LW (code, mips_s4, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s4])); + MIPS_LW (code, mips_s5, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s5])); + MIPS_LW (code, mips_s6, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s6])); + MIPS_LW (code, mips_s7, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_s7])); + MIPS_LW (code, mips_fp, mips_a0, G_STRUCT_OFFSET (MonoContext, sc_regs[mips_fp])); /* a1 is the handler to call */ mips_move (code, mips_t9, mips_a1); @@ -164,15 +168,15 @@ mono_arch_get_call_filter (void) /* restore all regs from the stack */ offset = 16; - mips_lw (code, mips_s0, mips_sp, offset); offset += 4; - mips_lw (code, mips_s1, mips_sp, offset); offset += 4; - mips_lw (code, mips_s2, mips_sp, offset); offset += 4; - mips_lw (code, mips_s3, mips_sp, offset); offset += 4; - mips_lw (code, mips_s4, mips_sp, offset); offset += 4; - mips_lw (code, mips_s5, mips_sp, offset); offset += 4; - mips_lw (code, mips_s6, mips_sp, offset); offset += 4; - mips_lw (code, mips_s7, mips_sp, offset); offset += 4; - mips_lw (code, mips_fp, mips_sp, offset); offset += 4; + MIPS_LW (code, mips_s0, mips_sp, offset); offset += IREG_SIZE; + MIPS_LW (code, mips_s1, mips_sp, offset); offset += IREG_SIZE; + MIPS_LW (code, mips_s2, mips_sp, offset); offset += IREG_SIZE; + MIPS_LW (code, mips_s3, mips_sp, offset); offset += IREG_SIZE; + MIPS_LW (code, mips_s4, mips_sp, offset); offset += IREG_SIZE; + MIPS_LW (code, mips_s5, mips_sp, offset); offset += IREG_SIZE; + MIPS_LW (code, mips_s6, mips_sp, offset); offset += IREG_SIZE; + MIPS_LW (code, mips_s7, mips_sp, offset); offset += IREG_SIZE; + MIPS_LW (code, mips_fp, mips_sp, offset); offset += IREG_SIZE; /* epilog */ mips_lw (code, mips_ra, mips_sp, alloc_size + MIPS_RET_ADDR_OFFSET); @@ -197,7 +201,7 @@ throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, gboolean #endif if (!restore_context) - restore_context = mono_arch_get_restore_context (); + restore_context = mono_get_restore_context (); /* adjust eip so that it point into the call instruction */ eip -= 8; @@ -207,11 +211,7 @@ throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, gboolean /*g_print ("stack in throw: %p\n", esp);*/ memcpy (&ctx.sc_regs, (void *)(esp + MIPS_STACK_PARAM_OFFSET), sizeof (gulong) * MONO_SAVED_GREGS); -#if 0 - memcpy (&ctx.sc_fpregs, fp_regs, sizeof (float) * MONO_SAVED_FREGS); -#else - memset (&ctx.sc_fpregs, 0, sizeof (float) * MONO_SAVED_FREGS); -#endif + memset (&ctx.sc_fpregs, 0, sizeof (mips_freg) * MONO_SAVED_FREGS); MONO_CONTEXT_SET_IP (&ctx, eip); if (mono_object_isinst (exc, mono_defaults.exception_class)) { @@ -219,11 +219,7 @@ throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, gboolean if (!rethrow) mono_ex->stack_trace = NULL; } -#ifdef CUSTOM_EXCEPTION_HANDLING - arch_handle_exception (&ctx, exc, FALSE); -#else mono_handle_exception (&ctx, exc, (void *)eip, FALSE); -#endif #ifdef DEBUG_EXCEPTIONS g_print ("throw_exception: restore to pc=%p sp=%p fp=%p ctx=%p\n", (void *) ctx.sc_pc, (void *) ctx.sc_regs[mips_sp], @@ -244,7 +240,7 @@ throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, gboolean * */ static gpointer -mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name, gboolean rethrow) +mono_arch_get_throw_exception_generic (guint8 *start, int size, int corlib, gboolean rethrow) { guint8 *code; int alloc_size, pos, i; @@ -270,18 +266,17 @@ mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name, gbo /* Save all the regs on the stack */ for (i = 0; i < MONO_MAX_IREGS; i++) { if (i != mips_sp) - mips_sw (code, i, mips_sp, i*sizeof(guint32) + MIPS_STACK_PARAM_OFFSET); + MIPS_SW (code, i, mips_sp, i*IREG_SIZE + MIPS_STACK_PARAM_OFFSET); else { mips_addiu (code, mips_at, mips_sp, alloc_size); - mips_sw (code, mips_at, mips_sp, i*sizeof(guint32) + MIPS_STACK_PARAM_OFFSET); + MIPS_SW (code, mips_at, mips_sp, i*IREG_SIZE + MIPS_STACK_PARAM_OFFSET); } } - if (by_name) { - mips_move (code, mips_a2, mips_a0); + if (corlib) { + mips_move (code, mips_a1, mips_a0); mips_load (code, mips_a0, mono_defaults.corlib); - mips_load (code, mips_a1, "System"); - mips_load (code, mips_t9, mono_exception_from_name); + mips_load (code, mips_t9, mono_exception_from_token); mips_jalr (code, mips_t9, mips_ra); mips_nop (code); mips_move (code, mips_a0, mips_v0); @@ -291,7 +286,7 @@ mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name, gbo /* exc is already in place in a0 */ /* pointer to ip */ - if (by_name) + if (corlib) mips_lw (code, mips_a1, mips_sp, alloc_size + MIPS_RET_ADDR_OFFSET); else mips_move (code, mips_a1, mips_ra); @@ -320,11 +315,15 @@ mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name, gbo * */ gpointer -mono_arch_get_rethrow_exception (void) +mono_arch_get_rethrow_exception (MonoTrampInfo **info, gboolean aot) { static guint8 start [GENERIC_EXCEPTION_SIZE]; static int inited = 0; + g_assert (!aot); + if (info) + *info = NULL; + if (inited) return start; mono_arch_get_throw_exception_generic (start, sizeof (start), FALSE, TRUE); @@ -344,12 +343,16 @@ mono_arch_get_rethrow_exception (void) * x86_call_code (code, arch_get_throw_exception ()); * */ -gpointer -mono_arch_get_throw_exception (void) +gpointer +mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot) { static guint8 start [GENERIC_EXCEPTION_SIZE]; static int inited = 0; + g_assert (!aot); + if (info) + *info = NULL; + if (inited) return start; mono_arch_get_throw_exception_generic (start, sizeof (start), FALSE, FALSE); @@ -357,116 +360,81 @@ mono_arch_get_throw_exception (void) return start; } +gpointer +mono_arch_get_throw_exception_by_name (void) +{ + guint8 *start, *code; + int size = 64; + + /* Not used on MIPS */ + start = code = mono_global_codeman_reserve (size); + mips_break (code, 0xfd); + mono_arch_flush_icache (start, code - start); + return start; +} + /** - * arch_get_throw_exception_by_name: + * mono_arch_get_throw_corlib_exception: * * Returns a function pointer which can be used to raise * corlib exceptions. The returned function has the following - * signature: void (*func) (char *exc_name); - * For example to raise an arithmetic exception you can use: - * - * x86_push_imm (code, "ArithmeticException"); - * x86_call_code (code, arch_get_throw_exception_by_name ()); - * + * signature: void (*func) (guint32 ex_token, guint32 offset); + * On MIPS, the offset argument is missing. */ -gpointer -mono_arch_get_throw_exception_by_name (void) +gpointer +mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot) { static guint8 start [GENERIC_EXCEPTION_SIZE]; static int inited = 0; + g_assert (!aot); + if (info) + *info = NULL; + if (inited) return start; mono_arch_get_throw_exception_generic (start, sizeof (start), TRUE, FALSE); inited = 1; return start; -} - -static MonoArray * -glist_to_array (GList *list, MonoClass *eclass) -{ - MonoDomain *domain = mono_domain_get (); - MonoArray *res; - int len, i; - - if (!list) - return NULL; - - len = g_list_length (list); - res = mono_array_new (domain, eclass, len); - - for (i = 0; list; list = list->next, i++) - mono_array_set (res, gpointer, i, list->data); - - return res; } -/* mono_arch_find_jit_info: +/* + * mono_arch_find_jit_info: * - * This function is used to gather information from @ctx. It returns the - * MonoJitInfo of the corresponding function, unwinds one stack frame and - * stores the resulting context into @new_ctx. It also stores a string - * describing the stack location into @trace (if not NULL), and modifies - * the @lmf if necessary. @native_offset return the IP offset from the - * start of the function or -1 if that info is not available. + * This function is used to gather information from @ctx, and store it in @frame_info. + * It unwinds one stack frame, and stores the resulting context into @new_ctx. @lmf + * is modified if needed. + * Returns TRUE on success, FALSE otherwise. */ -MonoJitInfo * -mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, - MonoJitInfo *res, MonoJitInfo *prev_ji, - MonoContext *ctx, MonoContext *new_ctx, - char **trace, MonoLMF **lmf, - int *native_offset, gboolean *managed) +gboolean +mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, + MonoJitInfo *ji, MonoContext *ctx, + MonoContext *new_ctx, MonoLMF **lmf, + mgreg_t **save_locations, + StackFrameInfo *frame) { - MonoJitInfo *ji; - gpointer ip = MONO_CONTEXT_GET_IP (ctx); - gpointer fp = MONO_CONTEXT_GET_BP (ctx); - guint32 sp; - - /* Avoid costly table lookup during stack overflow */ - if (prev_ji && (ip > prev_ji->code_start && ((guint8*)ip < ((guint8*)prev_ji->code_start) + prev_ji->code_size))) - ji = prev_ji; - else - ji = mono_jit_info_table_find (domain, ip); - - if (trace) - *trace = NULL; - - if (native_offset) - *native_offset = -1; - - if (managed) - *managed = FALSE; + memset (frame, 0, sizeof (StackFrameInfo)); + frame->ji = ji; *new_ctx = *ctx; - setup_context (new_ctx); if (ji != NULL) { - int i; gint32 address; - int offset = 0; + gpointer ip = MONO_CONTEXT_GET_IP (ctx); + gpointer fp = MONO_CONTEXT_GET_BP (ctx); + guint32 sp; + + frame->type = FRAME_TYPE_MANAGED; - if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) { + if (*lmf && (fp >= (gpointer)(*lmf)->ebp)) { /* remove any unused lmf */ *lmf = (*lmf)->previous_lmf; } address = (char *)ip - (char *)ji->code_start; - if (native_offset) - *native_offset = address; - - if (managed) - if (!ji->method->wrapper_type) - *managed = TRUE; - - if (trace) { - *trace = mono_debug_print_stack_frame (ji->method, offset, domain); - } - - /* My stack frame */ - fp = MONO_CONTEXT_GET_BP (ctx); - - /* Compute the previous stack frame */ + /* Compute the previous stack frame, assuming method + * starts with addiu sp, sp, . */ sp = (guint32)(fp) - (short)(*(guint32 *)(ji->code_start)); /* Sanity check the frame */ @@ -475,7 +443,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, #ifdef DEBUG_EXCEPTIONS g_print ("mono_arch_find_jit_info: bad stack sp=%p\n", (void *) sp); #endif - return (gpointer)-1; + return FALSE; } if (ji->method->save_lmf && 0) { @@ -496,10 +464,15 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, /* these all happen before adjustment of fp */ /* Look for sw ??, ????(sp) */ insn = ((guint32 *)ji->code_start) + 1; - while (!*insn || (*insn & 0xffe00000) == 0xafa00000) { + while (!*insn || ((*insn & 0xffe00000) == 0xafa00000) || ((*insn & 0xffe00000) == 0xffa00000)) { int reg = (*insn >> 16) & 0x1f; + guint32 addr = (((guint32)fp) + (short)(*insn & 0x0000ffff)); + mask &= ~(1 << reg); - new_ctx->sc_regs [reg] = *(guint32 *)(((guint32)fp) + (short)(*insn & 0x0000ffff)); + if ((*insn & 0xffe00000) == 0xafa00000) + new_ctx->sc_regs [reg] = *(guint32 *)addr; + else + new_ctx->sc_regs [reg] = *(guint64 *)addr; insn++; } MONO_CONTEXT_SET_SP (new_ctx, sp); @@ -511,28 +484,26 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MONO_CONTEXT_SET_IP (new_ctx, new_ctx->sc_regs[mips_ra] - 8); /* Sanity check -- we should have made progress here */ - g_assert (new_ctx->sc_pc != ctx->sc_pc); - return ji; + g_assert (MONO_CONTEXT_GET_BP (new_ctx) != MONO_CONTEXT_GET_BP (ctx)); + return TRUE; } else if (*lmf) { if (!(*lmf)->method) { #ifdef DEBUG_EXCEPTIONS g_print ("mono_arch_find_jit_info: bad lmf @ %p\n", (void *) *lmf); #endif - return (gpointer)-1; + return FALSE; } g_assert (((*lmf)->magic == MIPS_LMF_MAGIC1) || ((*lmf)->magic == MIPS_LMF_MAGIC2)); - if (trace) { - char *fname = mono_method_full_name ((*lmf)->method, TRUE); - *trace = g_strdup_printf ("in (unmanaged) %s", fname); - g_free (fname); - } - - if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { - } else { - memset (res, 0, sizeof (MonoJitInfo)); - res->method = (*lmf)->method; + ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip, NULL); + if (!ji) { + // FIXME: This can happen with multiple appdomains (bug #444383) + return FALSE; } + + frame->ji = ji; + frame->type = FRAME_TYPE_MANAGED_TO_NATIVE; + memcpy (&new_ctx->sc_regs, (*lmf)->iregs, sizeof (gulong) * MONO_SAVED_GREGS); memcpy (&new_ctx->sc_fpregs, (*lmf)->fregs, sizeof (float) * MONO_SAVED_FREGS); MONO_CONTEXT_SET_IP (new_ctx, (*lmf)->eip); @@ -540,10 +511,10 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, g_assert (new_ctx->sc_pc != ctx->sc_pc); *lmf = (*lmf)->previous_lmf; - return ji ? ji : res; + return TRUE; } - return NULL; + return FALSE; } void @@ -592,12 +563,8 @@ mono_arch_handle_exception (void *ctx, gpointer obj, gboolean test_only) #ifdef DEBUG_EXCEPTIONS g_print ("mono_arch_handle_exception: pc=%p\n", (void *) mctx.sc_pc); #endif -#ifdef CUSTOM_EXCEPTION_HANDLING - result = arch_handle_exception (&mctx, obj, test_only); -#else mono_handle_exception (&mctx, obj, (gpointer)mctx.sc_pc, test_only); result = TRUE; -#endif #ifdef DEBUG_EXCEPTIONS g_print ("mono_arch_handle_exception: restore pc=%p\n", (void *)mctx.sc_pc); @@ -609,180 +576,3 @@ mono_arch_handle_exception (void *ctx, gpointer obj, gboolean test_only) return result; } - -#ifdef CUSTOM_EXCEPTION_HANDLING -/** - * arch_handle_exception: - * @ctx: saved processor state - * @obj: the exception object - * @test_only: only test if the exception is caught, but dont call handlers - * - * - */ -static gboolean -arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean test_only) -{ - MonoDomain *domain = mono_domain_get (); - MonoJitInfo *ji, rji; - static int (*call_filter) (MonoContext *, gpointer, gpointer) = NULL; - MonoJitTlsData *jit_tls = TlsGetValue (mono_jit_tls_id); - MonoLMF *lmf = jit_tls->lmf; - GList *trace_ips = NULL; - MonoException *mono_ex; - MonoArray *initial_trace_ips = NULL; - int frame_count = 0; - gboolean has_dynamic_methods = FALSE; - - g_assert (ctx != NULL); - if (!obj) { - MonoException *ex = mono_get_exception_null_reference (); - ex->message = mono_string_new (domain, - "Object reference not set to an instance of an object"); - obj = (MonoObject *)ex; - } - - if (mono_object_isinst (obj, mono_defaults.exception_class)) { - mono_ex = (MonoException*)obj; - initial_trace_ips = mono_ex->trace_ips; - } else { - mono_ex = NULL; - } - - - if (!call_filter) - call_filter = mono_arch_get_call_filter (); - - g_assert (jit_tls->end_of_stack); - g_assert (jit_tls->abort_func); - - if (!test_only) { - MonoContext ctx_cp = *ctx; - setup_context (&ctx_cp); - if (mono_jit_trace_calls != NULL) - g_print ("EXCEPTION handling: %s\n", mono_object_class (obj)->name); - if (!arch_handle_exception (&ctx_cp, obj, TRUE)) { - if (mono_break_on_exc) - G_BREAKPOINT (); - mono_unhandled_exception (obj); - } - } - - memset (&rji, 0, sizeof (rji)); - - while (1) { - MonoContext new_ctx; - - setup_context (&new_ctx); - ji = mono_arch_find_jit_info (domain, jit_tls, &rji, &rji, ctx, &new_ctx, - NULL, &lmf, NULL, NULL); - if (!ji) { - g_warning ("Exception inside function without unwind info"); - g_assert_not_reached (); - } - - if (ji != (gpointer)-1) { - frame_count ++; - - if (test_only && ji->method->wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE && mono_ex) { - /* - * Avoid overwriting the stack trace if the exception is - * rethrown. Also avoid giant stack traces during a stack - * overflow. - */ - if (!initial_trace_ips && (frame_count < 1000)) { - trace_ips = g_list_prepend (trace_ips, MONO_CONTEXT_GET_IP (ctx)); - - } - } - - if (ji->method->dynamic) - has_dynamic_methods = TRUE; - - if (ji->num_clauses) { - int i; - - g_assert (ji->clauses); - - for (i = 0; i < ji->num_clauses; i++) { - MonoJitExceptionInfo *ei = &ji->clauses [i]; - gboolean filtered = FALSE; - - if (ei->try_start <= MONO_CONTEXT_GET_IP (ctx) && - MONO_CONTEXT_GET_IP (ctx) <= ei->try_end) { - /* catch block */ - - if ((ei->flags == MONO_EXCEPTION_CLAUSE_NONE) || (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER)) { - /* store the exception object int cfg->excvar */ - g_assert (ei->exvar_offset); - /* need to use the frame pointer (mips_fp): methods with clauses always have mips_fp */ - *((gpointer *)(void*)((char *)(ctx->sc_regs [mips_fp]) + ei->exvar_offset)) = obj; - } - - if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) - filtered = call_filter (ctx, ei->data.filter, mono_ex); - - if ((ei->flags == MONO_EXCEPTION_CLAUSE_NONE && - mono_object_isinst (obj, ei->data.catch_class)) || filtered) { - if (test_only) { - if (mono_ex && !initial_trace_ips) { - trace_ips = g_list_reverse (trace_ips); - mono_ex->trace_ips = glist_to_array (trace_ips, mono_defaults.int_class); - if (has_dynamic_methods) - /* These methods could go away anytime, so compute the stack trace now */ - mono_ex->stack_trace = ves_icall_System_Exception_get_trace (mono_ex); - } - g_list_free (trace_ips); - return TRUE; - } - if (mono_jit_trace_calls != NULL) - g_print ("EXCEPTION: catch found at clause %d of %s\n", i, mono_method_full_name (ji->method, TRUE)); - /*g_print ("stack for catch: %p\n", MONO_CONTEXT_GET_BP (ctx));*/ - MONO_CONTEXT_SET_IP (ctx, ei->handler_start); - jit_tls->lmf = lmf; - return 0; - } - if (!test_only && ei->try_start <= MONO_CONTEXT_GET_IP (ctx) && - MONO_CONTEXT_GET_IP (ctx) < ei->try_end && - (ei->flags & MONO_EXCEPTION_CLAUSE_FINALLY)) { - if (mono_jit_trace_calls != NULL) - g_print ("EXCEPTION: finally clause %d of %s\n", i, mono_method_full_name (ji->method, TRUE)); - call_filter (ctx, ei->handler_start, NULL); - } - - } - } - } - } - - *ctx = new_ctx; - setup_context (ctx); - - if ((ji == (gpointer)-1) || MONO_CONTEXT_GET_BP (ctx) >= jit_tls->end_of_stack) { - if (!test_only) { - jit_tls->lmf = lmf; - jit_tls->abort_func (obj); - g_assert_not_reached (); - } else { - if (mono_ex && !initial_trace_ips) { - trace_ips = g_list_reverse (trace_ips); - mono_ex->trace_ips = glist_to_array (trace_ips, mono_defaults.int_class); - if (has_dynamic_methods) - /* These methods could go away anytime, so compute the stack trace now */ - mono_ex->stack_trace = ves_icall_System_Exception_get_trace (mono_ex); - } - g_list_free (trace_ips); - return FALSE; - } - } - } - - g_assert_not_reached (); -} -#endif /* CUSTOM_EXCEPTION_HANDLING */ - -gboolean -mono_arch_has_unwind_info (gconstpointer addr) -{ - return FALSE; -} -