2003-03-30
2003-03-30 03:00:00 by Martin Stjernholm <mast@lysator.liu.se>
-
a12b8c6d53046b1cec72f3b340605503ab96aef9
(67 lines)
(+51/-16)
[
Show
| Annotate
]
Branch: 7.9
Use the gc marks to report more accurately on leaked things.
Rev: src/gc.c:1.212
Rev: src/gc.h:1.100
Rev: src/main.c:1.169
Rev: src/object.c:1.232
2:
|| 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.211 2003/03/30 01:34:53 mast Exp $
+ || $Id: gc.c,v 1.212 2003/03/30 02:08:08 mast Exp $
*/
#include "global.h"
33:
#include "block_alloc.h"
- RCSID("$Id: gc.c,v 1.211 2003/03/30 01:34:53 mast Exp $");
+ RCSID("$Id: gc.c,v 1.212 2003/03/30 02:08:08 mast Exp $");
int gc_enabled = 1;
321:
void *gc_svalue_location=0;
char *fatal_after_gc=0;
+ #ifdef DEBUG_MALLOC
+
+ /* To keep the markers after the gc. Only used for the dmalloc leak
+ * report at exit. */
+ int gc_keep_markers = 0;
+
+ int gc_external_refs_zapped = 0;
+
+ #endif
+
#define DESCRIBE_MEM 1
#define DESCRIBE_NO_REFS 2
#define DESCRIBE_SHORT 4
1313:
return ret;
}
+ static void cleanup_markers (void)
+ {
+ #ifdef DO_PIKE_CLEANUP
+ size_t e=0;
+ struct marker *h;
+ for(e=0;e<marker_hash_table_size;e++)
+ while(marker_hash_table[e])
+ remove_marker(marker_hash_table[e]->data);
+ #endif
+ exit_marker_hash();
+ }
+
+
static void init_gc(void)
{
#ifdef PIKE_DEBUG
if (!gc_is_watching) {
#endif
-
+ #ifdef DEBUG_MALLOC
+ /* The marker hash table is left around after a previous gc if
+ * gc_keep_markers is set. */
+ if (marker_hash_table) cleanup_markers();
+ #endif
+
low_init_marker_hash(num_objects);
get_marker(rec_list.data); /* Used to simplify fencepost conditions. */
#ifdef PIKE_DEBUG
1327:
static void exit_gc(void)
{
- #ifdef DO_PIKE_CLEANUP
- size_t e=0;
- struct marker *h;
- for(e=0;e<marker_hash_table_size;e++)
- while(marker_hash_table[e])
- remove_marker(marker_hash_table[e]->data);
+ #ifdef DEBUG_MALLOC
+ if (!gc_keep_markers)
#endif
-
+ cleanup_markers();
+
+ free_all_gc_frame_blocks();
+
+ #ifdef GC_VERBOSE
+ num_gc_frames = 0;
+ #endif
+
#ifdef PIKE_DEBUG
if (gc_is_watching) {
fprintf(stderr, "## Exiting gc and resetting watches for %d things.\n",
1341: Inside #if defined(PIKE_DEBUG)
gc_is_watching = 0;
}
#endif
- exit_marker_hash();
- free_all_gc_frame_blocks();
- #ifdef GC_VERBOSE
- num_gc_frames = 0;
- #endif
+
}
#ifdef PIKE_DEBUG
1417: Inside #if defined(PIKE_DEBUG)
if(i) exit_gc();
d_flag=tmp;
}
- #endif
+
- #ifdef PIKE_DEBUG
-
+
void debug_gc_add_extra_ref(void *a)
{
struct marker *m;
1536: Inside #if defined(PIKE_DEBUG)
if (Pike_in_gc != GC_PASS_CHECK)
Pike_fatal("gc_external_mark() called in invalid gc pass.\n");
+ #ifdef DEBUG_MALLOC
+ if (gc_external_refs_zapped) {
+ fprintf (stderr, "One external ref to %p found%s.\n",
+ a, where ? where : "");
+ if (in) describe (in);
+ return 0;
+ }
+ #endif
+
m=get_marker(a);
m->xrefs++;
m->flags|=GC_XREFERENCED;