#include <config.h>
-#if _WIN32_WINNT < 0x0501
-/* Required for Vectored Exception Handling. */
-#undef _WIN32_WINNT
-#define _WIN32_WINNT 0x0501
-#endif /* _WIN32_WINNT < 0x0501 */
-
#include <glib.h>
#include <signal.h>
#include <string.h>
+#ifdef HAVE_UCONTEXT_H
+#include <ucontext.h>
+#endif
+#include <mono/metadata/abi-details.h>
#include <mono/arch/x86/x86-codegen.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-debug.h>
#include <mono/utils/mono-mmap.h>
static gpointer signal_exception_trampoline;
gpointer
-mono_x86_get_signal_exception_trampoline (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+mono_x86_get_signal_exception_trampoline (MonoTrampInfo **info, gboolean aot);
#ifdef TARGET_WIN32
static void (*restore_stack) (void *);
LPTOP_LEVEL_EXCEPTION_FILTER mono_old_win_toplevel_exception_filter;
gpointer mono_win_vectored_exception_handle;
-extern gboolean mono_win_chained_exception_needs_run;
extern int (*gUnhandledExceptionHandler)(EXCEPTION_POINTERS*);
#ifndef PROCESS_CALLBACK_FILTER_ENABLED
#endif
#define W32_SEH_HANDLE_EX(_ex) \
- if (_ex##_handler) _ex##_handler(0, ep, sctx)
+ if (_ex##_handler) _ex##_handler(0, ep, ctx)
LONG CALLBACK seh_unhandled_exception_filter(EXCEPTION_POINTERS* ep)
{
}
#endif
- mono_handle_native_sigsegv (SIGSEGV, NULL);
+ mono_handle_native_sigsegv (SIGSEGV, NULL, NULL);
return EXCEPTION_CONTINUE_SEARCH;
}
x86_mov_reg_reg (code, X86_EDI, X86_ESP, 4);
/* use the new freed stack from sigcontext */
+ /* XXX replace usage of struct sigcontext with MonoContext so we can use MONO_STRUCT_OFFSET */
x86_mov_reg_membase (code, X86_ESP, X86_EBX, G_STRUCT_OFFSET (struct sigcontext, esp), 4);
/* get the current domain */
/* return */
x86_ret (code);
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
return start;
}
guint32 free_stack = 0;
StackFrameInfo frame;
- /* convert sigcontext to MonoContext (due to reuse of stack walking helpers */
- mono_arch_sigctx_to_monoctx (sctx, &ctx);
+ mono_sigctx_to_monoctx (sctx, &ctx);
/* get our os page size */
GetSystemInfo(&si);
do {
MonoContext new_ctx;
- mono_arch_find_jit_info (domain, jit_tls, &rji, &ctx, &new_ctx, &lmf, NULL, &frame);
+ mono_arch_unwind_frame (domain, jit_tls, &rji, &ctx, &new_ctx, &lmf, NULL, &frame);
if (!frame.ji) {
g_warning ("Exception inside function without unwind info");
g_assert_not_reached ();
ctx = new_ctx;
} while (free_stack < 64 * 1024 && frame.ji != (gpointer) -1);
- /* convert into sigcontext to be used in mono_arch_handle_exception */
- mono_arch_monoctx_to_sigctx (&ctx, sctx);
+ mono_monoctx_to_sigctx (&ctx, sctx);
/* todo: install new stack-guard page */
{
EXCEPTION_RECORD* er;
CONTEXT* ctx;
- struct sigcontext* sctx;
LONG res;
+ MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
+
+ /* If the thread is not managed by the runtime return early */
+ if (!jit_tls)
+ return EXCEPTION_CONTINUE_SEARCH;
- mono_win_chained_exception_needs_run = FALSE;
+ jit_tls->mono_win_chained_exception_needs_run = FALSE;
res = EXCEPTION_CONTINUE_EXECUTION;
er = ep->ExceptionRecord;
ctx = ep->ContextRecord;
- sctx = g_malloc(sizeof(struct sigcontext));
-
- /* Copy Win32 context to UNIX style context */
- sctx->eax = ctx->Eax;
- sctx->ebx = ctx->Ebx;
- sctx->ecx = ctx->Ecx;
- sctx->edx = ctx->Edx;
- sctx->ebp = ctx->Ebp;
- sctx->esp = ctx->Esp;
- sctx->esi = ctx->Esi;
- sctx->edi = ctx->Edi;
- sctx->eip = ctx->Eip;
switch (er->ExceptionCode) {
case EXCEPTION_STACK_OVERFLOW:
- win32_handle_stack_overflow (ep, sctx);
+ win32_handle_stack_overflow (ep, ctx);
break;
case EXCEPTION_ACCESS_VIOLATION:
W32_SEH_HANDLE_EX(segv);
W32_SEH_HANDLE_EX(fpe);
break;
default:
+ jit_tls->mono_win_chained_exception_needs_run = TRUE;
break;
}
- if (mono_win_chained_exception_needs_run) {
+ if (jit_tls->mono_win_chained_exception_needs_run) {
/* Don't copy context back if we chained exception
* as the handler may have modfied the EXCEPTION_POINTERS
* directly. We don't pass sigcontext to chained handlers.
* can correctly chain the exception.
*/
res = EXCEPTION_CONTINUE_SEARCH;
- } else {
- /* Copy context back */
- ctx->Eax = sctx->eax;
- ctx->Ebx = sctx->ebx;
- ctx->Ecx = sctx->ecx;
- ctx->Edx = sctx->edx;
- ctx->Ebp = sctx->ebp;
- ctx->Esp = sctx->esp;
- ctx->Esi = sctx->esi;
- ctx->Edi = sctx->edi;
- ctx->Eip = sctx->eip;
}
- /* TODO: Find right place to free this in stack overflow case */
- if (er->ExceptionCode != EXCEPTION_STACK_OVERFLOW)
- g_free (sctx);
-
return res;
}
void win32_seh_cleanup()
{
- if (mono_old_win_toplevel_exception_filter) SetUnhandledExceptionFilter(mono_old_win_toplevel_exception_filter);
- RemoveVectoredExceptionHandler (seh_unhandled_exception_filter);
+ if (mono_old_win_toplevel_exception_filter)
+ SetUnhandledExceptionFilter(mono_old_win_toplevel_exception_filter);
+ RemoveVectoredExceptionHandler (mono_win_vectored_exception_handle);
}
void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
x86_mov_reg_membase (code, X86_EAX, X86_ESP, 4, 4);
/* restore EBX */
- x86_mov_reg_membase (code, X86_EBX, X86_EAX, G_STRUCT_OFFSET (MonoContext, ebx), 4);
+ x86_mov_reg_membase (code, X86_EBX, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, ebx), 4);
/* restore EDI */
- x86_mov_reg_membase (code, X86_EDI, X86_EAX, G_STRUCT_OFFSET (MonoContext, edi), 4);
+ x86_mov_reg_membase (code, X86_EDI, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, edi), 4);
/* restore ESI */
- x86_mov_reg_membase (code, X86_ESI, X86_EAX, G_STRUCT_OFFSET (MonoContext, esi), 4);
+ x86_mov_reg_membase (code, X86_ESI, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, esi), 4);
/* restore EDX */
- x86_mov_reg_membase (code, X86_EDX, X86_EAX, G_STRUCT_OFFSET (MonoContext, edx), 4);
+ x86_mov_reg_membase (code, X86_EDX, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, edx), 4);
/*
* The context resides on the stack, in the stack frame of the
*/
/* load ESP into EBP */
- x86_mov_reg_membase (code, X86_EBP, X86_EAX, G_STRUCT_OFFSET (MonoContext, esp), 4);
+ x86_mov_reg_membase (code, X86_EBP, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, esp), 4);
/* load return address into ECX */
- x86_mov_reg_membase (code, X86_ECX, X86_EAX, G_STRUCT_OFFSET (MonoContext, eip), 4);
+ x86_mov_reg_membase (code, X86_ECX, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, eip), 4);
/* save the return addr to the restored stack - 4 */
x86_mov_membase_reg (code, X86_EBP, -4, X86_ECX, 4);
/* load EBP into ECX */
- x86_mov_reg_membase (code, X86_ECX, X86_EAX, G_STRUCT_OFFSET (MonoContext, ebp), 4);
+ x86_mov_reg_membase (code, X86_ECX, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, ebp), 4);
/* save EBP to the restored stack - 8 */
x86_mov_membase_reg (code, X86_EBP, -8, X86_ECX, 4);
/* load EAX into ECX */
- x86_mov_reg_membase (code, X86_ECX, X86_EAX, G_STRUCT_OFFSET (MonoContext, eax), 4);
+ x86_mov_reg_membase (code, X86_ECX, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, eax), 4);
/* save EAX to the restored stack - 12 */
x86_mov_membase_reg (code, X86_EBP, -12, X86_ECX, 4);
/* restore ECX */
- x86_mov_reg_membase (code, X86_ECX, X86_EAX, G_STRUCT_OFFSET (MonoContext, ecx), 4);
+ x86_mov_reg_membase (code, X86_ECX, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, ecx), 4);
/* restore ESP - 12 */
x86_lea_membase (code, X86_ESP, X86_EBP, -12);
g_slist_free (unwind_ops);
}
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
return start;
}
x86_push_reg (code, X86_EBP);
/* set new EBP */
- x86_mov_reg_membase (code, X86_EBP, X86_EAX, G_STRUCT_OFFSET (MonoContext, ebp), 4);
+ x86_mov_reg_membase (code, X86_EBP, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, ebp), 4);
/* restore registers used by global register allocation (EBX & ESI) */
- x86_mov_reg_membase (code, X86_EBX, X86_EAX, G_STRUCT_OFFSET (MonoContext, ebx), 4);
- x86_mov_reg_membase (code, X86_ESI, X86_EAX, G_STRUCT_OFFSET (MonoContext, esi), 4);
- x86_mov_reg_membase (code, X86_EDI, X86_EAX, G_STRUCT_OFFSET (MonoContext, edi), 4);
+ x86_mov_reg_membase (code, X86_EBX, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, ebx), 4);
+ x86_mov_reg_membase (code, X86_ESI, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, esi), 4);
+ x86_mov_reg_membase (code, X86_EDI, X86_EAX, MONO_STRUCT_OFFSET (MonoContext, edi), 4);
/* align stack and save ESP */
x86_mov_reg_reg (code, X86_EDX, X86_ESP, 4);
g_slist_free (unwind_ops);
}
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
g_assert ((code - start) < kMaxCodeSize);
return start;
}
mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc,
mgreg_t eip, gboolean rethrow)
{
+ MonoError error;
MonoContext ctx;
ctx.esp = regs [X86_ESP];
g_assert ((ctx.esp % MONO_ARCH_FRAME_ALIGNMENT) == 0);
#endif
- if (mono_object_isinst (exc, mono_defaults.exception_class)) {
+ if (mono_object_isinst_checked (exc, mono_defaults.exception_class, &error)) {
MonoException *mono_ex = (MonoException*)exc;
- if (!rethrow)
+ if (!rethrow) {
mono_ex->stack_trace = NULL;
+ mono_ex->trace_ips = NULL;
+ }
}
+ mono_error_assert_ok (&error);
/* adjust eip so that it point into the call instruction */
ctx.eip -= 1;
* <return addr> <- esp (unaligned on apple)
*/
- mono_add_unwind_op_def_cfa (unwind_ops, (guint8*)NULL, (guint8*)NULL, X86_ESP, 4);
- mono_add_unwind_op_offset (unwind_ops, (guint8*)NULL, (guint8*)NULL, X86_NREG, -4);
+ unwind_ops = mono_arch_get_cie_program ();
/* Alloc frame */
x86_alu_reg_imm (code, X86_SUB, X86_ESP, stack_size);
g_slist_free (unwind_ops);
}
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
return start;
}
mono_arch_exceptions_init (void)
{
guint8 *tramp;
+ MonoTrampInfo *tinfo;
/*
* If we're running WoW64, we need to set the usermode exception policy
* for SEHs to behave. This requires hotfix http://support.microsoft.com/kb/976038
* or (eventually) Windows 7 SP1.
*/
-#ifdef HOST_WIN32
+#ifdef TARGET_WIN32
DWORD flags;
FARPROC getter;
FARPROC setter;
}
/* LLVM needs different throw trampolines */
- tramp = get_throw_trampoline ("llvm_throw_exception_trampoline", FALSE, TRUE, FALSE, FALSE, FALSE, NULL, FALSE);
+ tramp = get_throw_trampoline ("llvm_throw_exception_trampoline", FALSE, TRUE, FALSE, FALSE, FALSE, &tinfo, FALSE);
mono_register_jit_icall (tramp, "llvm_throw_exception_trampoline", NULL, TRUE);
+ mono_tramp_info_register (tinfo, NULL);
- tramp = get_throw_trampoline ("llvm_rethrow_exception_trampoline", FALSE, TRUE, FALSE, FALSE, FALSE, NULL, FALSE);
+ tramp = get_throw_trampoline ("llvm_rethrow_exception_trampoline", TRUE, TRUE, FALSE, FALSE, FALSE, &tinfo, FALSE);
mono_register_jit_icall (tramp, "llvm_rethrow_exception_trampoline", NULL, TRUE);
+ mono_tramp_info_register (tinfo, NULL);
- tramp = get_throw_trampoline ("llvm_throw_corlib_exception_trampoline", FALSE, TRUE, TRUE, FALSE, FALSE, NULL, FALSE);
+ tramp = get_throw_trampoline ("llvm_throw_corlib_exception_trampoline", FALSE, TRUE, TRUE, FALSE, FALSE, &tinfo, FALSE);
mono_register_jit_icall (tramp, "llvm_throw_corlib_exception_trampoline", NULL, TRUE);
+ mono_tramp_info_register (tinfo, NULL);
- tramp = get_throw_trampoline ("llvm_throw_corlib_exception_abs_trampoline", FALSE, TRUE, TRUE, TRUE, FALSE, NULL, FALSE);
+ tramp = get_throw_trampoline ("llvm_throw_corlib_exception_abs_trampoline", FALSE, TRUE, TRUE, TRUE, FALSE, &tinfo, FALSE);
mono_register_jit_icall (tramp, "llvm_throw_corlib_exception_abs_trampoline", NULL, TRUE);
+ mono_tramp_info_register (tinfo, NULL);
- tramp = get_throw_trampoline ("llvm_resume_unwind_trampoline", FALSE, FALSE, FALSE, FALSE, TRUE, NULL, FALSE);
+ tramp = get_throw_trampoline ("llvm_resume_unwind_trampoline", FALSE, FALSE, FALSE, FALSE, TRUE, &tinfo, FALSE);
mono_register_jit_icall (tramp, "llvm_resume_unwind_trampoline", NULL, TRUE);
+ mono_tramp_info_register (tinfo, NULL);
- signal_exception_trampoline = mono_x86_get_signal_exception_trampoline (NULL, FALSE);
+ signal_exception_trampoline = mono_x86_get_signal_exception_trampoline (&tinfo, FALSE);
+ mono_tramp_info_register (tinfo, NULL);
}
/*
- * mono_arch_find_jit_info:
+ * mono_arch_unwind_frame:
*
* See exceptions-amd64.c for docs.
*/
gboolean
-mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
+mono_arch_unwind_frame (MonoDomain *domain, MonoJitTlsData *jit_tls,
MonoJitInfo *ji, MonoContext *ctx,
MonoContext *new_ctx, MonoLMF **lmf,
mgreg_t **save_locations,
guint32 unwind_info_len;
guint8 *unwind_info;
- frame->type = FRAME_TYPE_MANAGED;
+ if (ji->is_trampoline)
+ frame->type = FRAME_TYPE_TRAMPOLINE;
+ else
+ frame->type = FRAME_TYPE_MANAGED;
unwind_info = mono_jinfo_get_unwind_info (ji, &unwind_info_len);
mono_unwind_frame (unwind_info, unwind_info_len, ji->code_start,
(guint8*)ji->code_start + ji->code_size,
- ip, regs, MONO_MAX_IREGS + 1,
+ ip, NULL, regs, MONO_MAX_IREGS + 1,
save_locations, MONO_MAX_IREGS, &cfa);
new_ctx->eax = regs [X86_EAX];
/* Adjust IP */
new_ctx->eip --;
- 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 */
- 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) {
return TRUE;
}
-
+
if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip, NULL))) {
+ frame->ji = ji;
} else {
- if (!((guint32)((*lmf)->previous_lmf) & 1))
- /* Top LMF entry */
+ if (!(*lmf)->method)
return FALSE;
- g_assert_not_reached ();
- /* Trampoline lmf frame */
frame->method = (*lmf)->method;
}
/* Adjust IP */
new_ctx->eip --;
- frame->ji = ji;
frame->type = FRAME_TYPE_MANAGED_TO_NATIVE;
/* Check if we are in a trampoline LMF frame */
if ((guint32)((*lmf)->previous_lmf) & 1) {
/* lmf->esp is set by the trampoline code */
new_ctx->esp = (*lmf)->esp;
-
- /* Pop arguments off the stack */
- /* FIXME: Handle the delegate case too ((*lmf)->method == NULL) */
- /* FIXME: Handle the IMT/vtable case too */
-#if 0
-#ifndef ENABLE_LLVM
- if ((*lmf)->method) {
- MonoMethod *method = (*lmf)->method;
- MonoJitArgumentInfo *arg_info = g_newa (MonoJitArgumentInfo, mono_method_signature (method)->param_count + 1);
-
- guint32 stack_to_pop = mono_arch_get_argument_info (NULL, mono_method_signature (method), mono_method_signature (method)->param_count, arg_info);
- new_ctx->esp += stack_to_pop;
- }
-#endif
-#endif
}
else
/* the lmf is always stored on the stack, so the following
return FALSE;
}
-void
-mono_arch_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
-{
- mono_sigctx_to_monoctx (sigctx, mctx);
-}
-
-void
-mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
-{
- mono_monoctx_to_sigctx (mctx, sigctx);
-}
-
gpointer
mono_arch_ip_from_context (void *sigctx)
{
-#if defined(__native_client__)
+#if defined(__native_client__) || defined(HOST_WATCHOS)
printf("WARNING: mono_arch_ip_from_context() called!\n");
return (NULL);
-#else
-#ifdef MONO_ARCH_USE_SIGACTION
+#elif defined(MONO_ARCH_USE_SIGACTION)
ucontext_t *ctx = (ucontext_t*)sigctx;
return (gpointer)UCONTEXT_REG_EIP (ctx);
+#elif defined(HOST_WIN32)
+ return ((CONTEXT*)sigctx)->Eip;
#else
struct sigcontext *ctx = sigctx;
return (gpointer)ctx->SC_EIP;
#endif
-#endif /* __native_client__ */
}
/*
start = code = mono_global_codeman_reserve (128);
+ /* FIXME no unwind before we push ip */
/* Caller ip */
x86_push_reg (code, X86_ECX);
- mono_add_unwind_op_def_cfa (unwind_ops, (guint8*)NULL, (guint8*)NULL, X86_ESP, 4);
- mono_add_unwind_op_offset (unwind_ops, (guint8*)NULL, (guint8*)NULL, X86_NREG, -4);
+ mono_add_unwind_op_def_cfa (unwind_ops, code, start, X86_ESP, 4);
+ mono_add_unwind_op_offset (unwind_ops, code, start, X86_NREG, -4);
/* Fix the alignment to be what apple expects */
stack_size = 12;
g_slist_free (unwind_ops);
}
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
return start;
}
MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
/* Pass the ctx parameter in TLS */
- mono_arch_sigctx_to_monoctx (ctx, &jit_tls->ex_ctx);
+ mono_sigctx_to_monoctx (ctx, &jit_tls->ex_ctx);
mctx = jit_tls->ex_ctx;
mono_setup_async_callback (&mctx, handle_signal_exception, obj);
MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
struct sigcontext *ctx = (struct sigcontext *)sigctx;
- mono_arch_sigctx_to_monoctx (sigctx, &jit_tls->ex_ctx);
+ mono_sigctx_to_monoctx (sigctx, &jit_tls->ex_ctx);
mctx = jit_tls->ex_ctx;
mono_setup_async_callback (&mctx, handle_signal_exception, obj);
#else
MonoContext mctx;
- mono_arch_sigctx_to_monoctx (sigctx, &mctx);
+ mono_sigctx_to_monoctx (sigctx, &mctx);
mono_handle_exception (&mctx, obj);
- mono_arch_monoctx_to_sigctx (&mctx, sigctx);
+ mono_monoctx_to_sigctx (&mctx, sigctx);
return TRUE;
#endif
}
void
-mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean stack_ovf)
+mono_arch_handle_altstack_exception (void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *siginfo, gpointer fault_addr, gboolean stack_ovf)
{
#ifdef MONO_ARCH_USE_SIGACTION
MonoException *exc = NULL;
if (stack_ovf)
exc = mono_domain_get ()->stack_overflow_ex;
if (!ji)
- mono_handle_native_sigsegv (SIGSEGV, sigctx);
+ mono_handle_native_sigsegv (SIGSEGV, sigctx, siginfo);
/* setup a call frame on the real stack so that control is returned there
* and exception handling can continue.
* If this was a stack overflow the caller already ensured the stack pages
x86_mov_reg_membase (code, X86_EAX, X86_ESP, 8, 4);
/* setup the copy of the stack */
- x86_mov_reg_membase (code, X86_ECX, X86_EDX, G_STRUCT_OFFSET (MonoContinuation, stack_used_size), 4);
+ x86_mov_reg_membase (code, X86_ECX, X86_EDX, MONO_STRUCT_OFFSET (MonoContinuation, stack_used_size), 4);
x86_shift_reg_imm (code, X86_SHR, X86_ECX, 2);
x86_cld (code);
- x86_mov_reg_membase (code, X86_ESI, X86_EDX, G_STRUCT_OFFSET (MonoContinuation, saved_stack), 4);
- x86_mov_reg_membase (code, X86_EDI, X86_EDX, G_STRUCT_OFFSET (MonoContinuation, return_sp), 4);
+ x86_mov_reg_membase (code, X86_ESI, X86_EDX, MONO_STRUCT_OFFSET (MonoContinuation, saved_stack), 4);
+ x86_mov_reg_membase (code, X86_EDI, X86_EDX, MONO_STRUCT_OFFSET (MonoContinuation, return_sp), 4);
x86_prefix (code, X86_REP_PREFIX);
x86_movsl (code);
/* now restore the registers from the LMF */
- x86_mov_reg_membase (code, X86_ECX, X86_EDX, G_STRUCT_OFFSET (MonoContinuation, lmf), 4);
- x86_mov_reg_membase (code, X86_EBX, X86_ECX, G_STRUCT_OFFSET (MonoLMF, ebx), 4);
- x86_mov_reg_membase (code, X86_EBP, X86_ECX, G_STRUCT_OFFSET (MonoLMF, ebp), 4);
- x86_mov_reg_membase (code, X86_ESI, X86_ECX, G_STRUCT_OFFSET (MonoLMF, esi), 4);
- x86_mov_reg_membase (code, X86_EDI, X86_ECX, G_STRUCT_OFFSET (MonoLMF, edi), 4);
+ x86_mov_reg_membase (code, X86_ECX, X86_EDX, MONO_STRUCT_OFFSET (MonoContinuation, lmf), 4);
+ x86_mov_reg_membase (code, X86_EBX, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, ebx), 4);
+ x86_mov_reg_membase (code, X86_EBP, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, ebp), 4);
+ x86_mov_reg_membase (code, X86_ESI, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, esi), 4);
+ x86_mov_reg_membase (code, X86_EDI, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, edi), 4);
/* restore the lmf chain */
/*x86_mov_reg_membase (code, X86_ECX, X86_ESP, 12, 4);
x86_mov_membase_reg (code, X86_ECX, 0, X86_EDX, 4);*/
- x86_jump_membase (code, X86_EDX, G_STRUCT_OFFSET (MonoContinuation, return_ip));
+ x86_jump_membase (code, X86_EDX, MONO_STRUCT_OFFSET (MonoContinuation, return_ip));
g_assert ((code - start) <= 48);
saved = start;
return (MonoContinuationRestore)saved;