diff --git a/configure.in b/configure.in index b94dd0cab..52ce95a44 100644 --- a/configure.in +++ b/configure.in @@ -35,7 +35,32 @@ if test "x$res" = "xno"; then fi AC_SUBST(fnmatch_libs) - + +# Setting have_valgrind to "no" seems pointless, but we just need to +# put something in as the 4th parameter, so configure doesn't abort +# when valgrind.pc isn't found. +have_valgrind="no" +PKG_CHECK_MODULES(VALGRIND, valgrind >= 2.4.0, have_valgrind=yes, have_valgrind=no) +AC_ARG_ENABLE(valgrind, + [ --enable-valgrind enable valgrind support], [ + if [ test "$enableval" = "yes" ]; then + AC_MSG_RESULT(yes) + have_valgrind="yes" + else + AC_MSG_RESULT(no) + have_valgrind="no" + VALGRIND_CFLAGS="" + VALGRIND_LIBS="" + fi + ], [ + have_valgrind=$have_valgrind + ] +) + +if test x$have_valgrind = "xyes"; then + AC_DEFINE(HAVE_VALGRIND, 1, [Valgrind support]) +fi + MODULE_ARCH="$host_os-$host_cpu" AC_SUBST(MODULE_ARCH) AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture") diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 1e8926c23..7bab8c6df 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -6,6 +6,7 @@ INCLUDES = -I$(includedir) \ @e_cflags@ \ @x_cflags@ \ @cf_cflags@ \ + @VALGRIND_CFLAGS@ \ @EDJE_DEF@ bin_PROGRAMS = \ @@ -148,7 +149,7 @@ enlightenment_SOURCES = \ e_main.c \ $(enlightenment_src) -enlightenment_LDFLAGS = -export-dynamic @e_libs@ @x_libs@ @dlopen_libs@ @cf_libs@ +enlightenment_LDFLAGS = -export-dynamic @e_libs@ @x_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ enlightenment_remote_SOURCES = \ e.h \ diff --git a/src/bin/e_module.c b/src/bin/e_module.c index d78d7a592..fb46e8319 100644 --- a/src/bin/e_module.c +++ b/src/bin/e_module.c @@ -4,6 +4,10 @@ #include "e.h" #include "config.h" +#ifdef HAVE_VALGRIND +# include +#endif + /* TODO List: * * * add module types/classes @@ -65,6 +69,14 @@ int e_module_shutdown(void) { Evas_List *l, *tmp; + +#ifdef HAVE_VALGRIND + /* do a leak check now before we dlclose() all those plugins, cause + * that means we won't get a decent backtrace to leaks in there + */ + VALGRIND_DO_LEAK_CHECK +#endif + for (l = _e_modules; l;) { tmp = l;