* Marek Habersack <mhabersack@novell.com>
*
* Copyright (c) 2009 Novell, Inc (http://novell.com)
+ *
+ * Note: this profiler is completely unsafe wrt handling managed objects,
+ * don't use and don't copy code from here.
*/
#include "config.h"
#include <mono/metadata/threads.h>
#include <mono/metadata/profiler.h>
#include <mono/metadata/loader.h>
-#include <mono/io-layer/mono-mutex.h>
+#include <mono/utils/mono-mutex.h>
#define LOCATION_INDENT " "
#define BACKTRACE_SIZE 64
static inline void append_report (GString **report, const gchar *format, ...)
{
-#if GLIB_CHECK_VERSION(2,14,0)
+#if defined (_EGLIB_MAJOR) || GLIB_CHECK_VERSION(2,14,0)
va_list ap;
if (!*report)
*report = g_string_new ("");
gchar *utf_str;
guint32 hash;
- if (!info || !saved || saved->string->length != info->len)
+ if (!info || !saved || mono_string_length (saved->string) != info->len)
return FALSE;
utf_str = mono_string_to_utf8 (saved->string);
mono_mutex_unlock (&mismatched_files_section);
}
+static MonoClass *string_class = NULL;
+
+static void mono_portability_remember_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
+{
+ if (klass != string_class)
+ return;
+ mono_portability_remember_string (prof, mono_object_get_domain (obj), (MonoString*)obj);
+}
+
static void mono_portability_iomap_event (MonoProfiler *prof, const char *report, const char *pathname, const char *new_pathname)
{
guint32 hash, pathnameHash;
static void runtime_initialized_cb (MonoProfiler *prof)
{
runtime_initialized = TRUE;
+ string_class = mono_get_string_class ();
}
static void profiler_shutdown (MonoProfiler *prof)
{
MonoProfiler *prof = g_new0 (MonoProfiler, 1);
- mono_mutex_init (&mismatched_files_section, NULL);
+ mono_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 (prof, profiler_shutdown);
mono_profiler_install_runtime_initialized (runtime_initialized_cb);
mono_profiler_install_iomap (mono_portability_iomap_event);
- mono_profiler_install_string_allocation (mono_portability_remember_string);
+ mono_profiler_install_allocation (mono_portability_remember_alloc);
- mono_profiler_set_events (MONO_PROFILE_STRING_ALLOC | MONO_PROFILE_IOMAP_EVENTS);
+ mono_profiler_set_events (MONO_PROFILE_ALLOCATIONS | MONO_PROFILE_IOMAP_EVENTS);
}