Mercurial > hg > xemacs-beta
changeset 4803:5d120deb60ca
Enable rudimentary support for valgrind, including functions that tell valgrind
to do a leak check at runtime. See xemacs-patches message with ID
<870180fe1001060942k2b06ef1bn2631c5f226b5e6b2@mail.gmail.com>.
author | Jerry James <james@xemacs.org> |
---|---|
date | Wed, 06 Jan 2010 10:44:06 -0700 |
parents | 2fc0e2f18322 |
children | 3be2c7c0ef4b |
files | ChangeLog configure configure.ac man/ChangeLog man/internals/internals.texi src/ChangeLog src/alloc.c src/config.h.in |
diffstat | 8 files changed, 88 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jan 06 10:01:14 2010 -0700 +++ b/ChangeLog Wed Jan 06 10:44:06 2010 -0700 @@ -1,3 +1,8 @@ +2010-01-06 Jerry James <james@xemacs.org> + + * configure.ac: Add --with-valgrind option. + * configure: Regenerate. + 2009-12-21 Jerry James <james@xemacs.org> * INSTALL: Remove references to OffiX.
--- a/configure Wed Jan 06 10:01:14 2010 -0700 +++ b/configure Wed Jan 06 10:44:06 2010 -0700 @@ -1062,6 +1062,8 @@ with_quantify enable_purify with_purify +enable_valgrind +with_valgrind with_x ' ac_precious_vars='build_alias @@ -2030,6 +2032,7 @@ trigger bugs in some compilers. --with-quantify Support performance debugging using Quantify. --with-purify Support memory debugging using Purify. + --with-valgrind Support memory debugging using Valgrind. Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -4753,6 +4756,22 @@ withval="$with_purify" fi; +# If --with-valgrind or --without-valgrind were given then copy the value to the +# equivalent enable_valgrind variable. +if test "${with_valgrind+set}" = set; then + enable_valgrind="$with_valgrind" +fi; +# If -enable-valgrind or --disable-valgrind were given then copy the value to the +# equivalent with_valgrind variable. +if test "${enable_valgrind+set}" = set; then + with_valgrind="$enable_valgrind" +fi; +# Check whether --with-valgrind or --without-valgrind was given. +if test "${with_valgrind+set}" = set; then + enableval="$with_valgrind" + withval="$with_valgrind" + +fi; if test "$with_purify" = "yes" -o "$with_quantify" = "yes"; then test "$with_system_malloc" = "default" && with_system_malloc=yes @@ -40927,6 +40946,10 @@ #define QUANTIFY 1 _ACEOF +test "$with_valgrind" = "yes" && cat >>confdefs.h <<\_ACEOF +#define USE_VALGRIND 1 +_ACEOF + test "$with_pop" = "yes" && cat >>confdefs.h <<\_ACEOF #define MAIL_USE_POP 1 _ACEOF @@ -41254,6 +41277,7 @@ echo " WARNING: Error checking is on by default for XEmacs beta releases." echo " WARNING: ---------------------------------------------------------" fi +test "$with_valgrind" = yes && echo " Compiling in support for memory debugging with Valgrind." echo "" ) | tee -a Installation echo ""
--- a/configure.ac Wed Jan 06 10:01:14 2010 -0700 +++ b/configure.ac Wed Jan 06 10:44:06 2010 -0700 @@ -1014,6 +1014,9 @@ XE_MERGED_ARG([purify], AS_HELP_STRING([--with-purify],[Support memory debugging using Purify.]), [], []) +XE_MERGED_ARG([valgrind], + AS_HELP_STRING([--with-valgrind],[Support memory debugging using Valgrind.]), + [], []) dnl ------------------------------------------------------------------------- dnl Final command line argument checks. @@ -5490,6 +5493,7 @@ test "$enable_quick_build" = "yes" && AC_DEFINE(QUICK_BUILD) test "$with_purify" = "yes" && AC_DEFINE(PURIFY) test "$with_quantify" = "yes" && AC_DEFINE(QUANTIFY) +test "$with_valgrind" = "yes" && AC_DEFINE(USE_VALGRIND) test "$with_pop" = "yes" && AC_DEFINE(MAIL_USE_POP) test "$with_kerberos" = "yes" && AC_DEFINE(KERBEROS) test "$with_hesiod" = "yes" && AC_DEFINE(HESIOD) @@ -5805,6 +5809,7 @@ echo " WARNING: Error checking is on by default for XEmacs beta releases." echo " WARNING: ---------------------------------------------------------" fi +test "$with_valgrind" = yes && echo " Compiling in support for memory debugging with Valgrind." echo "" ) | tee -a Installation dnl echo "The above configure report is appended to \"Installation\" file."
--- a/man/ChangeLog Wed Jan 06 10:01:14 2010 -0700 +++ b/man/ChangeLog Wed Jan 06 10:44:06 2010 -0700 @@ -1,3 +1,8 @@ +2010-01-06 Jerry James <james@xemacs.org> + + * internals/internals.texi (Debugging and Testing): Document + valgrind configuration and use. + 2009-12-21 Jerry James <james@xemacs.rg> * internals/internals.texi (A Summary of the Various XEmacs Modules):
--- a/man/internals/internals.texi Wed Jan 06 10:01:14 2010 -0700 +++ b/man/internals/internals.texi Wed Jan 06 10:44:06 2010 -0700 @@ -6225,6 +6225,13 @@ temacs -batch -l loadup.el run-temacs @var{xemacs-args...} @end example +@cindex Valgrind +To make an XEmacs that can tell valgrind to do a memory leak check at +runtime, configure @code{--with-valgrind}. If XEmacs has been +configured @code{--with-newgc}, then valgrind must be invoked with +@code{--vex-iropt-precise-memory-exns=yes} in order to handle signals +properly. + @cindex error checking Before you go through the trouble, are you compiling with all debugging and error-checking off? If not, try that first. Be warned
--- a/src/ChangeLog Wed Jan 06 10:01:14 2010 -0700 +++ b/src/ChangeLog Wed Jan 06 10:44:06 2010 -0700 @@ -1,3 +1,11 @@ +2010-01-06 Jerry James <james@xemacs.org> + + * alloc.c: Include valgrind header if USE_VALGRIND. + (Fvalgrind_leak_check): New function. + (Fvalgrind_quick_leak_check): New function. + (syms_of_alloc): Declare the new functions. + * config.h.in (USE_VALGRIND): New define. + 2010-01-06 Jerry James <james@xemacs.org> * emacs.c: Fix FSF address.
--- a/src/alloc.c Wed Jan 06 10:01:14 2010 -0700 +++ b/src/alloc.c Wed Jan 06 10:44:06 2010 -0700 @@ -71,6 +71,9 @@ #ifdef DOUG_LEA_MALLOC #include <malloc.h> #endif +#ifdef USE_VALGRIND +#include <valgrind/memcheck.h> +#endif EXFUN (Fgarbage_collect, 0); @@ -4699,6 +4702,29 @@ } #endif /* ALLOC_TYPE_STATS */ +#ifdef USE_VALGRIND +DEFUN ("valgrind-leak-check", Fvalgrind_leak_check, 0, 0, "", /* +Ask valgrind to perform a memory leak check. +The results of the leak check are sent to stderr. +*/ + ()) +{ + VALGRIND_DO_LEAK_CHECK; + return Qnil; +} + +DEFUN ("valgrind-quick-leak-check", Fvalgrind_quick_leak_check, 0, 0, "", /* +Ask valgrind to perform a quick memory leak check. +This just prints a summary of leaked memory, rather than all the details. +The results of the leak check are sent to stderr. +*/ + ()) +{ + VALGRIND_DO_QUICK_LEAK_CHECK; + return Qnil; +} +#endif /* USE_VALGRIND */ + void recompute_funcall_allocation_flag (void) { @@ -5053,6 +5079,10 @@ #endif DEFSUBR (Ftotal_memory_usage); DEFSUBR (Fconsing_since_gc); +#ifdef USE_VALGRIND + DEFSUBR (Fvalgrind_leak_check); + DEFSUBR (Fvalgrind_quick_leak_check); +#endif } void
--- a/src/config.h.in Wed Jan 06 10:01:14 2010 -0700 +++ b/src/config.h.in Wed Jan 06 10:44:06 2010 -0700 @@ -647,6 +647,10 @@ It is only intended for use by the developers. */ #undef PURIFY +/* Define USE_VALGRIND to compile valgrind hints into the code. + It is only intended for use by the developers. */ +#undef USE_VALGRIND + /* Define EXTERNAL_WIDGET to compile support for using the editor as a widget within another program. */ #undef EXTERNAL_WIDGET