Merge pull request #2816 from xmcclure/profile-clean-0
[mono.git] / mono / metadata / profiler.c
index b2620ecf030075854d47d30ca77e767a4958c518..d74a273d085bf0825656642a845a683722b5ea89 100644 (file)
@@ -24,6 +24,7 @@
 #include "mono/metadata/mono-config-dirs.h"
 #include "mono/io-layer/io-layer.h"
 #include "mono/utils/mono-dl.h"
+#include <mono/utils/mono-logger-internals.h>
 #include <string.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -1168,10 +1169,13 @@ load_profiler_from_directory (const char *directory, const char *libname, const
        char *err;
        void *iter;
 
+       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "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_LAZY, &err);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Attempting to load profiler: %s %ssuccessful, err: %s", path, pmodule?"":"not ", err);
                g_free (path);
                g_free (err);
                if (pmodule)
@@ -1250,7 +1254,10 @@ mono_profiler_load (const char *desc)
                }
                if (!load_embedded_profiler (desc, mname)) {
                        libname = g_strdup_printf ("mono-profiler-%s", mname);
-                       if (mono_config_get_assemblies_dir ())
+                       char *profiler_lib_dir = getenv ("MONO_PROFILER_LIB_DIR");
+                       if (profiler_lib_dir)
+                               res = load_profiler_from_directory (profiler_lib_dir, libname, desc);
+                       if (!res && mono_config_get_assemblies_dir ())
                                res = load_profiler_from_directory (mono_assembly_getrootdir (), libname, desc);
                        if (!res)
                                res = load_profiler_from_directory (NULL, libname, desc);