/* the entry point */ void mono_profiler_startup (const char *desc) { iJIT_IsProfilingActiveFlags flags = iJIT_IsProfilingActive(); if (flags == iJIT_SAMPLING_ON) { mono_profiler_install (NULL, codeanalyst_shutdown); mono_profiler_install_jit_end (method_jit_result); mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION); } }
/* the entry point */ void mono_profiler_startup (const char *desc) { MonoProfiler *prof = g_new0 (MonoProfiler, 1); mono_profiler_install (prof, sample_shutdown); mono_profiler_install_jit_end (mop_jit_end); mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION); ldscript = fopen ("ldscript", "w"); assm = fopen ("jit.s", "w"); }
/* the entry point */ void mono_profiler_startup (const char *desc) { MonoProfiler *prof; prof = g_new0 (MonoProfiler, 1); prof->images = g_hash_table_new (NULL, NULL); mono_profiler_install (prof, prof_shutdown); mono_profiler_install_jit_compile (prof_jit_enter, prof_jit_leave); mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION); }
void mono_profiler_startup (const char *desc) { MonoProfiler *prof = g_new0 (MonoProfiler, 1); mono_os_mutex_init (&mismatched_files_section); prof->mismatched_files_hash = g_hash_table_new (mismatched_files_guint32_hash, mismatched_files_guint32_equal); prof->saved_strings_hash = g_hash_table_new (NULL, NULL); prof->string_locations_hash = g_hash_table_new (mismatched_files_guint32_hash, mismatched_files_guint32_equal); mono_profiler_install (prof, profiler_shutdown); mono_profiler_install_runtime_initialized (runtime_initialized_cb); mono_profiler_install_iomap (mono_portability_iomap_event); mono_profiler_install_allocation (mono_portability_remember_alloc); mono_profiler_set_events ((MonoProfileFlags)(MONO_PROFILE_ALLOCATIONS | MONO_PROFILE_IOMAP_EVENTS)); }
void mono_profiler_startup (const char *desc) { MonoProfiler* p = g_new0 (MonoProfiler, 1); InitializeCriticalSection (&hp_lock); g_assert (! strncmp (desc, "desc-heap", 9)); p->klass_to_table_idx = g_hash_table_new (NULL, NULL); p->klass_table = g_ptr_array_new (); p->t_zero = GetTickCount (); mono_profiler_install_allocation (write_allocation); mono_profiler_install_gc (prof_gc_collection, prof_heap_resize); mono_profiler_set_events (MONO_PROFILE_ALLOCATIONS | MONO_PROFILE_GC); mono_profiler_install (p, mono_heap_prof_shutdown); }
static HRESULT load_mono(LPCWSTR mono_path) { static const WCHAR lib[] = {'\\','l','i','b',0}; static const WCHAR etc[] = {'\\','e','t','c',0}; WCHAR mono_dll_path[MAX_PATH+16]; WCHAR mono_lib_path[MAX_PATH+4], mono_etc_path[MAX_PATH+4]; char mono_lib_path_a[MAX_PATH], mono_etc_path_a[MAX_PATH]; int trace_size; char trace_setting[256]; int verbose_size; char verbose_setting[256]; if (is_mono_shutdown) { ERR("Cannot load Mono after it has been shut down.\n"); return E_FAIL; } if (!mono_handle) { strcpyW(mono_lib_path, mono_path); strcatW(mono_lib_path, lib); WideCharToMultiByte(CP_UTF8, 0, mono_lib_path, -1, mono_lib_path_a, MAX_PATH, NULL, NULL); strcpyW(mono_etc_path, mono_path); strcatW(mono_etc_path, etc); WideCharToMultiByte(CP_UTF8, 0, mono_etc_path, -1, mono_etc_path_a, MAX_PATH, NULL, NULL); if (!find_mono_dll(mono_path, mono_dll_path)) goto fail; mono_handle = LoadLibraryW(mono_dll_path); if (!mono_handle) goto fail; #define LOAD_MONO_FUNCTION(x) do { \ x = (void*)GetProcAddress(mono_handle, #x); \ if (!x) { \ goto fail; \ } \ } while (0); LOAD_MONO_FUNCTION(mono_assembly_get_image); LOAD_MONO_FUNCTION(mono_assembly_load_from); LOAD_MONO_FUNCTION(mono_assembly_open); LOAD_MONO_FUNCTION(mono_config_parse); LOAD_MONO_FUNCTION(mono_class_from_mono_type); LOAD_MONO_FUNCTION(mono_class_from_name); LOAD_MONO_FUNCTION(mono_class_get_method_from_name); LOAD_MONO_FUNCTION(mono_domain_assembly_open); LOAD_MONO_FUNCTION(mono_domain_get); LOAD_MONO_FUNCTION(mono_domain_get_by_id); LOAD_MONO_FUNCTION(mono_domain_set); LOAD_MONO_FUNCTION(mono_domain_set_config); LOAD_MONO_FUNCTION(mono_free); LOAD_MONO_FUNCTION(mono_image_open); LOAD_MONO_FUNCTION(mono_install_assembly_preload_hook); LOAD_MONO_FUNCTION(mono_jit_exec); LOAD_MONO_FUNCTION(mono_jit_init_version); LOAD_MONO_FUNCTION(mono_jit_set_trace_options); LOAD_MONO_FUNCTION(mono_marshal_get_vtfixup_ftnptr); LOAD_MONO_FUNCTION(mono_object_get_domain); LOAD_MONO_FUNCTION(mono_object_get_virtual_method); LOAD_MONO_FUNCTION(mono_object_new); LOAD_MONO_FUNCTION(mono_object_unbox); LOAD_MONO_FUNCTION(mono_profiler_install); LOAD_MONO_FUNCTION(mono_reflection_type_from_name); LOAD_MONO_FUNCTION(mono_runtime_invoke); LOAD_MONO_FUNCTION(mono_runtime_object_init); LOAD_MONO_FUNCTION(mono_runtime_quit); LOAD_MONO_FUNCTION(mono_set_dirs); LOAD_MONO_FUNCTION(mono_set_verbose_level); LOAD_MONO_FUNCTION(mono_stringify_assembly_name); LOAD_MONO_FUNCTION(mono_string_new); LOAD_MONO_FUNCTION(mono_thread_attach); LOAD_MONO_FUNCTION(mono_thread_manage); LOAD_MONO_FUNCTION(mono_trace_set_assembly); #undef LOAD_MONO_FUNCTION #define LOAD_OPT_MONO_FUNCTION(x, default) do { \ x = (void*)GetProcAddress(mono_handle, #x); \ if (!x) { \ x = default; \ } \ } while (0); LOAD_OPT_MONO_FUNCTION(mono_image_open_from_module_handle, image_open_module_handle_dummy); LOAD_OPT_MONO_FUNCTION(mono_trace_set_print_handler, set_print_handler_dummy); LOAD_OPT_MONO_FUNCTION(mono_trace_set_printerr_handler, set_print_handler_dummy); #undef LOAD_OPT_MONO_FUNCTION mono_profiler_install(NULL, mono_shutdown_callback_fn); mono_trace_set_print_handler(mono_print_handler_fn); mono_trace_set_printerr_handler(mono_print_handler_fn); mono_set_dirs(mono_lib_path_a, mono_etc_path_a); mono_config_parse(NULL); mono_install_assembly_preload_hook(mono_assembly_preload_hook_fn, NULL); trace_size = GetEnvironmentVariableA("WINE_MONO_TRACE", trace_setting, sizeof(trace_setting)); if (trace_size) { mono_jit_set_trace_options(trace_setting); } verbose_size = GetEnvironmentVariableA("WINE_MONO_VERBOSE", verbose_setting, sizeof(verbose_setting)); if (verbose_size) { mono_set_verbose_level(verbose_setting[0] - '0'); } } return S_OK; fail: ERR("Could not load Mono into this process\n"); FreeLibrary(mono_handle); mono_handle = NULL; return E_FAIL; }
void mono_profiler_startup (char *arg) { gchar **ptr; char *filterfile_name = NULL; gchar **args; /* Why does the runtime passes the module name to us ? */ if (strstr (arg, ":")) arg = strstr (arg, ":") + 1; else arg = NULL; args = g_strsplit (arg ? arg : "", ",", -1); MonoProfiler *prof = g_new0 (MonoProfiler, 1); prof->methods = g_hash_table_new (NULL, NULL); prof->classes = g_hash_table_new (NULL, NULL); prof->assemblies = g_hash_table_new (NULL, NULL); for (ptr = args; ptr && *ptr; ptr++) { const char *arg = *ptr; gchar *message; if (strncmp (arg, "filterfile=", 11) == 0) filterfile_name = g_strdup (arg + 11); else if (strncmp (arg, "outfile=", 8) == 0) prof->outfile_name = g_strdup (arg + 8); else if (strncmp (arg, "-", 1) == 0) { add_filter (prof, arg); } else if (strncmp (arg, "+", 1) == 0) { add_filter (prof, arg); } else { message = g_strdup_printf ("Unknown argument '%s'.", arg); fprintf (stderr, "monocov | Error while processing arguments: %s\n", message); g_free (message); } } g_strfreev (args); if (filterfile_name) { FILE *filterfile; filterfile = fopen (filterfile_name, "r"); if (!filterfile) { fprintf (stderr, "coverage.c: Unable to open filter file '%s'.\n", filterfile_name); exit (1); } while (!feof (filterfile)) { char buf [2048]; fgets (buf, 2048, filterfile); buf [sizeof (buf) - 1] = '\0'; if ((buf [0] == '#') || (buf [0] == '\0')) continue; if (buf [strlen (buf) - 1] == '\n') buf [strlen (buf) - 1] = '\0'; add_filter (prof, buf); } fclose (filterfile); } mono_profiler_install (prof, coverage_shutdown); mono_profiler_set_events (MONO_PROFILE_INS_COVERAGE | MONO_PROFILE_ASSEMBLY_EVENTS); mono_profiler_install_coverage_filter (collect_coverage_for); mono_profiler_install_assembly (NULL, assembly_load, NULL, NULL); /* we don't deal with unloading, so disable it for now */ setenv ("MONO_NO_UNLOAD", "1", 1); }
static void install_jit_profile () { MonoProfiler *prof = new MonoProfiler; mono_profiler_install (prof, mono_shutdown); mono_profiler_install_jit_end (profile_jit_result); mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION); }