diff options
| author | Daniel Colascione | 2013-09-22 18:34:52 -0800 |
|---|---|---|
| committer | Daniel Colascione | 2013-09-22 18:34:52 -0800 |
| commit | a84683fdd5dcb629a59807e78c413e21f21a186d (patch) | |
| tree | 785edb9e32d30a7e7e7f48598aac77e98554169c /src/alloc.c | |
| parent | fb83ea63a5db0fe6c20667532d1019a58d2fc1fd (diff) | |
| download | emacs-a84683fdd5dcb629a59807e78c413e21f21a186d.tar.gz emacs-a84683fdd5dcb629a59807e78c413e21f21a186d.zip | |
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.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 26 |
1 files changed, 26 insertions, 0 deletions
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/>. */ | |||
| 45 | 45 | ||
| 46 | #include <verify.h> | 46 | #include <verify.h> |
| 47 | 47 | ||
| 48 | #if (defined ENABLE_CHECKING && \ | ||
| 49 | defined HAVE_VALGRIND_VALGRIND_H && \ | ||
| 50 | !defined USE_VALGRIND) | ||
| 51 | # define USE_VALGRIND 1 | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #if USE_VALGRIND | ||
| 55 | #include <valgrind/valgrind.h> | ||
| 56 | #include <valgrind/memcheck.h> | ||
| 57 | static int valgrind_p; | ||
| 58 | #endif | ||
| 59 | |||
| 48 | /* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects. | 60 | /* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects. |
| 49 | Doable only if GC_MARK_STACK. */ | 61 | Doable only if GC_MARK_STACK. */ |
| 50 | #if ! GC_MARK_STACK | 62 | #if ! GC_MARK_STACK |
| @@ -4327,6 +4339,11 @@ mark_maybe_object (Lisp_Object obj) | |||
| 4327 | void *po; | 4339 | void *po; |
| 4328 | struct mem_node *m; | 4340 | struct mem_node *m; |
| 4329 | 4341 | ||
| 4342 | #if USE_VALGRIND | ||
| 4343 | if (valgrind_p) | ||
| 4344 | VALGRIND_MAKE_MEM_DEFINED (&obj, sizeof (obj)); | ||
| 4345 | #endif | ||
| 4346 | |||
| 4330 | if (INTEGERP (obj)) | 4347 | if (INTEGERP (obj)) |
| 4331 | return; | 4348 | return; |
| 4332 | 4349 | ||
| @@ -4395,6 +4412,11 @@ mark_maybe_pointer (void *p) | |||
| 4395 | { | 4412 | { |
| 4396 | struct mem_node *m; | 4413 | struct mem_node *m; |
| 4397 | 4414 | ||
| 4415 | #if USE_VALGRIND | ||
| 4416 | if (valgrind_p) | ||
| 4417 | VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p)); | ||
| 4418 | #endif | ||
| 4419 | |||
| 4398 | /* Quickly rule out some values which can't point to Lisp data. | 4420 | /* Quickly rule out some values which can't point to Lisp data. |
| 4399 | USE_LSB_TAG needs Lisp data to be aligned on multiples of GCALIGNMENT. | 4421 | USE_LSB_TAG needs Lisp data to be aligned on multiples of GCALIGNMENT. |
| 4400 | Otherwise, assume that Lisp data is aligned on even addresses. */ | 4422 | Otherwise, assume that Lisp data is aligned on even addresses. */ |
| @@ -6643,6 +6665,10 @@ init_alloc (void) | |||
| 6643 | #endif | 6665 | #endif |
| 6644 | Vgc_elapsed = make_float (0.0); | 6666 | Vgc_elapsed = make_float (0.0); |
| 6645 | gcs_done = 0; | 6667 | gcs_done = 0; |
| 6668 | |||
| 6669 | #if USE_VALGRIND | ||
| 6670 | valgrind_p = RUNNING_ON_VALGRIND; | ||
| 6671 | #endif | ||
| 6646 | } | 6672 | } |
| 6647 | 6673 | ||
| 6648 | void | 6674 | void |