#include "mono/metadata/profiler-private.h"
#include "mono/metadata/debug-helpers.h"
#include "mono/metadata/mono-debug.h"
+#include "mono/io-layer/io-layer.h"
#include <string.h>
#include <gmodule.h>
static MonoProfileFunc shutdown_callback;
+static CRITICAL_SECTION profiler_coverage_mutex;
+
/* this is directly accessible to other mono libs. */
MonoProfileFlags mono_profiler_events;
g_error ("profiler already setup");
current_profiler = prof;
shutdown_callback = callback;
+ InitializeCriticalSection (&profiler_coverage_mutex);
}
void
if (! (*coverage_filter_cb) (current_profiler, method))
return NULL;
+ EnterCriticalSection (&profiler_coverage_mutex);
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);
return res;
}
mono_profiler_coverage_free (MonoMethod *method)
{
MonoProfileCoverageInfo* info;
- if (!coverage_hash)
+
+ EnterCriticalSection (&profiler_coverage_mutex);
+ if (!coverage_hash) {
+ LeaveCriticalSection (&profiler_coverage_mutex);
return;
+ }
+
info = g_hash_table_lookup (coverage_hash, method);
- if (!info)
- return;
- g_free (info);
- g_hash_table_remove (coverage_hash, method);
+ if (info) {
+ g_free (info);
+ g_hash_table_remove (coverage_hash, method);
+ }
+ LeaveCriticalSection (&profiler_coverage_mutex);
}
void
MonoMethodHeader *header;
MonoProfileCoverageEntry entry;
+ EnterCriticalSection (&profiler_coverage_mutex);
info = g_hash_table_lookup (coverage_hash, method);
+ LeaveCriticalSection (&profiler_coverage_mutex);
+
if (!info)
return;
if (!(gint)(p->total*1000))
continue;
m = method_get_name (p->method);
- printf ("########################\n% 8.3f %7llu % 8.3f %s\n",
- (double)(p->total*1000), p->count, (double)(p->total*1000)/(double)p->count, m);
+ printf ("########################\n");
+ printf ("% 8.3f ", (double) (p->total * 1000));
+ printf ("%7llu ", p->count);
+ printf ("% 8.3f ", (double) (p->total * 1000)/(double)p->count);
+ printf (" %s\n", m);
+
g_free (m);
/* callers */
output_callers (p);
MethodProfile *mprof;
AllocInfo *talloc_info, *alloc_info;
CallerInfo *tcaller_info, *caller_info;
-
+
mprof = g_hash_table_lookup (prof->methods, method);
if (!mprof) {
/* the master thread didn't see this method, just transfer the info as is */
caller_info = mono_mempool_alloc0 (prof->mempool, sizeof (CallerInfo));
*caller_info = *tcaller_info;
caller_info->next = mprof->caller_info;
- mprof->caller_info = caller_info->next;
+ mprof->caller_info = caller_info;
}
}
}