Ejemplo n.º 1
0
static gboolean
load_embedded_profiler (const char *desc, const char *name)
{
	char *err = NULL;
	char *symbol;
	MonoDl *pmodule = NULL;
	gboolean result;

	/*
	 * Some profilers (such as ours) may need to call back into the runtime
	 * from their sampling callback (which is called in async-signal context).
	 * They need to be able to know that all references back to the runtime
	 * have been resolved; otherwise, calling runtime functions may result in
	 * invoking the dynamic linker which is not async-signal-safe. Passing
	 * MONO_DL_EAGER will ask the dynamic linker to resolve everything upfront.
	 */
	pmodule = mono_dl_open (NULL, MONO_DL_EAGER, &err);
	if (!pmodule) {
		g_warning ("Could not open main executable (%s)", err);
		g_free (err);
		return FALSE;
	}

	symbol = g_strdup_printf (INITIALIZER_NAME "_%s", name);
	result = load_profiler (pmodule, desc, symbol);
	g_free (symbol);

	return result;
}
Ejemplo n.º 2
0
static gboolean
load_profiler_from_mono_instalation (const char *libname, const char *desc)
{
	char *err = NULL;
	MonoDl *pmodule = mono_dl_open_runtime_lib (libname, MONO_DL_LAZY, &err);
	g_free (err);
	if (pmodule)
		return load_profiler (pmodule, desc, INITIALIZER_NAME);
	return FALSE;
}
Ejemplo n.º 3
0
static gboolean
load_profiler_from_mono_installation (const char *libname, const char *desc)
{
	char *err = NULL;
	MonoDl *pmodule = mono_dl_open_runtime_lib (libname, MONO_DL_EAGER, &err);
	mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, "Attempting to load profiler from runtime libs: %s, %ssuccessful, err: %s", libname, pmodule?"":"not ", err);
	g_free (err);
	if (pmodule)
		return load_profiler (pmodule, desc, INITIALIZER_NAME);
	return FALSE;
}
Ejemplo n.º 4
0
static gboolean
load_profiler_from_directory (const char *directory, const char *libname, const char *desc)
{
	MonoDl *pmodule = NULL;
	char* path;
	char *err;
	void *iter;

	iter = NULL;
	err = NULL;
	while ((path = mono_dl_build_path (directory, libname, &iter))) {
		pmodule = mono_dl_open (path, MONO_DL_LAZY, &err);
		g_free (path);
		g_free (err);
		if (pmodule)
			return load_profiler (pmodule, desc, INITIALIZER_NAME);
	}
		
	return FALSE;
}
Ejemplo n.º 5
0
static gboolean
load_embedded_profiler (const char *desc, const char *name)
{
	char *err = NULL;
	char *symbol;
	MonoDl *pmodule = NULL;
	gboolean result;

	pmodule = mono_dl_open (NULL, MONO_DL_LAZY, &err);
	if (!pmodule) {
		g_warning ("Could not open main executable (%s)", err);
		g_free (err);
		return FALSE;
	}

	symbol = g_strdup_printf (INITIALIZER_NAME "_%s", name);
	result = load_profiler (pmodule, desc, symbol);
	g_free (symbol);

	return result;
}
Ejemplo n.º 6
0
// TODO: Much of the library loading code here is custom. It would be better to merge this with mono-dl
static gboolean
load_profiler_from_directory (const char *directory, const char *libname, const char *desc)
{
	MonoDl *pmodule = NULL;
	char* path;
	char *err;
	void *iter;

	mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, "Attempting to load profiler %s from %s (desc %s)", libname, directory, desc);

	iter = NULL;
	err = NULL;
	while ((path = mono_dl_build_path (directory, libname, &iter))) {
		pmodule = mono_dl_open (path, MONO_DL_EAGER, &err);
		mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, "Attempting to load profiler: %s, %ssuccessful, err: %s", path, pmodule?"":"not ", err);
		g_free (path);
		g_free (err);
		if (pmodule)
			return load_profiler (pmodule, desc, INITIALIZER_NAME);
	}
		
	return FALSE;
}