diff options
| author | Daniel Colascione <dancol@dancol.org> | 2013-09-22 18:34:52 -0800 |
|---|---|---|
| committer | Daniel Colascione <dancol@dancol.org> | 2013-09-22 18:34:52 -0800 |
| commit | a84683fdd5dcb629a59807e78c413e21f21a186d (patch) | |
| tree | 785edb9e32d30a7e7e7f48598aac77e98554169c | |
| parent | fb83ea63a5db0fe6c20667532d1019a58d2fc1fd (diff) | |
| download | emacs-a84683fdd5dcb629a59807e78c413e21f21a186d.tar.gz | |
Tell valgrind about conservative GC regions and suppress spurious
warings.
* alloc.c (USE_VALGRIND): New macro; on by default
when ENABLE_CHECKING.
(mark_maybe_object,mark_maybe_pointer)
[USE_VALGRIND]: Mark conservatively-scanned regions valid for
valgrind purposes.
(valgrind_p) [USE_VALGRIND]: New variable.
(init_alloc) [USE_VALGRIND]: Initialize valgrind_p.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/alloc.c | 26 |
4 files changed, 42 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index ad6163cd7f0..67f3f926b9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-09-23 Daniel Colascione <dancol@dancol.org> + + * configure.ac: Check for valgrind headers. + 2013-09-20 Xue Fuqiao <xfq.free@gmail.com> * INSTALL: New homepage of libtiff. diff --git a/configure.ac b/configure.ac index 8ff33e779a8..c63627d18d4 100644 --- a/configure.ac +++ b/configure.ac @@ -3696,6 +3696,8 @@ AC_SUBST(KRB5LIB) AC_SUBST(DESLIB) AC_SUBST(KRB4LIB) +AC_CHECK_HEADERS(valgrind/valgrind.h) + AC_CHECK_FUNCS_ONCE(tzset) AC_MSG_CHECKING(whether localtime caches TZ) AC_CACHE_VAL(emacs_cv_localtime_cache, diff --git a/src/ChangeLog b/src/ChangeLog index a466047718f..9905f61e8da 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2013-09-23 Daniel Colascione <dancol@dancol.org> + + * alloc.c (USE_VALGRIND): New macro; on by default + when ENABLE_CHECKING. + (mark_maybe_object,mark_maybe_pointer) + [USE_VALGRIND]: Mark conservatively-scanned regions valid for + valgrind purposes. + (valgrind_p) [USE_VALGRIND]: New variable. + (init_alloc) [USE_VALGRIND]: Initialize valgrind_p. + 2013-09-22 Jan Djärv <jan.h.d@swipnet.se> * process.c (wait_reading_process_output): Change int pnamelen to diff --git a/src/alloc.c b/src/alloc.c index 847b3c88bbe..564faa18aa8 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -45,6 +45,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <verify.h> +#if (defined ENABLE_CHECKING && \ + defined HAVE_VALGRIND_VALGRIND_H && \ + !defined USE_VALGRIND) +# define USE_VALGRIND 1 +#endif + +#if USE_VALGRIND +#include <valgrind/valgrind.h> +#include <valgrind/memcheck.h> +static int valgrind_p; +#endif + /* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects. Doable only if GC_MARK_STACK. */ #if ! GC_MARK_STACK @@ -4327,6 +4339,11 @@ mark_maybe_object (Lisp_Object obj) void *po; struct mem_node *m; +#if USE_VALGRIND + if (valgrind_p) + VALGRIND_MAKE_MEM_DEFINED (&obj, sizeof (obj)); +#endif + if (INTEGERP (obj)) return; @@ -4395,6 +4412,11 @@ mark_maybe_pointer (void *p) { struct mem_node *m; +#if USE_VALGRIND + if (valgrind_p) + VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); +#endif + /* Quickly rule out some values which can't point to Lisp data. USE_LSB_TAG needs Lisp data to be aligned on multiples of GCALIGNMENT. Otherwise, assume that Lisp data is aligned on even addresses. */ @@ -6643,6 +6665,10 @@ init_alloc (void) #endif Vgc_elapsed = make_float (0.0); gcs_done = 0; + +#if USE_VALGRIND + valgrind_p = RUNNING_ON_VALGRIND; +#endif } void |
