From ed8c7cea9a837b32a2793dea06230d616ce9ac98 Mon Sep 17 00:00:00 2001 From: Geoff Norton Date: Thu, 28 Aug 2008 20:46:26 +0000 Subject: [PATCH] 2008-08-28 Geoff Norton * darwin_stop_world.c: * include/private/gcconfig.h: Add support for Darwin/ARM svn path=/trunk/mono/; revision=111873 --- ChangeLog | 5 ++++ darwin_stop_world.c | 54 ++++++++++++++++++++++++++++++++++++-- include/private/gcconfig.h | 22 +++++++++++++--- 3 files changed, 76 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4cf4cd88..4ff0f0df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-08-28 Geoff Norton + + * darwin_stop_world.c: + * include/private/gcconfig.h: Add support for Darwin/ARM + 2008-08-12 Geoff Norton * pthread_support.c: GCC shipped with SLES9 ppc gets confused with our current diff --git a/darwin_stop_world.c b/darwin_stop_world.c index 20f3fc76..d3b94feb 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -79,6 +79,9 @@ void GC_push_all_stacks() { #elif defined(I386) i386_thread_state_t state; mach_msg_type_number_t thread_state_count = i386_THREAD_STATE_COUNT; +#elif defined(ARM) + arm_thread_state_t state; + mach_msg_type_number_t thread_state_count = ARM_THREAD_STATE_COUNT; #else # error FIXME for non-x86 || ppc architectures mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT; @@ -193,6 +196,26 @@ void GC_push_all_stacks() { GC_push_one(state.r30); GC_push_one(state.r31); #endif +#elif defined(ARM) + lo = (void*)state.__sp; + + GC_push_one(state.__r[0]); + GC_push_one(state.__r[1]); + GC_push_one(state.__r[2]); + GC_push_one(state.__r[3]); + GC_push_one(state.__r[4]); + GC_push_one(state.__r[5]); + GC_push_one(state.__r[6]); + GC_push_one(state.__r[7]); + GC_push_one(state.__r[8]); + GC_push_one(state.__r[9]); + GC_push_one(state.__r[10]); + GC_push_one(state.__r[11]); + GC_push_one(state.__r[12]); + /* GC_push_one(state.__sp); */ + GC_push_one(state.__lr); + GC_push_one(state.__pc); + GC_push_one(state.__cpsr); #else # error FIXME for non-x86 || ppc architectures #endif @@ -318,7 +341,7 @@ void GC_push_all_stacks() { GC_push_one(info.r30); GC_push_one(info.r31); #endif -# else +# elif defined(I386) /* !POWERPC */ /* FIXME: Remove after testing: */ WARN("This is completely untested and likely will not work\n", 0); i386_thread_state_t info; @@ -366,7 +389,34 @@ void GC_push_all_stacks() { GC_push_one(info.fs); GC_push_one(info.gs); #endif -# endif /* !POWERPC */ +# elif defined(ARM) /* !I386 */ + arm_thread_state_t info; + mach_msg_type_number_t outCount = THREAD_STATE_MAX; + r = thread_get_state(thread, GC_MACH_THREAD_STATE_FLAVOR, + (natural_t *)&info, &outCount); + if(r != KERN_SUCCESS) continue; + + lo = (void*)info.__sp; + hi = (ptr_t)FindTopOfStack(info.__sp); + + GC_push_one(info.__r[0]); + GC_push_one(info.__r[1]); + GC_push_one(info.__r[2]); + GC_push_one(info.__r[3]); + GC_push_one(info.__r[4]); + GC_push_one(info.__r[5]); + GC_push_one(info.__r[6]); + GC_push_one(info.__r[7]); + GC_push_one(info.__r[8]); + GC_push_one(info.__r[9]); + GC_push_one(info.__r[10]); + GC_push_one(info.__r[11]); + GC_push_one(info.__r[12]); + /* GC_push_one(info.__sp); */ + GC_push_one(info.__lr); + GC_push_one(info.__pc); + GC_push_one(info.__cpsr); +# endif /* !ARM */ } # if DEBUG_THREADS GC_printf3("Darwin: Stack for thread 0x%lx = [%lx,%lx)\n", diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 11aee131..ba9ca71a 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -59,10 +59,15 @@ # define FREEBSD # endif +/* And one for Darwin: */ +# if defined(macosx) || (defined(__APPLE__) && defined(__MACH__)) +# define DARWIN +# endif + /* Determine the machine type: */ # if defined(__arm__) || defined(__thumb__) # define ARM32 -# if !defined(LINUX) && !defined(NETBSD) +# if !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN) # define NOSYS # define mach_type_known # endif @@ -297,8 +302,7 @@ # define MACOS # define mach_type_known # endif -# if defined(macosx) || (defined(__APPLE__) && defined(__MACH__)) -# define DARWIN +# ifdef DARWIN # if defined(__ppc__) || defined(__ppc64__) # define POWERPC # define mach_type_known @@ -326,6 +330,10 @@ /* There seems to be some issues with trylock hanging on darwin. This should be looked into some more */ # define NO_PTHREAD_TRYLOCK +# elif defined(__arm__) +# define ARM +# define mach_type_known +# define DARWIN_DONT_PARSE_STACK # endif # endif # if defined(NeXT) && defined(mc68000) @@ -1883,6 +1891,14 @@ # define OS_TYPE "MSWINCE" # define DATAEND /* not needed */ # endif +# ifdef DARWIN +# define OS_TYPE "DARWIN" +# define DATASTART ((ptr_t) get_etext()) +# define DATAEND ((ptr_t) get_end()) +# define STACKBOTTOM ((ptr_t) 0x30000000) +# undef USE_MMAP +# undef USE_MUNMAP +# endif # ifdef NOSYS /* __data_start is usually defined in the target linker script. */ extern int __data_start[]; -- 2.40.0