[threads] Move thread describe code to mono_thread_internal_describe (#3590)
authorLudovic Henry <ludovic@xamarin.com>
Tue, 20 Sep 2016 20:39:30 +0000 (22:39 +0200)
committerGitHub <noreply@github.com>
Tue, 20 Sep 2016 20:39:30 +0000 (22:39 +0200)
mono/metadata/threads-types.h
mono/metadata/threads.c
mono/mini/mini-exceptions.c
mono/utils/mono-threads-posix.c
mono/utils/mono-threads-windows.c
mono/utils/mono-threads.c
mono/utils/mono-threads.h

index 9da0dfc6c54eaeae50e985008b330b565bb1ab94..e1ea4217d01ccc6c2cabf5ee629176f451857e5e 100644 (file)
@@ -263,4 +263,7 @@ MonoException* mono_thread_try_resume_interruption (void);
 gboolean
 mono_thread_internal_current_is_attached (void);
 
+void
+mono_thread_internal_describe (MonoInternalThread *internal, GString *str);
+
 #endif /* _MONO_METADATA_THREADS_TYPES_H_ */
index 1965c3b4254ee32dbfe89d9b06750d1c14a958ef..3cdd6d58a29425ab1f3c47d727c34f0de9587e0a 100644 (file)
@@ -3384,7 +3384,7 @@ get_thread_dump (MonoThreadInfo *info, gpointer ud)
 #if 0
 /* This no longer works with remote unwinding */
        g_string_append_printf (text, " tid=0x%p this=0x%p ", (gpointer)(gsize)thread->tid, thread);
-       mono_thread_info_describe (info, text);
+       mono_thread_internal_describe (thread, text);
        g_string_append (text, "\n");
 #endif
 
@@ -5157,4 +5157,28 @@ mono_threads_is_ready_to_be_interrupted (void)
 
        UNLOCK_THREAD (thread);
        return TRUE;
-}
\ No newline at end of file
+}
+
+void
+mono_thread_internal_describe (MonoInternalThread *internal, GString *text)
+{
+       MonoThreadInfo *info;
+
+       g_string_append_printf (text, ", thread handle : %p", internal->handle);
+
+       info = (MonoThreadInfo*) internal->thread_info;
+       if (!info)
+               return;
+
+       g_string_append (text, ", state : ");
+       mono_thread_info_describe_interrupt_token (info, text);
+
+       if (info->owned_mutexes) {
+               int i;
+
+               g_string_append (text, ", owns : [");
+               for (i = 0; i < info->owned_mutexes->len; i++)
+                       g_string_append_printf (text, i == 0 ? "%p" : ", %p", g_ptr_array_index (info->owned_mutexes, i));
+               g_string_append (text, "]");
+       }
+}
index 265be946e51a8309da60e9c35721695acc315a7e..fa24b73f186132b30eb3d4b358664d3f59e2d4f6 100644 (file)
@@ -2504,7 +2504,7 @@ mono_print_thread_dump_internal (void *sigctx, MonoContext *start_ctx)
                g_string_append (text, "\n\"<unnamed thread>\"");
 
        g_string_append_printf (text, " tid=0x%p this=0x%p ", (gpointer)(gsize)thread->tid, thread);
-       mono_thread_info_describe ((MonoThreadInfo*) thread->thread_info, text);
+       mono_thread_internal_describe (thread, text);
        g_string_append (text, "\n");
 
 #ifdef MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX
index 4b9f5d393f5e79fb7ee9dc489f7fe8b00a0e7f69..53458ed6c7f5776aa6551679c83074f5f4ee20a8 100644 (file)
@@ -325,21 +325,6 @@ mono_threads_platform_set_exited (MonoThreadInfo *info)
        info->handle = NULL;
 }
 
-void
-mono_threads_platform_describe (MonoThreadInfo *info, GString *text)
-{
-       int i;
-
-       g_string_append_printf (text, "thread handle %p state : ", info->handle);
-
-       mono_thread_info_describe_interrupt_token (info, text);
-
-       g_string_append_printf (text, ", owns (");
-       for (i = 0; i < info->owned_mutexes->len; i++)
-               g_string_append_printf (text, i > 0 ? ", %p" : "%p", g_ptr_array_index (info->owned_mutexes, i));
-       g_string_append_printf (text, ")");
-}
-
 void
 mono_threads_platform_own_mutex (MonoThreadInfo *info, gpointer mutex_handle)
 {
index 4761af48d0c90507c6fc9433a6b882b05afb804f..65898d52303b9ca833bf02e91f01b482fb939e80 100644 (file)
@@ -317,12 +317,6 @@ mono_threads_platform_set_exited (MonoThreadInfo *info)
        info->handle = NULL;
 }
 
-void
-mono_threads_platform_describe (MonoThreadInfo *info, GString *text)
-{
-       /* TODO */
-}
-
 void
 mono_threads_platform_own_mutex (MonoThreadInfo *info, gpointer mutex_handle)
 {
index 2f07dbae1f1393f39fd62d5ac0a32d3eaae39864..d0c7fa1040ed7ecd39e64967b395e2d85c1ac076 100644 (file)
@@ -1662,12 +1662,6 @@ mono_thread_info_duplicate_handle (MonoThreadInfo *info)
        return mono_threads_platform_duplicate_handle (info);
 }
 
-void
-mono_thread_info_describe (MonoThreadInfo *info, GString *text)
-{
-       mono_threads_platform_describe (info, text);
-}
-
 void
 mono_thread_info_own_mutex (MonoThreadInfo *info, gpointer mutex_handle)
 {
index 493d44884ca49f564d9f9f057479bf082645848a..3091b1a17c9371a3976cee87a8c91769439c112d 100644 (file)
@@ -242,10 +242,8 @@ typedef struct {
        /* Stack mark for targets that explicitly require one */
        gpointer stack_mark;
 
-#if defined(_POSIX_VERSION) || defined(__native_client__)
-       /* This is the data that was stored in the w32 handle */
+       /* FIXME: move to MonoInternalThread */
        GPtrArray *owned_mutexes;
-#endif
 } MonoThreadInfo;
 
 typedef struct {
@@ -528,7 +526,6 @@ void mono_threads_platform_exit (int exit_code);
 HANDLE mono_threads_platform_open_thread_handle (HANDLE handle, MonoNativeThreadId tid);
 void mono_threads_platform_close_thread_handle (HANDLE handle);
 void mono_threads_platform_set_exited (THREAD_INFO_TYPE *info);
-void mono_threads_platform_describe (THREAD_INFO_TYPE *info, GString *text);
 void mono_threads_platform_own_mutex (THREAD_INFO_TYPE *info, gpointer mutex_handle);
 void mono_threads_platform_disown_mutex (THREAD_INFO_TYPE *info, gpointer mutex_handle);
 gpointer mono_threads_platform_duplicate_handle (THREAD_INFO_TYPE *info);
@@ -649,9 +646,6 @@ mono_thread_info_is_current (THREAD_INFO_TYPE *info);
 gpointer
 mono_thread_info_duplicate_handle (THREAD_INFO_TYPE *info);
 
-void
-mono_thread_info_describe (THREAD_INFO_TYPE *info, GString *text);
-
 void
 mono_thread_info_own_mutex (THREAD_INFO_TYPE *info, gpointer mutex_handle);