New mach support code to support setting thread context.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 28 Apr 2011 06:51:37 +0000 (03:51 -0300)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 28 Apr 2011 06:54:08 +0000 (03:54 -0300)
* mach-support.h: Add mono_mach_arch_mcontext_to_thread_state
and mono_mach_arch_set_thread_state.

* mach-support-x86.c:
* mach-support-amd64.c:
* mach-support-arm.c: Implement arch specific versions of those
new functions.

mono/utils/mach-support-amd64.c
mono/utils/mach-support-arm.c
mono/utils/mach-support-x86.c
mono/utils/mach-support.h

index 7c4e6112ef2d42ea9bf293ef37278147bfbc2a49..4fe13c94b8887523fe18f16d79660232070f1431 100644 (file)
@@ -47,6 +47,15 @@ mono_mach_arch_thread_state_to_mcontext (thread_state_t state, mcontext_t contex
        ctx->__ss = *arch_state;
 }
 
+void
+mono_mach_arch_mcontext_to_thread_state (mcontext_t context, thread_state_t state)
+{
+       x86_thread_state64_t *arch_state = (x86_thread_state64_t *) state;
+       struct __darwin_mcontex64 *ctx = (struct __darwin_mcontex64 *) context;
+
+       *arch_state = ctx->__ss;
+}
+
 int
 mono_mach_arch_get_thread_state_size ()
 {
@@ -66,6 +75,12 @@ mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mac
        return ret;
 }
 
+kern_return_t
+mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count)
+{
+       return thread_set_state (thread, x86_THREAD_STATE64, state, count);
+}
+
 void *
 mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key)
 {
index 51a07bd88e81d421943f4c202d3d782e1687f6c9..edef2b37196a3da0cabd950cbc3ce0cc055d4da2 100644 (file)
@@ -47,6 +47,15 @@ mono_mach_arch_thread_state_to_mcontext (thread_state_t state, mcontext_t contex
        ctx->__ss = *arch_state;
 }
 
+void
+mono_mach_arch_mcontext_to_thread_state (mcontext_t context, thread_state_t state)
+{
+       arm_thread_state_t *arch_state = (arm_thread_state_t *) state;
+       struct __darwin_mcontext *ctx = (struct __darwin_mcontext *) context;
+
+       *arch_state = ctx->__ss;
+}
+
 int
 mono_mach_arch_get_thread_state_size ()
 {
@@ -66,6 +75,12 @@ mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mac
        return ret;
 }
 
+kern_return_t
+mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count)
+{
+       return thread_set_state (thread, ARM_THREAD_STATE_COUNT, state, count);
+}
+
 void *
 mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key)
 {
index 40fde645a052ee51a98076186e766b90025acd75..aac2fb2b4abcab6e849e79d4d9ed8734bbcd52b6 100644 (file)
@@ -47,6 +47,15 @@ mono_mach_arch_thread_state_to_mcontext (thread_state_t state, mcontext_t contex
        ctx->__ss = *arch_state;
 }
 
+void
+mono_mach_arch_mcontext_to_thread_state (mcontext_t context, thread_state_t state)
+{
+       x86_thread_state32_t *arch_state = (x86_thread_state32_t *) state;
+       struct __darwin_mcontext32 *ctx = (struct __darwin_mcontext32 *) context;
+
+       *arch_state = ctx->__ss;
+}
+
 int
 mono_mach_arch_get_thread_state_size ()
 {
@@ -66,6 +75,12 @@ mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mac
        return ret;
 }
 
+kern_return_t
+mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count)
+{
+       return thread_set_state (thread, x86_THREAD_STATE32, state, count);
+}
+
 void *
 mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key)
 {
index 5bc6bbb3625df4cf797c0f59fd3525584d591e79..ff7ea5bbc51a3f40ca1511ca824b06bd52d348e0 100644 (file)
@@ -25,11 +25,13 @@ void *mono_mach_arch_get_sp (thread_state_t state) MONO_INTERNAL;
 
 int mono_mach_arch_get_mcontext_size (void) MONO_INTERNAL;
 void mono_mach_arch_thread_state_to_mcontext (thread_state_t state, mcontext_t context) MONO_INTERNAL;
+void mono_mach_arch_mcontext_to_thread_state (mcontext_t context, thread_state_t state) MONO_INTERNAL;
 
 int mono_mach_arch_get_thread_state_size (void) MONO_INTERNAL;
 kern_return_t mono_mach_get_threads (thread_act_array_t *threads, guint32 *count) MONO_INTERNAL;
 kern_return_t mono_mach_free_threads (thread_act_array_t threads, guint32 count) MONO_INTERNAL;
 kern_return_t mono_mach_arch_get_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t *count) MONO_INTERNAL;
+kern_return_t mono_mach_arch_set_thread_state (thread_port_t thread, thread_state_t state, mach_msg_type_number_t count) MONO_INTERNAL;
 void *mono_mach_arch_get_tls_value_from_thread (pthread_t thread, guint32 key) MONO_INTERNAL;
 
 #endif