Merge pull request #2816 from xmcclure/profile-clean-0
[mono.git] / mono / io-layer / wthreads.c
index c9c8a907240d84b4aa2d9e00d76dd563954fbef3..304fd35adf807e349c77529ee2813686d0e6553a 100644 (file)
@@ -7,6 +7,7 @@
  * (C) 2002-2006 Ximian, Inc.
  * Copyright 2003-2011 Novell, Inc (http://www.novell.com)
  * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include <config.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/thread-private.h>
 #include <mono/io-layer/mutex-private.h>
+#include <mono/io-layer/io-trace.h>
 
 #include <mono/utils/mono-threads.h>
 #include <mono/utils/atomic.h>
 #include <mono/utils/mono-time.h>
 #include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
 
 #ifdef HAVE_VALGRIND_MEMCHECK_H
 #include <valgrind/memcheck.h>
 #endif
 
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
-
-#if 0
-#define WAIT_DEBUG(code) do { code } while (0)
-#else
-#define WAIT_DEBUG(code) do { } while (0)
-#endif
-
 struct _WapiHandleOps _wapi_thread_ops = {
        NULL,                           /* close */
        NULL,                           /* signal */
@@ -126,11 +117,11 @@ wapi_thread_handle_set_exited (gpointer handle, guint32 exitstatus)
                return;
        }
 
-       DEBUG ("%s: Thread %p terminating", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Thread %p terminating", __func__, handle);
 
        thread_handle = lookup_thread (handle);
 
-       DEBUG ("%s: Thread %p abandoning held mutexes", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Thread %p abandoning held mutexes", __func__, handle);
 
        for (i = 0; i < thread_handle->owned_mutexes->len; i++) {
                gpointer mutex = g_ptr_array_index (thread_handle->owned_mutexes, i);
@@ -148,7 +139,7 @@ wapi_thread_handle_set_exited (gpointer handle, guint32 exitstatus)
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
        
-       DEBUG("%s: Recording thread handle %p id %ld status as %d",
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Recording thread handle %p id %ld status as %d",
                  __func__, handle, thread_handle->id, exitstatus);
        
        /* The thread is no longer active, so unref it */
@@ -188,7 +179,7 @@ wapi_create_thread_handle (void)
         */
        _wapi_handle_ref (handle);
 
-       DEBUG ("%s: started thread id %ld", __func__, thread->id);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: started thread id %ld", __func__, thread->id);
        
        return handle;
 }