New tests.
[mono.git] / libgc / darwin_stop_world.c
index d3b94feb258c402830b94e3d3a200251073f41df..7e60fe790f53931eb85e99611c71f86a0a02757a 100644 (file)
@@ -2,6 +2,13 @@
 
 # if defined(GC_DARWIN_THREADS)
 
+#include <AvailabilityMacros.h>
+#include "mono/utils/mono-compiler.h"
+
+#ifdef MONO_DEBUGGER_SUPPORTED
+#include "include/libgc-mono-debugger.h"
+#endif
+
 /* From "Inside Mac OS X - Mach-O Runtime Architecture" published by Apple
    Page 49:
    "The space beneath the stack pointer, where a new stack frame would normally
@@ -82,6 +89,9 @@ void GC_push_all_stacks() {
 #elif defined(ARM)
   arm_thread_state_t state;
   mach_msg_type_number_t thread_state_count = ARM_THREAD_STATE_COUNT;
+#elif defined(X86_64)
+  x86_thread_state64_t state;
+  mach_msg_type_number_t thread_state_count = x86_THREAD_STATE64_COUNT;
 #else
 # error FIXME for non-x86 || ppc architectures
   mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT;
@@ -102,10 +112,11 @@ void GC_push_all_stacks() {
                             GC_MACH_THREAD_STATE_FLAVOR,
                             (natural_t*)&state,
                             &thread_state_count);
-       if(r != KERN_SUCCESS) ABORT("thread_get_state failed");
+       if(r != KERN_SUCCESS) continue;
        
 #if defined(I386)
-#if defined(_STRUCT_X86_EXCEPTION_STATE32)
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+
        lo = state.__esp;
 
        GC_push_one(state.__eax); 
@@ -126,6 +137,29 @@ void GC_push_all_stacks() {
        GC_push_one(state.esi); 
        GC_push_one(state.ebp); 
 #endif
+#elif defined(X86_64)
+          lo = state.__rsp;
+          GC_push_one(state.__rax);
+          GC_push_one(state.__rbx);
+          GC_push_one(state.__rcx);
+          GC_push_one(state.__rdx);
+          GC_push_one(state.__rdi);
+          GC_push_one(state.__rsi);
+          GC_push_one(state.__rbp);
+          GC_push_one(state.__rsp);
+          GC_push_one(state.__r8);
+          GC_push_one(state.__r9);
+          GC_push_one(state.__r10);
+          GC_push_one(state.__r11);
+          GC_push_one(state.__r12);
+          GC_push_one(state.__r13);
+          GC_push_one(state.__r14);
+          GC_push_one(state.__r15);
+          GC_push_one(state.__rip);
+          GC_push_one(state.__rflags);
+          GC_push_one(state.__cs);
+          GC_push_one(state.__fs);
+          GC_push_one(state.__gs);
 #elif defined(POWERPC)
 #if defined(_STRUCT_PPC_EXCEPTION_STATE)
        lo = (void*)(state.__r1 - PPC_RED_ZONE_SIZE);
@@ -350,7 +384,7 @@ void GC_push_all_stacks() {
                             (natural_t *)&info, &outCount);
        if(r != KERN_SUCCESS) continue;
 
-#if defined(_STRUCT_X86_EXCEPTION_STATE32)
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
        lo = (void*)info.__esp;
        hi = (ptr_t)FindTopOfStack(info.__esp);
 
@@ -682,4 +716,17 @@ void GC_darwin_register_mach_handler_thread(mach_port_t thread) {
   GC_use_mach_handler_thread = 1;
 }
 
+#ifdef MONO_DEBUGGER_SUPPORTED
+GCThreadFunctions *gc_thread_vtable = NULL;
+
+void *
+GC_mono_debugger_get_stack_ptr (void)
+{
+       GC_thread me;
+
+       me = GC_lookup_thread (pthread_self ());
+       return &me->stop_info.stack_ptr;
+}
+#endif
+
 #endif