*
* 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"
#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
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) {
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);
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;
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)
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;
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) {
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++;
}
}
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);
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));
}