Merge pull request #2816 from xmcclure/profile-clean-0
[mono.git] / mono / profiler / mono-profiler-iomap.c
index bc0dd2c1b65cc1ad70d71a62ae54332c18750afa..445e1bf1f893cab64898eed096e0c072ea009b1e 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Note: this profiler is completely unsafe wrt handling managed objects,
  * don't use and don't copy code from here.
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 #include "config.h"
 
@@ -23,7 +24,7 @@
 #include <mono/metadata/threads.h>
 #include <mono/metadata/profiler.h>
 #include <mono/metadata/loader.h>
-#include <mono/utils/mono-mutex.h>
+#include <mono/utils/mono-os-mutex.h>
 
 #define LOCATION_INDENT "        "
 #define BACKTRACE_SIZE 64
@@ -112,7 +113,7 @@ static void mismatched_stats_foreach_func (gpointer key, gpointer value, gpointe
                return;
        }
 
-       location = g_hash_table_lookup (prof->string_locations_hash, &hash);
+       location = (StringLocation *)g_hash_table_lookup (prof->string_locations_hash, &hash);
        while (location) {
                if (location->hint && strlen (location->hint) > 0) {
                        if (!bannerShown) {
@@ -195,7 +196,7 @@ static inline void print_report (const gchar *format, ...)
        vfprintf (stdout, format, ap);
        fprintf (stdout, "\n");
        va_end (ap);
-       klass = mono_class_from_name (mono_get_corlib (), "System", "Environment");
+       klass = mono_class_load_from_name (mono_get_corlib (), "System", "Environment");
        mono_class_init (klass);
        prop = mono_class_get_property_from_name (klass, "StackTrace");
        str = (MonoString*)mono_property_get_value (prop, NULL, NULL, NULL);
@@ -243,7 +244,7 @@ static gboolean saved_strings_find_func (gpointer key, gpointer value, gpointer
 
 static inline void store_string_location (MonoProfiler *prof, const gchar *string, guint32 hash, size_t len)
 {
-       StringLocation *location = g_hash_table_lookup (prof->string_locations_hash, &hash);
+       StringLocation *location = (StringLocation *)g_hash_table_lookup (prof->string_locations_hash, &hash);
        SavedString *saved;
        SavedStringFindInfo info;
        guint32 *hashptr;
@@ -461,7 +462,7 @@ static void mono_portability_remember_string (MonoProfiler *prof, MonoDomain *do
                return;
        }
 
-       mono_mutex_lock (&mismatched_files_section);
+       mono_os_mutex_lock (&mismatched_files_section);
        head = (SavedString*)g_hash_table_lookup (prof->saved_strings_hash, (gpointer)str);
        if (head) {
                while (head->next)
@@ -469,7 +470,7 @@ static void mono_portability_remember_string (MonoProfiler *prof, MonoDomain *do
                head->next = entry;
        } else
                g_hash_table_insert (prof->saved_strings_hash, (gpointer)str, (gpointer)entry);
-       mono_mutex_unlock (&mismatched_files_section);
+       mono_os_mutex_unlock (&mismatched_files_section);
 }
 
 static MonoClass *string_class = NULL;
@@ -489,7 +490,7 @@ static void mono_portability_iomap_event (MonoProfiler *prof, const char *report
        if (!runtime_initialized)
                return;
 
-       mono_mutex_lock (&mismatched_files_section);
+       mono_os_mutex_lock (&mismatched_files_section);
        hash = calc_strings_hash (pathname, new_pathname, &pathnameHash);
        stats = (MismatchedFilesStats*)g_hash_table_lookup (prof->mismatched_files_hash, &hash);
        if (stats == NULL) {
@@ -507,11 +508,11 @@ static void mono_portability_iomap_event (MonoProfiler *prof, const char *report
                        g_error ("Out of memory allocating integer pointer for mismatched files hash table.");
 
                store_string_location (prof, (const gchar*)stats->requestedName, pathnameHash, strlen (stats->requestedName));
-               mono_mutex_unlock (&mismatched_files_section);
+               mono_os_mutex_unlock (&mismatched_files_section);
 
                print_report ("%s -     Found file path: '%s'\n", report, new_pathname);
        } else {
-               mono_mutex_unlock (&mismatched_files_section);
+               mono_os_mutex_unlock (&mismatched_files_section);
                stats->count++;
        }
 }
@@ -525,14 +526,14 @@ static void runtime_initialized_cb (MonoProfiler *prof)
 static void profiler_shutdown (MonoProfiler *prof)
 {
        print_mismatched_stats (prof);
-       mono_mutex_destroy (&mismatched_files_section);
+       mono_os_mutex_destroy (&mismatched_files_section);
 }
 
 void mono_profiler_startup (const char *desc)
 {
        MonoProfiler *prof = g_new0 (MonoProfiler, 1);
 
-       mono_mutex_init (&mismatched_files_section);
+       mono_os_mutex_init (&mismatched_files_section);
        prof->mismatched_files_hash = g_hash_table_new (mismatched_files_guint32_hash, mismatched_files_guint32_equal);
        prof->saved_strings_hash = g_hash_table_new (NULL, NULL);
        prof->string_locations_hash = g_hash_table_new (mismatched_files_guint32_hash, mismatched_files_guint32_equal);
@@ -542,5 +543,5 @@ void mono_profiler_startup (const char *desc)
        mono_profiler_install_iomap (mono_portability_iomap_event);
        mono_profiler_install_allocation (mono_portability_remember_alloc);
 
-       mono_profiler_set_events (MONO_PROFILE_ALLOCATIONS | MONO_PROFILE_IOMAP_EVENTS);
+       mono_profiler_set_events ((MonoProfileFlags)(MONO_PROFILE_ALLOCATIONS | MONO_PROFILE_IOMAP_EVENTS));
 }