[profiler] Include vtune support for jitted methods in the build system.
authorVlad Brezae <brezaevlad@gmail.com>
Sat, 18 Oct 2014 03:46:04 +0000 (20:46 -0700)
committerVlad Brezae <brezaevlad@gmail.com>
Mon, 5 Jan 2015 22:19:50 +0000 (14:19 -0800)
In order to track emitted code with vtune you need to :
* pass --enable-vtune=yes to autogen.sh
* have in the LD_LIBRARY_PATH the path to the profiler libraries (ex $(installation_folder)/lib)
* pass argument --profiler=vtune to mono

configure.ac
mono/profiler/Makefile.am
mono/profiler/mono-profiler-vtune.c

index c00b84d55b3d6686f92451bfcae200679c89735e..50eaa44960f52dd26e9e169d984799715d29033a 100644 (file)
@@ -2878,6 +2878,46 @@ SPARC64)
        ;;
 esac
 
+dnl *************
+dnl *** VTUNE ***
+dnl *************
+
+AC_ARG_ENABLE(vtune,[  --enable-vtune  Enable the VTUNE back-end], enable_vtune=$enableval, enable_vtune=no)
+AC_ARG_WITH(vtune, [  --with-vtune=<vtune prefix>      Enable jit vtune profiling], enable_vtune=yes,)
+
+AM_CONDITIONAL(HAVE_VTUNE, test x$enable_vtune = xyes)
+
+if test "x$enable_vtune" = "xyes"; then
+       if test "x$with_vtune" = "x"; then
+               VTUNE_PATH=/opt/intel/vtune_amplifier_xe
+       else
+               VTUNE_PATH=$with_vtune
+       fi
+       VTUNE_INCLUDE=$VTUNE_PATH/include
+       case "$TARGET" in
+       X86)
+               VTUNE_LIB=$VTUNE_PATH/lib32
+               ;;
+       AMD64)
+               VTUNE_LIB=$VTUNE_PATH/lib64
+               ;;
+       *)
+               AC_MSG_ERROR([Unsupported target $TARGET for VTUNE.])
+               ;;
+       esac
+       if test ! -f $VTUNE_INCLUDE/jitprofiling.h; then
+               AC_MSG_ERROR([VTUNE $VTUNE_INCLUDE/jitprofiling.h not found.])
+       fi
+       if test ! -f $VTUNE_LIB/libjitprofiling.a; then
+               AC_MSG_ERROR([VTUNE $VTUNE_LIB/libjitprofiling.a not found.])
+       fi
+
+       VTUNE_CFLAGS=-I$VTUNE_INCLUDE
+       VTUNE_LIBS="-L/$VTUNE_LIB/ -ljitprofiling"
+
+       AC_SUBST(VTUNE_LIBS)
+       AC_SUBST(VTUNE_CFLAGS)
+fi
 dnl Use GCC atomic ops if they work on the target.
 if test x$GCC = "xyes"; then
        case $TARGET in
index 2c00ac36c7239d56be0fba8b28b0c88f86d74682..07634ef6b9635c3f1335f7789e1f7695e676aca5 100644 (file)
@@ -12,7 +12,13 @@ AM_CPPFLAGS = \
 if !DISABLE_LIBRARIES
 if !DISABLE_PROFILER
 bin_PROGRAMS = mprof-report
-lib_LTLIBRARIES = libmono-profiler-cov.la libmono-profiler-aot.la libmono-profiler-iomap.la libmono-profiler-log.la
+
+if HAVE_VTUNE
+vtune_lib = libmono-profiler-vtune.la
+endif
+
+lib_LTLIBRARIES = libmono-profiler-cov.la libmono-profiler-aot.la libmono-profiler-iomap.la libmono-profiler-log.la $(vtune_lib)
+
 if PLATFORM_DARWIN
 libmono_profiler_log_la_LDFLAGS = -Wl,-undefined -Wl,suppress -Wl,-flat_namespace
 endif
@@ -57,6 +63,11 @@ libmono_profiler_iomap_la_SOURCES = mono-profiler-iomap.c
 libmono_profiler_iomap_la_LIBADD = $(LIBMONO) $(GLIB_LIBS) $(LIBICONV)
 libmono_profiler_log_la_SOURCES = proflog.c
 libmono_profiler_log_la_LIBADD = $(LIBMONO) $(Z_LIBS)
+if HAVE_VTUNE
+libmono_profiler_vtune_la_SOURCES = mono-profiler-vtune.c
+libmono_profiler_vtune_la_CFLAGS = $(VTUNE_CFLAGS)
+libmono_profiler_vtune_la_LIBADD = $(VTUNE_LIBS) $(LIBMONO) $(GLIB_LIBS) $(LIBICONV)
+endif
 
 if PLATFORM_ANDROID
 libmono_profiler_log_la_LIBADD += $(GLIB_LIBS)
index dafd100acccb3d1361ec5fbe75f68af16a978d09..e5c6f73e9fda88815dbe52169bae2f197125b028 100644 (file)
@@ -37,7 +37,7 @@
 
 #define bool char
 
-#include "jitprofiling.h"
+#include <jitprofiling.h>
 
 /* called at the end of the program */
 static void
@@ -51,7 +51,6 @@ method_jit_result (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, i
        if (result == MONO_PROFILE_OK) {
                int i;
                MonoDebugSourceLocation *sourceLoc;
-               MonoDebugMethodInfo *methodDebugInfo;
                MonoDebugMethodJitInfo *dmji;
                MonoClass *klass = mono_method_get_class (method);
                char *signature = mono_signature_get_desc (mono_method_signature (method), TRUE);