*
*
* Copyright (c) 2011 Novell, Inc (http://www.novell.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <signal.h>
#endif
-#if defined (HOST_WATCHOS) || defined (HOST_APPLETVOS)
-#include <libunwind.h>
-#endif
-
/*
* General notes about mono-context.
* Each arch defines a MonoContext struct with all GPR regs + IP/PC.
#if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
defined(__FreeBSD__) || defined(__OpenBSD__)
#ifdef HAVE_SIGACTION
-#define MONO_SIGNAL_USE_SIGACTION 1
+#define MONO_SIGNAL_USE_UCONTEXT_T 1
#endif
#endif
#if defined(__native_client__)
-#undef MONO_SIGNAL_USE_SIGACTION
+#undef MONO_SIGNAL_USE_UCONTEXT_T
#endif
#ifdef HOST_WIN32
#if !defined( HOST_WIN32 ) && !defined(__native_client__) && !defined(__native_client_codegen__)
#ifdef HAVE_SIGACTION
-#define MONO_SIGNAL_USE_SIGACTION 1
+#define MONO_SIGNAL_USE_UCONTEXT_T 1
#endif
#endif
#if defined(HOST_WATCHOS)
#define MONO_CONTEXT_GET_CURRENT(ctx) do { \
- unw_context_t uctx; \
- unw_cursor_t c; \
- unw_word_t data; \
- g_assert (unw_getcontext (&uctx) == 0); \
- g_assert (unw_init_local (&c, &uctx) == 0); \
- for (int reg = 0; reg < 13; ++reg) { \
- unw_get_reg (&c, (unw_regnum_t) UNW_ARM_R0 + reg, &data); \
- ctx.regs[reg] = data; \
- } \
- unw_get_reg (&c, UNW_ARM_SP, &data); \
- ctx.regs[ARMREG_SP] = data; \
- unw_get_reg (&c, UNW_ARM_LR, &data); \
- ctx.regs[ARMREG_LR] = data; \
- unw_get_reg (&c, UNW_ARM_IP, &data); \
- ctx.regs[ARMREG_PC] = data; \
- ctx.pc = ctx.regs[ARMREG_PC]; \
- for (int reg = 0; reg < 16; ++reg) { \
- unw_get_reg (&c, (unw_regnum_t) UNW_ARM_D0 + reg, &data); \
- ctx.fregs[reg] = data; \
- } \
} while (0);
#else
#if defined (HOST_APPLETVOS)
#define MONO_CONTEXT_GET_CURRENT(ctx) do { \
- fprintf (stderr, "MONO_CONTEXT_GET_CURRENT: Not implemented"); \
- g_error ("MONO_CONTEXT_GET_CURRENT: Not implemented"); \
+ arm_unified_thread_state_t thread_state; \
+ int state_flavor = ARM_UNIFIED_THREAD_STATE; \
+ unsigned state_count = ARM_UNIFIED_THREAD_STATE_COUNT; \
+ thread_port_t self = mach_thread_self (); \
+ kern_return_t ret = thread_get_state (self, state_flavor, (thread_state_t) &thread_state, &state_count); \
+ g_assert (ret == 0); \
+ mono_mach_arch_thread_state_to_mono_context ((thread_state_t)&thread_state, &ctx); \
+ mach_port_deallocate (current_task (), self); \
} while (0);
#else