diff --git a/src/gc.c b/src/gc.c index 6daa608ae7364c2e324302dfa867e1693927e820..ee64a8ce08b0be438b2e0356f1eb7286062292b1 100644 --- a/src/gc.c +++ b/src/gc.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: gc.c,v 1.253 2004/04/18 02:16:05 mast Exp $ +|| $Id: gc.c,v 1.254 2004/05/23 00:44:34 nilsson Exp $ */ #include "global.h" @@ -33,7 +33,7 @@ struct callback *gc_evaluator_callback=0; #include "block_alloc.h" -RCSID("$Id: gc.c,v 1.253 2004/04/18 02:16:05 mast Exp $"); +RCSID("$Id: gc.c,v 1.254 2004/05/23 00:44:34 nilsson Exp $"); int gc_enabled = 1; @@ -257,6 +257,12 @@ int gc_found_in_type = PIKE_T_UNKNOWN; const char *gc_found_place = NULL; #endif +#ifdef DO_PIKE_CLEANUP +/* To keep the markers after the gc. Only used for the leak report at exit. */ +int gc_keep_markers = 0; +int gc_external_refs_zapped = 0; +#endif + #ifdef PIKE_DEBUG #undef get_marker @@ -340,12 +346,6 @@ static size_t found_ref_count; char *fatal_after_gc=0; -#ifdef DO_PIKE_CLEANUP -/* To keep the markers after the gc. Only used for the leak report at exit. */ -int gc_keep_markers = 0; -int gc_external_refs_zapped = 0; -#endif - #define DESCRIBE_MEM 1 #define DESCRIBE_SHORT 4 #define DESCRIBE_NO_DMALLOC 8 @@ -1592,6 +1592,16 @@ void exit_gc(void) #endif } +#ifdef DO_PIKE_CLEANUP +void gc_check_zapped (void *a, TYPE_T type, const char *file, int line) +{ + struct marker *m = find_marker (a); + if (m && (m->flags & GC_CLEANUP_FREED)) + fprintf (stderr, "Free of leaked %s %p from %s:%d, %d refs remaining\n", + get_name_of_type (type), a, file, line, *(INT32 *)a - 1); +} +#endif + #ifdef PIKE_DEBUG /* This function marks some known externals. The rest are handled by * callbacks added with add_gc_callback. */ @@ -1779,16 +1789,6 @@ int gc_mark_external (void *a, const char *place) return 0; } -#ifdef DO_PIKE_CLEANUP -void gc_check_zapped (void *a, TYPE_T type, const char *file, int line) -{ - struct marker *m = find_marker (a); - if (m && (m->flags & GC_CLEANUP_FREED)) - fprintf (stderr, "Free of leaked %s %p from %s:%d, %d refs remaining\n", - get_name_of_type (type), a, file, line, *(INT32 *)a - 1); -} -#endif - void debug_really_free_gc_frame(struct gc_frame *l) { if (l->frameflags & GC_LINK_FREED) diff --git a/src/gc.h b/src/gc.h index 3c3307e66750c4a8b415f821027d52be9f4a13ab..36a0480d35dfa14345157811700e771a87c4547a 100644 --- a/src/gc.h +++ b/src/gc.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: gc.h,v 1.112 2004/04/18 02:16:05 mast Exp $ +|| $Id: gc.h,v 1.113 2004/05/23 00:44:50 nilsson Exp $ */ #ifndef GC_H @@ -85,7 +85,7 @@ extern int gc_destruct_everything; #define gc_destruct_everything 0 #endif -#if defined (PIKE_DEBUG) && defined (DO_PIKE_CLEANUP) +#if defined (DO_PIKE_CLEANUP) extern int gc_keep_markers; #else #define gc_keep_markers 0 @@ -170,7 +170,7 @@ struct marker * references. Set to 0 during mark pass if a nonweak reference is * found. Decreased during zap weak pass as gc_do_weak_free() is * called. */ -#ifdef PIKE_DEBUG +#ifdef DO_PIKE_CLEANUP INT32 xrefs; /* Known external references. Increased by gc_mark_external(). */ INT32 saved_refs; @@ -241,6 +241,8 @@ struct marker /* The thing has been visited by gc_checked_as_weak(). */ #define GC_WATCHED 0x01000000 /* The thing has been set under watch by gc_watch(). */ +#endif +#ifdef DO_PIKE_CLEANUP #define GC_CLEANUP_FREED 0x02000000 /* The thing was freed by the cleanup code under the assumption that * references were lost. */ diff --git a/src/object.h b/src/object.h index 28ff605e022b6b787908a29f449cbdd0a7715fbb..3a142a6ef1807103f4914018decd19de1408df4a 100644 --- a/src/object.h +++ b/src/object.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: object.h,v 1.84 2004/05/18 09:45:46 vida Exp $ +|| $Id: object.h,v 1.85 2004/05/23 00:45:11 nilsson Exp $ */ #ifndef OBJECT_H @@ -37,6 +37,10 @@ extern struct program *magic_index_program; extern struct program *magic_set_index_program; extern struct program *magic_indices_program; extern struct program *magic_values_program; +#ifdef DO_PIKE_CLEANUP +extern int gc_external_refs_zapped; +void gc_check_zapped (void *a, TYPE_T type, const char *file, int line); +#endif #define free_object(O) do{ \ struct object *o_=(O); \ diff --git a/src/program.h b/src/program.h index 87a81e733f02d170a32272de5245b04a17fa567f..7601b5402c949d32dbaa7137870c999861381c34 100644 --- a/src/program.h +++ b/src/program.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: program.h,v 1.203 2004/05/20 20:13:38 grubba Exp $ +|| $Id: program.h,v 1.204 2004/05/23 00:45:11 nilsson Exp $ */ #ifndef PROGRAM_H @@ -565,6 +565,11 @@ static inline int CHECK_IDREF_RANGE (int x, const struct program *p) #define FIND_LFUN(P,N) ( dmalloc_touch(struct program *,(P))->flags & PROGRAM_FIXED?((P)->lfuns[(N)]):low_find_lfun((P), (N)) ) #define QUICK_FIND_LFUN(P,N) (dmalloc_touch(struct program *,(P))->lfuns[N]) +#ifdef DO_PIKE_CLEANUP +extern int gc_external_refs_zapped; +void gc_check_zapped (void *a, TYPE_T type, const char *file, int line); +#endif + #define free_program(p) do{ \ struct program *_=(p); \ debug_malloc_touch(_); \