X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fprofiler%2Flog.c;h=8a677c2720d48bba530592351a5f6283d87f970b;hb=bfc76bafbf72f8e10c4d2cc7b12e779715c527fa;hp=847ee26184cb93824366892581ba1eee5685eeb6;hpb=e217c5ae861453e4f27d0bd70dbd287413e80f11;p=mono.git diff --git a/mono/profiler/log.c b/mono/profiler/log.c index 847ee26184c..8a677c2720d 100644 --- a/mono/profiler/log.c +++ b/mono/profiler/log.c @@ -1142,7 +1142,7 @@ sync_point_mark (MonoProfilerSyncPointType type) ENTER_LOG (&sync_points_ctr, logbuffer, EVENT_SIZE /* event */ + - LEB128_SIZE /* type */ + BYTE_SIZE /* type */ ); emit_event (logbuffer, TYPE_META | TYPE_SYNC_POINT); @@ -1219,7 +1219,7 @@ gc_roots (MonoProfiler *prof, MonoObject *const *objects, const MonoProfilerGCRo for (int i = 0; i < num; ++i) { emit_obj (logbuffer, objects [i]); - emit_byte (logbuffer, root_types [i]); + emit_value (logbuffer, root_types [i]); emit_value (logbuffer, extra_info [i]); } @@ -1760,7 +1760,7 @@ class_loaded (MonoProfiler *prof, MonoClass *klass) } static void -method_enter (MonoProfiler *prof, MonoMethod *method) +method_enter (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *ctx) { if (get_thread ()->call_depth++ <= log_config.max_call_depth) { ENTER_LOG (&method_entries_ctr, logbuffer, @@ -1776,7 +1776,7 @@ method_enter (MonoProfiler *prof, MonoMethod *method) } static void -method_leave (MonoProfiler *prof, MonoMethod *method) +method_leave (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *ctx) { if (--get_thread ()->call_depth <= log_config.max_call_depth) { ENTER_LOG (&method_exits_ctr, logbuffer, @@ -1791,6 +1791,12 @@ method_leave (MonoProfiler *prof, MonoMethod *method) } } +static void +tail_call (MonoProfiler *prof, MonoMethod *method, MonoMethod *target) +{ + method_leave (prof, method, NULL); +} + static void method_exc_leave (MonoProfiler *prof, MonoMethod *method, MonoObject *exc) { @@ -1810,7 +1816,14 @@ method_exc_leave (MonoProfiler *prof, MonoMethod *method, MonoObject *exc) static MonoProfilerCallInstrumentationFlags method_filter (MonoProfiler *prof, MonoMethod *method) { - return MONO_PROFILER_CALL_INSTRUMENTATION_PROLOGUE | MONO_PROFILER_CALL_INSTRUMENTATION_EPILOGUE; + if (log_config.callspec.len > 0 && + !mono_callspec_eval (method, &log_config.callspec)) + return MONO_PROFILER_CALL_INSTRUMENTATION_NONE; + + return MONO_PROFILER_CALL_INSTRUMENTATION_ENTER | + MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE | + MONO_PROFILER_CALL_INSTRUMENTATION_TAIL_CALL | + MONO_PROFILER_CALL_INSTRUMENTATION_EXCEPTION_LEAVE; } static void @@ -1896,7 +1909,8 @@ clause_exc (MonoProfiler *prof, MonoMethod *method, uint32_t clause_num, MonoExc EVENT_SIZE /* event */ + BYTE_SIZE /* clause type */ + LEB128_SIZE /* clause num */ + - LEB128_SIZE /* method */ + LEB128_SIZE /* method */ + + LEB128_SIZE /* exc */ ); emit_event (logbuffer, TYPE_EXCEPTION | TYPE_CLAUSE); @@ -2259,7 +2273,7 @@ dump_ubin (const char *filename, uintptr_t load_addr, uint64_t offset, uintptr_t LEB128_SIZE /* load address */ + LEB128_SIZE /* offset */ + LEB128_SIZE /* size */ + - nlen /* file name */ + len /* file name */ ); emit_event (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_UBIN); @@ -2662,6 +2676,12 @@ counters_sample (uint64_t timestamp) ; for (agent = log_profiler.counters; agent; agent = agent->next) { + /* + * FIXME: This calculation is incorrect for string counters since + * mono_counter_get_size () just returns 0 in that case. We should + * address this if we ever actually add any string counters to Mono. + */ + size += LEB128_SIZE /* index */ + BYTE_SIZE /* type */ + @@ -4247,12 +4267,12 @@ proflog_icall_SetMonitorEvents (MonoBoolean value) mono_coop_mutex_lock (&log_profiler.api_mutex); if (value) { - ENABLE (PROFLOG_EXCEPTION_EVENTS); + ENABLE (PROFLOG_MONITOR_EVENTS); mono_profiler_set_monitor_contention_callback (log_profiler.handle, monitor_contention); mono_profiler_set_monitor_acquired_callback (log_profiler.handle, monitor_acquired); mono_profiler_set_monitor_failed_callback (log_profiler.handle, monitor_failed); } else { - DISABLE (PROFLOG_EXCEPTION_EVENTS); + DISABLE (PROFLOG_MONITOR_EVENTS); mono_profiler_set_monitor_contention_callback (log_profiler.handle, NULL); mono_profiler_set_monitor_acquired_callback (log_profiler.handle, NULL); mono_profiler_set_monitor_failed_callback (log_profiler.handle, NULL); @@ -4626,28 +4646,11 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters) log_profiler.startup_time = current_time (); } -/* - * declaration to silence the compiler: this is the entry point that - * mono will load from the shared library and call. - */ -extern void -mono_profiler_init (const char *desc); - -extern void +MONO_API void mono_profiler_init_log (const char *desc); -/* - * this is the entry point that will be used when the profiler - * is embedded inside the main executable. - */ void mono_profiler_init_log (const char *desc) -{ - mono_profiler_init (desc); -} - -void -mono_profiler_init (const char *desc) { GPtrArray *filters = NULL; @@ -4670,7 +4673,7 @@ mono_profiler_init (const char *desc) mono_lls_init (&log_profiler.profiler_thread_list, NULL); - MonoProfilerHandle handle = log_profiler.handle = mono_profiler_install (&log_profiler); + MonoProfilerHandle handle = log_profiler.handle = mono_profiler_create (&log_profiler); /* * Required callbacks. These are either necessary for the profiler itself @@ -4752,11 +4755,14 @@ mono_profiler_init (const char *desc) mono_profiler_set_call_instrumentation_filter_callback (handle, method_filter); mono_profiler_set_method_enter_callback (handle, method_enter); mono_profiler_set_method_leave_callback (handle, method_leave); + mono_profiler_set_method_tail_call_callback (handle, tail_call); mono_profiler_set_method_exception_leave_callback (handle, method_exc_leave); } - if (log_config.collect_coverage) + if (log_config.collect_coverage) { + mono_profiler_enable_coverage (); mono_profiler_set_coverage_filter_callback (handle, coverage_filter); + } mono_profiler_enable_allocations (); mono_profiler_enable_sampling (handle);