X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fexceptions-s390.c;h=11a802331a2e203738e4e00bd4f0ce918bb6e98d;hb=f70afd2b76174d2c78c2074805c80eddbc36d953;hp=d9d6a12f96d5da06725b3893aa9e6ffb01bd8810;hpb=ff228e1c801bda9666b6edab3ee962e05edcf480;p=mono.git diff --git a/mono/mini/exceptions-s390.c b/mono/mini/exceptions-s390.c index d9d6a12f96d..11a802331a2 100644 --- a/mono/mini/exceptions-s390.c +++ b/mono/mini/exceptions-s390.c @@ -76,23 +76,6 @@ gboolean mono_arch_handle_exception (void *ctx, /*====================== End of Global Variables ===================*/ -/*------------------------------------------------------------------*/ -/* */ -/* Name - mono_arch_has_unwind_info */ -/* */ -/* Function - Tests if a function has a DWARF exception table */ -/* that is able to restore all caller saved registers*/ -/* */ -/*------------------------------------------------------------------*/ - -gboolean -mono_arch_has_unwind_info (gconstpointer addr) -{ - return FALSE; -} - -/*========================= End of Function ========================*/ - /*------------------------------------------------------------------*/ /* */ /* Name - mono_arch_get_call_filter */ @@ -105,13 +88,17 @@ mono_arch_has_unwind_info (gconstpointer addr) /*------------------------------------------------------------------*/ gpointer -mono_arch_get_call_filter (void) +mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot) { static guint8 *start; static int inited = 0; guint8 *code; int alloc_size, pos, i; + g_assert (!aot); + if (info) + *info = NULL; + if (inited) return start; @@ -347,12 +334,16 @@ get_throw_exception_generic (guint8 *start, int size, /* */ /*------------------------------------------------------------------*/ -gpointer -mono_arch_get_throw_exception (void) +gpointer +mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot) { static guint8 *start; static int inited = 0; + g_assert (!aot); + if (info) + *info = NULL; + if (inited) return start; start = mono_global_codeman_reserve (SZ_THROW); @@ -375,11 +366,15 @@ mono_arch_get_throw_exception (void) /*------------------------------------------------------------------*/ gpointer -mono_arch_get_rethrow_exception (void) +mono_arch_get_rethrow_exception (MonoTrampInfo **info, gboolean aot) { static guint8 *start; static int inited = 0; + g_assert (!aot); + if (info) + *info = NULL; + if (inited) return start; start = mono_global_codeman_reserve (SZ_THROW); @@ -421,49 +416,29 @@ mono_arch_get_throw_exception_by_name (void) /* */ /* Name - mono_arch_find_jit_info */ /* */ -/* Function - This function is used to gather informatoin from */ -/* @ctx. It returns the MonoJitInfo of the corres- */ -/* ponding 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 returns the IP off- */ -/* set from the start of the function or -1 if that */ -/* informatoin is not available. */ +/* Function - See exceptions-amd64.c for docs. */ /* */ /*------------------------------------------------------------------*/ -MonoJitInfo * +gboolean 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) + MonoJitInfo *ji, MonoContext *ctx, + MonoContext *new_ctx, MonoLMF **lmf, + mgreg_t **save_locations, + StackFrameInfo *frame) { - MonoJitInfo *ji; gpointer ip = MONO_CONTEXT_GET_IP (ctx); MonoS390StackFrame *sframe; - 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; + memset (frame, 0, sizeof (StackFrameInfo)); + frame->ji = ji; - if (native_offset) - *native_offset = -1; - - if (managed) - *managed = FALSE; + *new_ctx = *ctx; if (ji != NULL) { - char *source_location, *tmpaddr, *fname; - gint32 address, iloffset; + gint32 address; - *new_ctx = *ctx; + frame->type = FRAME_TYPE_MANAGED; if (*lmf && (MONO_CONTEXT_GET_SP (ctx) >= (gpointer)(*lmf)->ebp)) { /* remove any unused lmf */ @@ -472,66 +447,36 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, address = (char *)ip - (char *)ji->code_start; - if (native_offset) - *native_offset = address; - - if (managed) - if (!ji->method->wrapper_type) - *managed = TRUE; - - if (trace) { - source_location = mono_debug_source_location_from_address (ji->method, address, NULL, domain); - iloffset = mono_debug_il_offset_from_address (ji->method, address, domain); - - if (iloffset < 0) - tmpaddr = g_strdup_printf ("<0x%08x>", address); - else - tmpaddr = g_strdup_printf ("[0x%08x]", iloffset); - - fname = mono_method_full_name (ji->method, TRUE); - - if (source_location) - *trace = g_strdup_printf ("in %s (at %s) %s", tmpaddr, source_location, fname); - else - *trace = g_strdup_printf ("in %s %s", tmpaddr, fname); - - g_free (fname); - g_free (source_location); - g_free (tmpaddr); - } sframe = (MonoS390StackFrame *) MONO_CONTEXT_GET_SP (ctx); MONO_CONTEXT_SET_BP (new_ctx, sframe->prev); sframe = (MonoS390StackFrame *) sframe->prev; - MONO_CONTEXT_SET_IP (new_ctx, sframe->return_address); + MONO_CONTEXT_SET_IP (new_ctx, (guint8*)sframe->return_address - 2); memcpy (&new_ctx->uc_mcontext.gregs[6], sframe->regs, (8*sizeof(gint32))); - return ji; + return TRUE; } else if (*lmf) { - - *new_ctx = *ctx; - if (!(*lmf)->method) - return (gpointer)-1; - - if (trace) - *trace = g_strdup_printf ("in (unmanaged) %s", mono_method_full_name ((*lmf)->method, TRUE)); - - if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) { - } else { - memset (res, 0, sizeof (MonoJitInfo)); - res->method = (*lmf)->method; + return FALSE; + + 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->uc_mcontext.gregs, (*lmf)->gregs, sizeof((*lmf)->gregs)); memcpy(new_ctx->uc_mcontext.fpregs.fprs, (*lmf)->fregs, sizeof((*lmf)->fregs)); MONO_CONTEXT_SET_BP (new_ctx, (*lmf)->ebp); - MONO_CONTEXT_SET_IP (new_ctx, (*lmf)->eip); + MONO_CONTEXT_SET_IP (new_ctx, (*lmf)->eip - 2); *lmf = (*lmf)->previous_lmf; - return ji ? ji : res; + return TRUE; } - return NULL; + return FALSE; } /*========================= End of Function ========================*/ @@ -578,7 +523,7 @@ mono_arch_ip_from_context (void *sigctx) /*------------------------------------------------------------------*/ /* */ -/* Name - mono_arch_get_restore_context */ +/* Name - mono_arch_get_restore_context */ /* */ /* Function - Return the address of the routine that will rest- */ /* ore the context. */ @@ -586,8 +531,12 @@ mono_arch_ip_from_context (void *sigctx) /*------------------------------------------------------------------*/ gpointer -mono_arch_get_restore_context () +mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot) { + g_assert (!aot); + if (info) + *info = NULL; + return setcontext; } @@ -629,7 +578,7 @@ mono_arch_is_int_overflow (void *uc, void *info) case 0x5d : /* Divide */ regNo = (code[2] & 0xf0 >> 8); offset = *((guint16 *) code+2) & 0x0fff; - operand = ctx->uc_mcontext.gregs[regNo] + offset; + operand = (guint32*)(ctx->uc_mcontext.gregs[regNo] + offset); if (*operand == 0) arithExc = FALSE; break; @@ -644,7 +593,7 @@ mono_arch_is_int_overflow (void *uc, void *info) if (code[1] == 0x97) { regNo = (code[2] & 0xf0 >> 8); offset = *((guint32 *) code+1) & 0x000fffff; - operand = ctx->uc_mcontext.gregs[regNo] + offset; + operand = (guint32*)(ctx->uc_mcontext.gregs[regNo] + offset); if (*operand == 0) arithExc = FALSE; } @@ -652,7 +601,7 @@ mono_arch_is_int_overflow (void *uc, void *info) default: arithExc = TRUE; } - ctx->uc_mcontext.psw.addr = code; + ctx->uc_mcontext.psw.addr = (guint32)code; return (arithExc); }