#include "mono/metadata/mono-debug.h"
#include "mono/metadata/class-internals.h"
#include "mono/metadata/domain-internals.h"
+#include "mono/metadata/gc-internal.h"
#include "mono/io-layer/io-layer.h"
#include <string.h>
#include <sys/time.h>
static MonoProfileFunc shutdown_callback;
+static MonoProfileGCFunc gc_event;
+static MonoProfileGCResizeFunc gc_heap_resize;
+
static CRITICAL_SECTION profiler_coverage_mutex;
/* this is directly accessible to other mono libs. */
shutdown_callback (current_profiler);
}
+void
+mono_profiler_gc_heap_resize (gint64 new_size)
+{
+ if ((mono_profiler_events & MONO_PROFILE_GC) && gc_heap_resize)
+ gc_heap_resize (current_profiler, new_size);
+}
+
+void
+mono_profiler_gc_event (MonoGCEvent event, int generation)
+{
+ if ((mono_profiler_events & MONO_PROFILE_GC) && gc_event)
+ gc_event (current_profiler, event, generation);
+}
+
+void
+mono_profiler_install_gc (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback)
+{
+ mono_gc_enable_events ();
+ gc_event = callback;
+ gc_heap_resize = heap_resize_callback;
+}
+
static GHashTable *coverage_hash = NULL;
MonoProfileCoverageInfo*
{
char *sig, *res;
- sig = mono_signature_get_desc (method->signature, FALSE);
+ 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,
method->name, sig);
g_free (sig);
m = method_get_name (p->method);
printf ("########################\n");
printf ("% 8.3f ", (double) (p->total * 1000));
- printf ("%7llu ", p->count);
+ printf ("%7llu ", (unsigned long long)p->count);
printf ("% 8.3f ", (double) (p->total * 1000)/(double)p->count);
printf (" %s\n", m);
/* callers */
output_callers (p);
}
- printf ("Total number of calls: %lld\n", total_calls);
+ printf ("Total number of calls: %lld\n", (long long)total_calls);
}
typedef struct {
profile_info->alloc_info = tmp;
}
tmp->count++;
- if (klass == mono_defaults.string_class) {
- tmp->mem += sizeof (MonoString) + 2 * mono_string_length ((MonoString*)obj) + 2;
- } else if (klass->parent == mono_defaults.array_class) {
- tmp->mem += sizeof (MonoArray) + mono_array_element_size (klass) * mono_array_length ((MonoArray*)obj);
- } else {
- tmp->mem += mono_class_instance_size (klass);
- }
+ tmp->mem += mono_object_get_size (obj);
}
static void
FILE *pipein;
FILE *pipeout;
char *binary;
- GPid child_pid;
+ int child_pid;
};
static Addr2LineData *addr2line_pipes = NULL;
}
if (!addr2line) {
const char *addr_argv[] = {"addr2line", "-f", "-e", binary, NULL};
- GPid child_pid;
+ int child_pid;
int ch_in, ch_out;
if (!g_spawn_async_with_pipes (NULL, (char**)addr_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
&child_pid, &ch_in, &ch_out, NULL, NULL)) {
char *mn;
gpointer ip;
GList *tmp, *sorted = NULL;
+ int pcount = ++ prof_counts;
- prof_counts ++;
+ prof_counts = MAX_PROF_SAMPLES;
for (i = 0; i < count; ++i) {
ip = prof_addresses [i];
ji = mono_jit_info_table_find (mono_domain_get (), ip);
if (c > 1)
g_free (mn);
}
- g_print ("prof counts: total/unmanaged: %d/%d\n", prof_counts, prof_ucounts);
+ g_print ("prof counts: total/unmanaged: %d/%d\n", pcount, prof_ucounts);
g_hash_table_foreach (prof_table, (GHFunc)prof_foreach, &sorted);
for (tmp = sorted; tmp; tmp = tmp->next) {
double perc;
g_list_free (profile);
g_free (prof_addresses);
+ prof_addresses = NULL;
g_hash_table_destroy (prof_table);
}
{
MonoProfiler *prof;
gchar **args, **ptr;
- MonoProfileFlags flags = MONO_PROFILE_JIT_COMPILATION;
+ MonoProfileFlags flags = 0;
MONO_TIMER_STARTUP;
+ if (!desc)
+ desc = "alloc,time,jit";
+
if (desc) {
/* Parse options */
if (strstr (desc, ":"))
desc = strstr (desc, ":") + 1;
else
- desc = "alloc,time";
+ desc = "alloc,time,jit";
args = g_strsplit (desc, ",", -1);
for (ptr = args; ptr && *ptr; ptr++) {
flags |= MONO_PROFILE_ALLOCATIONS;
else if (!strcmp (arg, "stat"))
flags |= MONO_PROFILE_STATISTICAL | MONO_PROFILE_APPDOMAIN_EVENTS;
+ else if (!strcmp (arg, "jit"))
+ flags |= MONO_PROFILE_JIT_COMPILATION;
else {
fprintf (stderr, "profiler : Unknown argument '%s'.\n", arg);
return;