]> git.sesse.net Git - vlc/commitdiff
Avoid dlclose() only when valgrind is running
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 31 Jan 2009 21:00:10 +0000 (23:00 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 31 Jan 2009 21:00:41 +0000 (23:00 +0200)
configure.ac
src/modules/os.c

index ae316156fd7c1b52b07fbe50875c314ac3efcde7..0869ef82775183667248ff740d2ffbe745934dae 100644 (file)
@@ -1565,7 +1565,11 @@ AC_ARG_ENABLE(debug,
 test "${enable_debug}" != "yes" && enable_debug="no"
 AH_TEMPLATE(NDEBUG,
             [Define to 1 if debug code should NOT be compiled])
-AS_IF([test "x${enable_debug}" = "xno"], [AC_DEFINE(NDEBUG)])
+AS_IF([test "x${enable_debug}" = "xno"], [
+  AC_DEFINE(NDEBUG)
+], [
+  AC_CHECK_HEADERS([valgrind/valgrind.h])
+])
 
 dnl
 dnl Allow runing as root (usefull for people runing on embedded platforms)
index 4a8912799533be8bc24249e5d12662685172cf7f..53368e47de6073a14356dd90b7e5f762a59341f9 100644 (file)
@@ -65,6 +65,9 @@
 #       include <dl.h>
 #   endif
 #endif
+#ifdef HAVE_VALGRIND_VALGRIND_H
+# include <valgrind/valgrind.h>
+#endif
 
 /*****************************************************************************
  * Local prototypes
@@ -274,11 +277,11 @@ void module_Unload( module_handle_t handle )
     FreeLibrary( handle );
 
 #elif defined(HAVE_DL_DLOPEN)
-# ifdef NDEBUG
-    dlclose( handle );
-# else
-    (void)handle;
+# ifdef HAVE_VALGRIND_VALGRIND_H
+    if( RUNNING_ON_VALGRIND > 0 )
+        return; /* do not dlclose() so that we get proper stack traces */
 # endif
+    dlclose( handle );
 
 #elif defined(HAVE_DL_SHL_LOAD)
     shl_unload( handle );