Merge pull request #4621 from alexanderkyte/strdup_env
[mono.git] / mono / metadata / lock-tracer.c
index ab39f393b58a42346754d3fb1e90b8d759c7e240..bda05487d5fde39a960e535e54c5e513a8e9b18d 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * lock-tracer.c: Runtime simple lock tracer
+/**
+ * \file
+ * Runtime simple lock tracer
  *
  * Authors:
  *     Rodrigo Kumpera (rkumpera@novell.com)
 #include <execinfo.h>
 #endif
 
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/mono-compiler.h>
 
 #include "lock-tracer.h"
 
-
 /*
  * This is a very simple lock trace implementation. It can be used to verify that the runtime is
  * correctly following all locking rules.
  * 
  * To log more kind of locks just do the following:
  *     - add an entry into the RuntimeLocks enum
- *  - change mono_mutex_lock(mutex) to mono_locks_acquire (mutex, LockName)
- *  - change mono_mutex_unlock to mono_locks_release (mutex, LockName)
+ *  - change mono_os_mutex_lock(mutex) to mono_locks_os_acquire (mutex, LockName)
+ *  - change mono_os_mutex_unlock(mutex) to mono_locks_os_release (mutex, LockName)
+ *  - change mono_coop_mutex_lock(mutex) to mono_locks_coop_acquire (mutex, LockName)
+ *  - change mono_coop_mutex_unlock(mutex) to mono_locks_coop_release (mutex, LockName)
  *  - change the decoder to understand the new lock kind.
  *
  * TODO:
@@ -71,9 +73,11 @@ mono_locks_tracer_init (void)
        Dl_info info;
        int res;
        char *name;
-       mono_mutex_init_recursive (&tracer_lock);
-       if (!g_getenv ("MONO_ENABLE_LOCK_TRACER"))
+       mono_os_mutex_init_recursive (&tracer_lock);
+
+       if (!g_hasenv ("MONO_ENABLE_LOCK_TRACER"))
                return;
+
        name = g_strdup_printf ("locks.%d", getpid ());
        trace_file = fopen (name, "w+");
        g_free (name);
@@ -139,5 +143,7 @@ mono_locks_lock_released (RuntimeLocks kind, gpointer lock)
 {
        add_record (RECORD_LOCK_RELEASED, kind, lock);
 }
+#else
 
-#endif
+MONO_EMPTY_SOURCE_FILE (lock_tracer);
+#endif /* LOCK_TRACER */