comparison src/alloc.c @ 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 73e8632018ad
children ae81a2c00f4f
comparison
equal deleted inserted replaced
4802:2fc0e2f18322 4803:5d120deb60ca
68 #endif /* NEW_GC */ 68 #endif /* NEW_GC */
69 #include "console-stream.h" 69 #include "console-stream.h"
70 70
71 #ifdef DOUG_LEA_MALLOC 71 #ifdef DOUG_LEA_MALLOC
72 #include <malloc.h> 72 #include <malloc.h>
73 #endif
74 #ifdef USE_VALGRIND
75 #include <valgrind/memcheck.h>
73 #endif 76 #endif
74 77
75 EXFUN (Fgarbage_collect, 0); 78 EXFUN (Fgarbage_collect, 0);
76 79
77 #if 0 /* this is _way_ too slow to be part of the standard debug options */ 80 #if 0 /* this is _way_ too slow to be part of the standard debug options */
4697 { 4700 {
4698 return make_int (total_gc_usage + consing_since_gc); 4701 return make_int (total_gc_usage + consing_since_gc);
4699 } 4702 }
4700 #endif /* ALLOC_TYPE_STATS */ 4703 #endif /* ALLOC_TYPE_STATS */
4701 4704
4705 #ifdef USE_VALGRIND
4706 DEFUN ("valgrind-leak-check", Fvalgrind_leak_check, 0, 0, "", /*
4707 Ask valgrind to perform a memory leak check.
4708 The results of the leak check are sent to stderr.
4709 */
4710 ())
4711 {
4712 VALGRIND_DO_LEAK_CHECK;
4713 return Qnil;
4714 }
4715
4716 DEFUN ("valgrind-quick-leak-check", Fvalgrind_quick_leak_check, 0, 0, "", /*
4717 Ask valgrind to perform a quick memory leak check.
4718 This just prints a summary of leaked memory, rather than all the details.
4719 The results of the leak check are sent to stderr.
4720 */
4721 ())
4722 {
4723 VALGRIND_DO_QUICK_LEAK_CHECK;
4724 return Qnil;
4725 }
4726 #endif /* USE_VALGRIND */
4727
4702 void 4728 void
4703 recompute_funcall_allocation_flag (void) 4729 recompute_funcall_allocation_flag (void)
4704 { 4730 {
4705 funcall_allocation_flag = 4731 funcall_allocation_flag =
4706 need_to_garbage_collect || 4732 need_to_garbage_collect ||
5051 #if 0 5077 #if 0
5052 DEFSUBR (Fmemory_limit); 5078 DEFSUBR (Fmemory_limit);
5053 #endif 5079 #endif
5054 DEFSUBR (Ftotal_memory_usage); 5080 DEFSUBR (Ftotal_memory_usage);
5055 DEFSUBR (Fconsing_since_gc); 5081 DEFSUBR (Fconsing_since_gc);
5082 #ifdef USE_VALGRIND
5083 DEFSUBR (Fvalgrind_leak_check);
5084 DEFSUBR (Fvalgrind_quick_leak_check);
5085 #endif
5056 } 5086 }
5057 5087
5058 void 5088 void
5059 vars_of_alloc (void) 5089 vars_of_alloc (void)
5060 { 5090 {