#define NEW_INITIALIZER_NAME "mono_profiler_init"
static gboolean
-load_profiler (MonoDl *module, const char *desc, const char *suffix)
+load_profiler (MonoDl *module, const char *name, const char *desc)
{
if (!module)
return FALSE;
- char *old_name;
-
- if (suffix)
- old_name = g_strdup_printf (OLD_INITIALIZER_NAME "_%s", suffix);
- else
- old_name = g_strdup_printf (OLD_INITIALIZER_NAME);
-
+ char *err, *old_name = g_strdup_printf (OLD_INITIALIZER_NAME);
MonoProfilerInitializer func;
- char *err;
-
if (!(err = mono_dl_symbol (module, old_name, (gpointer) &func))) {
- mono_profiler_printf_err ("Found old-style startup symbol %s for %s; profiler has not been migrated to the new API.", old_name, desc);
+ mono_profiler_printf_err ("Found old-style startup symbol '%s' for the '%s' profiler; it has not been migrated to the new API.", old_name, name);
g_free (old_name);
return FALSE;
}
g_free (err);
g_free (old_name);
- char *new_name;
-
- if (suffix)
- new_name = g_strdup_printf (NEW_INITIALIZER_NAME "_%s", suffix);
- else
- new_name = g_strdup_printf (NEW_INITIALIZER_NAME);
+ char *new_name = g_strdup_printf (NEW_INITIALIZER_NAME "_%s", name);
if ((err = mono_dl_symbol (module, new_name, (gpointer *) &func))) {
g_free (err);
}
static gboolean
-load_profiler_from_executable (const char *desc, const char *name)
+load_profiler_from_executable (const char *name, const char *desc)
{
char *err;
return FALSE;
}
- return load_profiler (module, desc, name);
+ return load_profiler (module, name, desc);
}
static gboolean
-load_profiler_from_directory (const char *directory, const char *libname, const char *desc)
+load_profiler_from_directory (const char *directory, const char *libname, const char *name, const char *desc)
{
char* path;
void *iter = NULL;
g_free (path);
if (module)
- return load_profiler (module, desc, NULL);
+ return load_profiler (module, name, desc);
}
return FALSE;
}
static gboolean
-load_profiler_from_installation (const char *libname, const char *desc)
+load_profiler_from_installation (const char *libname, const char *name, const char *desc)
{
char *err;
MonoDl *module = mono_dl_open_runtime_lib (libname, MONO_DL_EAGER, &err);
g_free (err);
if (module)
- return load_profiler (module, desc, NULL);
+ return load_profiler (module, name, desc);
return FALSE;
}
void
mono_profiler_load (const char *desc)
{
- mono_gc_base_init ();
-
if (!desc || !strcmp ("default", desc))
desc = "log:report";
} else
mname = g_strdup (desc);
- if (!load_profiler_from_executable (desc, mname)) {
+ if (!load_profiler_from_executable (mname, desc)) {
char *libname = g_strdup_printf ("mono-profiler-%s", mname);
- gboolean res = load_profiler_from_installation (libname, desc);
+ gboolean res = load_profiler_from_installation (libname, mname, desc);
if (!res && mono_config_get_assemblies_dir ())
- res = load_profiler_from_directory (mono_assembly_getrootdir (), libname, desc);
+ res = load_profiler_from_directory (mono_assembly_getrootdir (), libname, mname, desc);
if (!res)
- res = load_profiler_from_directory (NULL, libname, desc);
+ res = load_profiler_from_directory (NULL, libname, mname, desc);
if (!res)
mono_profiler_printf_err ("The '%s' profiler wasn't found in the main executable nor could it be loaded from '%s'.", mname, libname);
}
MonoProfilerHandle
-mono_profiler_install (MonoProfiler *prof)
+mono_profiler_create (MonoProfiler *prof)
{
MonoProfilerHandle handle = g_new0 (struct _MonoProfilerDesc, 1);
if (mono_profiler_state.startup_done)
return FALSE;
- mono_profiler_state.allocations = TRUE;
-
- return TRUE;
+ return mono_profiler_state.allocations = TRUE;
}
void
InterlockedWritePointer (&handle->call_instrumentation_filter, (gpointer) cb);
}
-gboolean
-mono_profiler_should_instrument_method (MonoMethod *method, gboolean entry)
+mono_bool
+mono_profiler_enable_call_context_introspection (void)
+{
+ if (mono_profiler_state.startup_done)
+ return FALSE;
+
+ mono_profiler_state.context_enable ();
+
+ return mono_profiler_state.call_contexts = TRUE;
+}
+
+void *
+mono_profiler_call_context_get_this (MonoProfilerCallContext *context)
+{
+ if (!mono_profiler_state.call_contexts)
+ return NULL;
+
+ return mono_profiler_state.context_get_this (context);
+}
+
+void *
+mono_profiler_call_context_get_argument (MonoProfilerCallContext *context, uint32_t position)
+{
+ if (!mono_profiler_state.call_contexts)
+ return NULL;
+
+ return mono_profiler_state.context_get_argument (context, position);
+}
+
+void *
+mono_profiler_call_context_get_local (MonoProfilerCallContext *context, uint32_t position)
+{
+ if (!mono_profiler_state.call_contexts)
+ return NULL;
+
+ return mono_profiler_state.context_get_local (context, position);
+}
+
+void *
+mono_profiler_call_context_get_result (MonoProfilerCallContext *context)
+{
+ if (!mono_profiler_state.call_contexts)
+ return NULL;
+
+ return mono_profiler_state.context_get_result (context);
+}
+
+void
+mono_profiler_call_context_free_buffer (void *buffer)
+{
+ mono_profiler_state.context_free_buffer (buffer);
+}
+
+MonoProfilerCallInstrumentationFlags
+mono_profiler_get_call_instrumentation_flags (MonoMethod *method)
{
MonoProfilerCallInstrumentationFlags flags = MONO_PROFILER_CALL_INSTRUMENTATION_NONE;
flags |= cb (handle->prof, method);
}
- if (entry)
- return flags & MONO_PROFILER_CALL_INSTRUMENTATION_PROLOGUE;
- else
- return flags & MONO_PROFILER_CALL_INSTRUMENTATION_EPILOGUE;
+ return flags;
}
void