1 #include <mono/metadata/profiler.h>
2 #include <mono/metadata/mono-gc.h>
3 #include <mono/metadata/debug-helpers.h>
14 #define BUFFER_SIZE (4096 * 16)
15 static int nocalls = 0;
16 static int notraces = 0;
17 static int use_zip = 0;
18 static int do_report = 0;
19 static int do_heap_shot = 0;
20 static int max_call_depth = 100;
21 static int runtime_inited = 0;
23 /* For linux compile with:
24 * gcc -fPIC -shared -o libmono-profiler-log.so proflog.c utils.c -Wall -g -lz `pkg-config --cflags --libs mono-2`
25 * gcc -o mprof-report decode.c utils.c -Wall -g -lz -lrt -lpthread `pkg-config --cflags mono-2`
27 * For osx compile with:
28 * gcc -m32 -Dmono_free=free shared -o libmono-profiler-log.dylib proflog.c utils.c -Wall -g -lz `pkg-config --cflags mono-2` -undefined suppress -flat_namespace
29 * gcc -m32 -o mprof-report decode.c utils.c -Wall -g -lz -lrt -lpthread `pkg-config --cflags mono-2`
32 * sudo cp mprof-report /usr/local/bin
33 * sudo cp libmono-profiler-log.so /usr/local/lib
37 typedef struct _LogBuffer LogBuffer;
40 * file format: [OBSOLETE]
42 * each buffer contains events
45 * [id: 4 bytes] [major: 1 byte] [minor: 1 byte] [length: 2 bytes]
48 * [mono version: variable]
52 * [bufid: 4 bytes] [len: 4 bytes]
53 * [time_base: 8 bytes]
56 * [thread id: 8 bytes]
59 * [extended type: 4 bits] [type: 4 bits]
60 * The data that follows depend on type.
61 * Time values are relative to the last time base of the buffer.
64 * [ptr: encoded] [class: encoded] [time: encoded] size?
66 * type enter/leave format:
67 * [method: encoded] [time: encoded]
75 uintptr_t method_base;
76 uintptr_t last_method;
79 unsigned char* data_end;
83 unsigned char buf [1];
86 struct _MonoProfiler {
91 int last_gc_gen_started;
95 #define TLS_SET(x,y) x = y
98 static __thread LogBuffer* tlsbuffer = NULL;
100 #define TLS_SET(x,y) pthread_setspecific(x, y)
101 #define TLS_GET(x) ((LogBuffer *) pthread_getspecific(x))
102 #define TLS_INIT(x) pthread_key_create(&x, NULL)
103 static pthread_key_t tlsbuffer;
109 LogBuffer* buf = alloc_buffer (BUFFER_SIZE);
110 buf->size = BUFFER_SIZE;
111 buf->time_base = current_time ();
112 buf->last_time = buf->time_base;
113 buf->data_end = (unsigned char*)buf + buf->size;
114 buf->data = buf->buf;
121 LogBuffer *logbuffer;
122 if (TLS_GET (tlsbuffer))
124 logbuffer = create_buffer ();
125 TLS_SET (tlsbuffer, logbuffer);
126 logbuffer->thread_id = thread_id ();
127 //printf ("thread %p at time %llu\n", (void*)logbuffer->thread_id, logbuffer->time_base);
131 ensure_logbuf (int bytes)
133 LogBuffer *old = TLS_GET (tlsbuffer);
134 if (old && old->data + bytes + 100 < old->data_end)
136 TLS_SET (tlsbuffer, NULL);
138 TLS_GET (tlsbuffer)->next = old;
140 TLS_GET (tlsbuffer)->call_depth = old->call_depth;
141 //printf ("new logbuffer\n");
142 return TLS_GET (tlsbuffer);
146 emit_byte (LogBuffer *logbuffer, int value)
148 logbuffer->data [0] = value;
150 assert (logbuffer->data <= logbuffer->data_end);
154 emit_value (LogBuffer *logbuffer, int value)
156 encode_uleb128 (value, logbuffer->data, &logbuffer->data);
157 assert (logbuffer->data <= logbuffer->data_end);
161 emit_time (LogBuffer *logbuffer, uint64_t value)
163 uint64_t tdiff = value - logbuffer->last_time;
165 if (value < logbuffer->last_time)
166 printf ("time went backwards\n");
167 //if (tdiff > 1000000)
168 // printf ("large time offset: %llu\n", tdiff);
170 encode_uleb128 (tdiff, logbuffer->data, &logbuffer->data);
171 /*if (tdiff != decode_uleb128 (p, &p))
172 printf ("incorrect encoding: %llu\n", tdiff);*/
173 logbuffer->last_time = value;
174 assert (logbuffer->data <= logbuffer->data_end);
178 emit_svalue (LogBuffer *logbuffer, int64_t value)
180 encode_sleb128 (value, logbuffer->data, &logbuffer->data);
181 assert (logbuffer->data <= logbuffer->data_end);
185 emit_ptr (LogBuffer *logbuffer, void *ptr)
187 if (!logbuffer->ptr_base)
188 logbuffer->ptr_base = (uintptr_t)ptr;
189 emit_svalue (logbuffer, (intptr_t)ptr - logbuffer->ptr_base);
190 assert (logbuffer->data <= logbuffer->data_end);
194 emit_method (LogBuffer *logbuffer, void *method)
196 if (!logbuffer->method_base) {
197 logbuffer->method_base = (intptr_t)method;
198 logbuffer->last_method = (intptr_t)method;
200 encode_sleb128 ((intptr_t)((char*)method - (char*)logbuffer->last_method), logbuffer->data, &logbuffer->data);
201 logbuffer->last_method = (intptr_t)method;
202 assert (logbuffer->data <= logbuffer->data_end);
206 emit_obj (LogBuffer *logbuffer, void *ptr)
208 if (!logbuffer->obj_base)
209 logbuffer->obj_base = (uintptr_t)ptr >> 3;
210 emit_svalue (logbuffer, ((uintptr_t)ptr >> 3) - logbuffer->obj_base);
211 assert (logbuffer->data <= logbuffer->data_end);
215 write_int32 (char *buf, int32_t value)
218 for (i = 0; i < 4; ++i) {
226 write_int64 (char *buf, int64_t value)
229 for (i = 0; i < 8; ++i) {
237 dump_header (MonoProfiler *profiler)
241 p = write_int32 (p, LOG_HEADER_ID);
242 *p++ = LOG_VERSION_MAJOR;
243 *p++ = LOG_VERSION_MINOR;
244 *p++ = LOG_DATA_VERSION;
245 *p++ = sizeof (void*);
246 p = write_int64 (p, 0); /* startup time */
247 p = write_int32 (p, 0); /* timer overhead */
248 p = write_int32 (p, 0); /* flags */
249 p = write_int32 (p, 0); /* pid */
250 p = write_int32 (p, 0); /* opsystem */
251 if (profiler->gzfile) {
252 gzwrite (profiler->gzfile, hbuf, p - hbuf);
254 fwrite (hbuf, p - hbuf, 1, profiler->file);
259 dump_buffer (MonoProfiler *profiler, LogBuffer *buf)
264 dump_buffer (profiler, buf->next);
265 p = write_int32 (p, BUF_ID);
266 p = write_int32 (p, buf->data - buf->buf);
267 p = write_int64 (p, buf->time_base);
268 p = write_int64 (p, buf->ptr_base);
269 p = write_int64 (p, buf->obj_base);
270 p = write_int64 (p, buf->thread_id);
271 p = write_int64 (p, buf->method_base);
272 if (profiler->gzfile) {
273 gzwrite (profiler->gzfile, hbuf, p - hbuf);
274 gzwrite (profiler->gzfile, buf->buf, buf->data - buf->buf);
276 fwrite (hbuf, p - hbuf, 1, profiler->file);
277 fwrite (buf->buf, buf->data - buf->buf, 1, profiler->file);
279 free_buffer (buf, buf->size);
283 runtime_initialized (MonoProfiler *profiler)
289 * Can be called only at safe callback locations.
292 safe_dump (MonoProfiler *profiler, LogBuffer *logbuffer)
294 int cd = logbuffer->call_depth;
296 dump_buffer (profiler, TLS_GET (tlsbuffer));
298 TLS_SET (tlsbuffer, NULL);
300 TLS_GET (tlsbuffer)->call_depth = cd;
304 gc_reference (MonoObject *obj, MonoClass *klass, uintptr_t size, uintptr_t num, MonoObject **refs, void *data)
307 //const char *name = mono_class_get_name (klass);
308 LogBuffer *logbuffer = ensure_logbuf (20 + num * 8);
309 emit_byte (logbuffer, TYPE_HEAP_OBJECT | TYPE_HEAP);
310 emit_obj (logbuffer, obj);
311 emit_ptr (logbuffer, klass);
312 emit_value (logbuffer, size);
313 emit_value (logbuffer, num);
314 for (i = 0; i < num; ++i)
315 emit_obj (logbuffer, refs [i]);
317 // printf ("obj: %p, klass: %s, refs: %d, size: %d\n", obj, name, (int)num, (int)size);
321 static unsigned int hs_mode_ms = 0;
322 static unsigned int hs_mode_gc = 0;
323 static unsigned int gc_count = 0;
324 static uint64_t last_hs_time = 0;
327 heap_walk (MonoProfiler *profiler)
331 LogBuffer *logbuffer;
334 logbuffer = ensure_logbuf (10);
335 now = current_time ();
336 if (hs_mode_ms && (now - last_hs_time)/1000000 >= hs_mode_ms)
338 else if (hs_mode_gc && (gc_count % hs_mode_gc) == 0)
340 else if (!hs_mode_ms && !hs_mode_gc && profiler->last_gc_gen_started == mono_gc_max_generation ())
345 emit_byte (logbuffer, TYPE_HEAP_START | TYPE_HEAP);
346 emit_time (logbuffer, now);
347 mono_gc_walk_heap (0, gc_reference, NULL);
348 logbuffer = ensure_logbuf (10);
349 now = current_time ();
350 emit_byte (logbuffer, TYPE_HEAP_END | TYPE_HEAP);
351 emit_time (logbuffer, now);
355 gc_event (MonoProfiler *profiler, MonoGCEvent ev, int generation) {
357 LogBuffer *logbuffer = ensure_logbuf (10);
358 now = current_time ();
359 emit_byte (logbuffer, TYPE_GC_EVENT | TYPE_GC);
360 emit_time (logbuffer, now);
361 emit_value (logbuffer, ev);
362 emit_value (logbuffer, generation);
363 /* to deal with nested gen1 after gen0 started */
364 if (ev == MONO_GC_EVENT_START) {
365 profiler->last_gc_gen_started = generation;
368 if (ev == MONO_GC_EVENT_PRE_START_WORLD)
369 heap_walk (profiler);
370 if (ev == MONO_GC_EVENT_POST_START_WORLD)
371 safe_dump (profiler, logbuffer);
372 //printf ("gc event %d for generation %d\n", ev, generation);
376 gc_resize (MonoProfiler *profiler, int64_t new_size) {
378 LogBuffer *logbuffer = ensure_logbuf (10);
379 now = current_time ();
380 emit_byte (logbuffer, TYPE_GC_RESIZE | TYPE_GC);
381 emit_time (logbuffer, now);
382 emit_value (logbuffer, new_size);
383 //printf ("gc resized to %lld\n", new_size);
386 #define MAX_FRAMES 16
389 MonoMethod* methods [MAX_FRAMES];
391 static int num_frames = MAX_FRAMES / 2;
394 walk_stack (MonoMethod *method, int32_t native_offset, int32_t il_offset, mono_bool managed, void* data)
396 FrameData *frame = data;
397 if (method && frame->count < num_frames) {
398 frame->methods [frame->count++] = method;
399 //printf ("In %d %s\n", frame->count, mono_method_get_name (method));
401 return frame->count == num_frames;
405 * a note about stack walks: they can cause more profiler events to fire,
406 * so we need to make sure they don't happen after we started emitting an
407 * event, hence the collect_bt/emit_bt split.
410 collect_bt (FrameData *data)
413 mono_stack_walk_no_il (walk_stack, data);
417 emit_bt (LogBuffer *logbuffer, FrameData *data)
419 /* FIXME: this is actually tons of data and we should
420 * just output it the first time and use an id the next
422 if (data->count > num_frames)
423 printf ("bad num frames: %d\n", data->count);
424 emit_value (logbuffer, 0); /* flags */
425 emit_value (logbuffer, data->count);
426 //if (*p != data.count) {
427 // printf ("bad num frames enc at %d: %d -> %d\n", count, data.count, *p); printf ("frames end: %p->%p\n", p, logbuffer->data); exit(0);}
428 while (data->count) {
429 emit_ptr (logbuffer, data->methods [--data->count]);
434 gc_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
438 int do_bt = (nocalls && runtime_inited && !notraces)? TYPE_ALLOC_BT: 0;
440 LogBuffer *logbuffer;
441 len = mono_object_get_size (obj);
444 logbuffer = ensure_logbuf (32 + MAX_FRAMES * 8);
445 now = current_time ();
446 emit_byte (logbuffer, do_bt | TYPE_ALLOC);
447 emit_time (logbuffer, now);
448 emit_ptr (logbuffer, klass);
449 emit_obj (logbuffer, obj);
450 emit_value (logbuffer, len);
452 emit_bt (logbuffer, &data);
454 safe_dump (prof, logbuffer);
455 //printf ("gc alloc %s at %p\n", mono_class_get_name (klass), obj);
459 gc_moves (MonoProfiler *prof, void **objects, int num)
463 LogBuffer *logbuffer = ensure_logbuf (10 + num * 8);
464 now = current_time ();
465 emit_byte (logbuffer, TYPE_GC_MOVE | TYPE_GC);
466 emit_time (logbuffer, now);
467 emit_value (logbuffer, num);
468 for (i = 0; i < num; ++i)
469 emit_obj (logbuffer, objects [i]);
470 //printf ("gc moved %d objects\n", num/2);
474 push_nesting (char *p, MonoClass *klass)
479 nesting = mono_class_get_nesting_type (klass);
481 p = push_nesting (p, nesting);
485 name = mono_class_get_name (klass);
486 nspace = mono_class_get_namespace (klass);
489 p += strlen (nspace);
499 type_name (MonoClass *klass)
503 push_nesting (buf, klass);
504 p = malloc (strlen (buf) + 1);
510 image_loaded (MonoProfiler *prof, MonoImage *image, int result)
515 LogBuffer *logbuffer;
516 if (result != MONO_PROFILE_OK)
518 name = mono_image_get_filename (image);
519 nlen = strlen (name) + 1;
520 logbuffer = ensure_logbuf (16 + nlen);
521 now = current_time ();
522 emit_byte (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
523 emit_time (logbuffer, now);
524 emit_byte (logbuffer, TYPE_IMAGE);
525 emit_ptr (logbuffer, image);
526 emit_value (logbuffer, 0); /* flags */
527 memcpy (logbuffer->data, name, nlen);
528 logbuffer->data += nlen;
529 //printf ("loaded image %p (%s)\n", image, name);
531 safe_dump (prof, logbuffer);
535 class_loaded (MonoProfiler *prof, MonoClass *klass, int result)
541 LogBuffer *logbuffer;
542 if (result != MONO_PROFILE_OK)
545 name = mono_type_get_name (mono_class_get_type (klass));
547 name = type_name (klass);
548 nlen = strlen (name) + 1;
549 image = mono_class_get_image (klass);
550 logbuffer = ensure_logbuf (24 + nlen);
551 now = current_time ();
552 emit_byte (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
553 emit_time (logbuffer, now);
554 emit_byte (logbuffer, TYPE_CLASS);
555 emit_ptr (logbuffer, klass);
556 emit_ptr (logbuffer, image);
557 emit_value (logbuffer, 0); /* flags */
558 memcpy (logbuffer->data, name, nlen);
559 logbuffer->data += nlen;
560 //printf ("loaded class %p (%s)\n", klass, name);
566 safe_dump (prof, logbuffer);
570 method_enter (MonoProfiler *prof, MonoMethod *method)
573 LogBuffer *logbuffer = ensure_logbuf (16);
574 if (logbuffer->call_depth++ > max_call_depth)
576 now = current_time ();
577 emit_byte (logbuffer, TYPE_ENTER | TYPE_METHOD);
578 emit_time (logbuffer, now);
579 emit_method (logbuffer, method);
583 method_leave (MonoProfiler *prof, MonoMethod *method)
586 LogBuffer *logbuffer = ensure_logbuf (16);
587 if (--logbuffer->call_depth > max_call_depth)
589 now = current_time ();
590 emit_byte (logbuffer, TYPE_LEAVE | TYPE_METHOD);
591 emit_time (logbuffer, now);
592 emit_method (logbuffer, method);
594 safe_dump (prof, logbuffer);
598 method_exc_leave (MonoProfiler *prof, MonoMethod *method)
601 LogBuffer *logbuffer;
604 logbuffer = ensure_logbuf (16);
605 if (--logbuffer->call_depth > max_call_depth)
607 now = current_time ();
608 emit_byte (logbuffer, TYPE_EXC_LEAVE | TYPE_METHOD);
609 emit_time (logbuffer, now);
610 emit_method (logbuffer, method);
614 method_jitted (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result)
619 LogBuffer *logbuffer;
620 if (result != MONO_PROFILE_OK)
622 name = mono_method_full_name (method, 1);
623 nlen = strlen (name) + 1;
624 logbuffer = ensure_logbuf (32 + nlen);
625 now = current_time ();
626 emit_byte (logbuffer, TYPE_JIT | TYPE_METHOD);
627 emit_time (logbuffer, now);
628 emit_method (logbuffer, method);
629 emit_ptr (logbuffer, mono_jit_info_get_code_start (jinfo));
630 emit_value (logbuffer, mono_jit_info_get_code_size (jinfo));
631 memcpy (logbuffer->data, name, nlen);
632 logbuffer->data += nlen;
635 safe_dump (prof, logbuffer);
639 throw_exc (MonoProfiler *prof, MonoObject *object)
641 int do_bt = (nocalls && runtime_inited && !notraces)? TYPE_EXCEPTION_BT: 0;
644 LogBuffer *logbuffer;
647 logbuffer = ensure_logbuf (16 + MAX_FRAMES * 8);
648 now = current_time ();
649 emit_byte (logbuffer, do_bt | TYPE_EXCEPTION);
650 emit_time (logbuffer, now);
651 emit_obj (logbuffer, object);
653 emit_bt (logbuffer, &data);
657 clause_exc (MonoProfiler *prof, MonoMethod *method, int clause_type, int clause_num)
660 LogBuffer *logbuffer = ensure_logbuf (16);
661 now = current_time ();
662 emit_byte (logbuffer, TYPE_EXCEPTION | TYPE_CLAUSE);
663 emit_time (logbuffer, now);
664 emit_value (logbuffer, clause_type);
665 emit_value (logbuffer, clause_num);
666 emit_method (logbuffer, method);
670 monitor_event (MonoProfiler *profiler, MonoObject *object, MonoProfilerMonitorEvent event)
672 int do_bt = (nocalls && runtime_inited && !notraces && event == MONO_PROFILER_MONITOR_CONTENTION)? TYPE_MONITOR_BT: 0;
675 LogBuffer *logbuffer;
678 logbuffer = ensure_logbuf (16 + MAX_FRAMES * 8);
679 now = current_time ();
680 emit_byte (logbuffer, (event << 4) | do_bt | TYPE_MONITOR);
681 emit_time (logbuffer, now);
682 emit_obj (logbuffer, object);
684 emit_bt (logbuffer, &data);
688 thread_start (MonoProfiler *prof, uintptr_t tid)
690 //printf ("thread start %p\n", (void*)tid);
695 thread_end (MonoProfiler *prof, uintptr_t tid)
698 if (TLS_GET (tlsbuffer))
699 dump_buffer (prof, TLS_GET (tlsbuffer));
701 TLS_SET (tlsbuffer, NULL);
705 log_shutdown (MonoProfiler *prof)
708 if (TLS_GET (tlsbuffer))
709 dump_buffer (prof, TLS_GET (tlsbuffer));
710 TLS_SET (tlsbuffer, NULL);
713 gzclose (prof->gzfile);
714 if (prof->pipe_output)
722 create_profiler (char *filename)
725 prof = calloc (1, sizeof (MonoProfiler));
726 if (do_report) /* FIXME: use filename as output */
727 filename = "|mprof-report -";
730 filename = "output.mlpd";
731 if (*filename == '|') {
732 prof->file = popen (filename + 1, "w");
733 prof->pipe_output = 1;
735 prof->file = fopen (filename, "wb");
738 printf ("Cannot create profiler output: %s\n", filename);
742 prof->gzfile = gzdopen (fileno (prof->file), "wb");
750 printf ("Log profiler version %d.%d (format: %d)\n", LOG_VERSION_MAJOR, LOG_VERSION_MINOR, LOG_DATA_VERSION);
751 printf ("Usage: mono --profile=log[:OPTION1[,OPTION2...]] program.exe\n");
752 printf ("Options:\n");
753 printf ("\thelp show this usage info\n");
754 printf ("\t[no]alloc enable/disable recording allocation info\n");
755 printf ("\t[no]calls enable/disable recording enter/leave method events\n");
756 printf ("\theapshot record heap shot info (by default at each major collection)\n");
757 printf ("\thsmode=MODE heapshot mode: every XXms milliseconds or every YYgc collections\n");
758 printf ("\ttime=fast use a faster (but more inaccurate) timer\n");
759 printf ("\tmaxframes=NUM collect up to NUM stack frames\n");
760 printf ("\tcalldepth=NUM ignore method events for call chain depth bigger than NUM\n");
761 printf ("\toutput=FILENAME write the data to file FILENAME\n");
762 printf ("\toutput=|PROGRAM write the data to the stdin of PROGRAM\n");
763 printf ("\treport create a report instead of writing the raw data to a file\n");
764 printf ("\tzip compress the output data\n");
770 match_option (const char* p, const char *opt, char **rval)
772 int len = strlen (opt);
773 if (strncmp (p, opt, len) == 0) {
775 if (p [len] == '=' && p [len + 1]) {
776 const char *opt = p + len + 1;
777 const char *end = strchr (opt, ',');
785 val = malloc (l + 1);
786 memcpy (val, opt, l);
803 mono_profiler_startup (const char *desc)
806 char *filename = NULL;
810 int calls_enabled = 0;
811 int allocs_enabled = 0;
812 int events = MONO_PROFILE_GC|MONO_PROFILE_ALLOCATIONS|
813 MONO_PROFILE_GC_MOVES|MONO_PROFILE_CLASS_EVENTS|MONO_PROFILE_THREADS|
814 MONO_PROFILE_ENTER_LEAVE|MONO_PROFILE_JIT_COMPILATION|MONO_PROFILE_EXCEPTIONS|
815 MONO_PROFILE_MONITOR_EVENTS|MONO_PROFILE_MODULE_EVENTS;
818 if (strncmp (p, "log", 3))
823 for (; *p; p = opt) {
829 if ((opt = match_option (p, "help", NULL)) != p) {
833 if ((opt = match_option (p, "calls", NULL)) != p) {
837 if ((opt = match_option (p, "nocalls", NULL)) != p) {
838 events &= ~MONO_PROFILE_ENTER_LEAVE;
842 if ((opt = match_option (p, "alloc", NULL)) != p) {
846 if ((opt = match_option (p, "noalloc", NULL)) != p) {
847 events &= ~MONO_PROFILE_ALLOCATIONS;
850 if ((opt = match_option (p, "time", &val)) != p) {
851 if (strcmp (val, "fast") == 0)
853 else if (strcmp (val, "null") == 0)
860 if ((opt = match_option (p, "report", NULL)) != p) {
864 if ((opt = match_option (p, "heapshot", NULL)) != p) {
865 events &= ~MONO_PROFILE_ALLOCATIONS;
866 events &= ~MONO_PROFILE_ENTER_LEAVE;
871 if ((opt = match_option (p, "hsmode", &val)) != p) {
873 unsigned int count = strtoul (val, &end, 10);
876 if (strcmp (end, "ms") == 0)
878 else if (strcmp (end, "gc") == 0)
885 if ((opt = match_option (p, "zip", NULL)) != p) {
889 if ((opt = match_option (p, "output", &val)) != p) {
893 if ((opt = match_option (p, "maxframes", &val)) != p) {
895 num_frames = strtoul (val, &end, 10);
896 if (num_frames > MAX_FRAMES)
897 num_frames = MAX_FRAMES;
899 notraces = num_frames == 0;
902 if ((opt = match_option (p, "calldepth", &val)) != p) {
904 max_call_depth = strtoul (val, &end, 10);
914 events |= MONO_PROFILE_ENTER_LEAVE;
918 events |= MONO_PROFILE_ALLOCATIONS;
919 utils_init (fast_time);
921 prof = create_profiler (filename);
924 mono_profiler_install (prof, log_shutdown);
925 mono_profiler_install_gc (gc_event, gc_resize);
926 mono_profiler_install_allocation (gc_alloc);
927 mono_profiler_install_gc_moves (gc_moves);
928 mono_profiler_install_class (NULL, class_loaded, NULL, NULL);
929 mono_profiler_install_module (NULL, image_loaded, NULL, NULL);
930 mono_profiler_install_thread (thread_start, thread_end);
931 mono_profiler_install_enter_leave (method_enter, method_leave);
932 mono_profiler_install_jit_end (method_jitted);
933 mono_profiler_install_exception (throw_exc, method_exc_leave, clause_exc);
934 mono_profiler_install_monitor (monitor_event);
935 mono_profiler_install_runtime_initialized (runtime_initialized);
937 mono_profiler_set_events (events);
939 TLS_INIT (tlsbuffer);