static MonoProfileGCFunc gc_event;
static MonoProfileGCResizeFunc gc_heap_resize;
+#define mono_profiler_coverage_lock() EnterCriticalSection (&profiler_coverage_mutex)
+#define mono_profiler_coverage_unlock() LeaveCriticalSection (&profiler_coverage_mutex)
static CRITICAL_SECTION profiler_coverage_mutex;
/* this is directly accessible to other mono libs. */
if (! (*coverage_filter_cb) (current_profiler, method))
return NULL;
- EnterCriticalSection (&profiler_coverage_mutex);
+ mono_profiler_coverage_lock ();
if (!coverage_hash)
coverage_hash = g_hash_table_new (NULL, NULL);
res->entries = entries;
g_hash_table_insert (coverage_hash, method, res);
- LeaveCriticalSection (&profiler_coverage_mutex);
+ mono_profiler_coverage_unlock ();
return res;
}
{
MonoProfileCoverageInfo* info;
- EnterCriticalSection (&profiler_coverage_mutex);
+ mono_profiler_coverage_lock ();
if (!coverage_hash) {
- LeaveCriticalSection (&profiler_coverage_mutex);
+ mono_profiler_coverage_unlock ();
return;
}
g_free (info);
g_hash_table_remove (coverage_hash, method);
}
- LeaveCriticalSection (&profiler_coverage_mutex);
+ mono_profiler_coverage_unlock ();
}
void
MonoMethodHeader *header;
MonoProfileCoverageEntry entry;
- EnterCriticalSection (&profiler_coverage_mutex);
+ mono_profiler_coverage_lock ();
info = g_hash_table_lookup (coverage_hash, method);
- LeaveCriticalSection (&profiler_coverage_mutex);
+ mono_profiler_coverage_unlock ();
if (!info)
return;
struct _AllocInfo {
AllocInfo *next;
MonoClass *klass;
- guint count;
- guint mem;
+ guint64 count;
+ guint64 mem;
};
struct _CallerInfo {
char *sig, *res;
sig = mono_signature_get_desc (mono_method_signature (method), FALSE);
- res = g_strdup_printf ("%s.%s::%s(%s)", method->klass->name_space, method->klass->name,
+ res = g_strdup_printf ("%s%s%s::%s(%s)", method->klass->name_space,
+ method->klass->name_space ? "." : "", method->klass->name,
method->name, sig);
g_free (sig);
return res;
typedef struct {
MethodProfile *mp;
- guint count;
+ guint64 count;
} NewobjProfile;
static gint
compare_newobj_profile (NewobjProfile *profa, NewobjProfile *profb)
{
- return (gint)profb->count - (gint)profa->count;
+ if (profb->count == profa->count)
+ return 0;
+ else
+ return profb->count > profa->count ? 1 : -1;
}
static void
{
NewobjProfile *prof = g_new (NewobjProfile, 1);
AllocInfo *tmp;
- guint count = 0;
+ guint64 count = 0;
prof->mp = mprof;
/* we use the total amount of memory to sort */
}
}
+/* This isn't defined on older glib versions and on some platforms */
+#ifndef G_GUINT64_FORMAT
+#define G_GUINT64_FORMAT "ul"
+#endif
+
static void
output_newobj_profile (GList *proflist)
{
const char* isarray;
char buf [256];
char *m;
- guint total = 0;
+ guint64 total = 0;
GSList *sorted, *tmps;
g_print ("\nAllocation profiler\n");
continue;
mp = p->mp;
m = method_get_name (mp->method);
- g_print ("########################\n%8d KB %s\n", p->count / 1024, m);
+ g_print ("########################\n%8" G_GUINT64_FORMAT " KB %s\n", (p->count / 1024), m);
g_free (m);
sorted = sort_alloc_list (mp->alloc_info);
for (tmps = sorted; tmps; tmps = tmps->next) {
} else {
isarray = "";
}
- g_snprintf (buf, sizeof (buf), "%s.%s%s",
- klass->name_space, klass->name, isarray);
- g_print (" %8d KB %8d %-48s\n", ainfo->mem / 1024, ainfo->count, buf);
+ g_snprintf (buf, sizeof (buf), "%s%%s%s",
+ klass->name_space, klass->name_space ? "." : "", klass->name, isarray);
+ g_print (" %8" G_GUINT64_FORMAT " KB %8" G_GUINT64_FORMAT " %-48s\n", (ainfo->mem / 1024), ainfo->count, buf);
}
/* callers */
output_callers (mp);
}
- g_print ("Total memory allocated: %d KB\n", total / 1024);
+ g_print ("Total memory allocated: %" G_GUINT64_FORMAT " KB\n", total / 1024);
}
static void