diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 7b9479139c5e2260f063e5cf785339d3dcaccf1c..1aa03ad9a6a0a11a5b9fa2b09acf0feece874fcd 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: builtin_functions.c,v 1.383 2001/06/27 17:33:42 grubba Exp $"); +RCSID("$Id: builtin_functions.c,v 1.384 2001/06/28 10:24:21 hubbe Exp $"); #include "interpret.h" #include "svalue.h" #include "pike_macros.h" @@ -2197,6 +2197,7 @@ PMOD_EXPORT void f_destruct(INT32 args) if(!CHECK_DATA_SECURITY(o, SECURITY_BIT_DESTRUCT)) Pike_error("Destruct permission denied.\n"); #endif + debug_malloc_touch(o); destruct(o); pop_n_elems(args); destruct_objects_to_destruct(); diff --git a/src/dmalloc.h b/src/dmalloc.h index d5c3a98240bc4f3ded60724bbc68d4e623914ecb..d2d77cf40bd4d70c87262faae1e816915ff62e70 100644 --- a/src/dmalloc.h +++ b/src/dmalloc.h @@ -1,5 +1,5 @@ /* - * $Id: dmalloc.h,v 1.30 2001/02/28 04:25:30 hubbe Exp $ + * $Id: dmalloc.h,v 1.31 2001/06/28 10:24:21 hubbe Exp $ */ PMOD_EXPORT extern char *debug_xalloc(size_t); @@ -46,6 +46,7 @@ extern int debug_malloc_register_fd(int, char *); extern int debug_malloc_close_fd(int, char *); void *debug_malloc_update_location(void *, char *); +void *debug_malloc_update_location_ptr(void *, ptrdiff_t, char *); void search_all_memheaders_for_references(void); /* Beware! names of named memory regions are never ever freed!! /Hubbe */ @@ -67,6 +68,8 @@ char *dmalloc_find_name(void *p); #define DO_IF_DMALLOC(X) X #define debug_malloc_touch(X) debug_malloc_update_location((X),DMALLOC_LOCATION()) #define debug_malloc_pass(X) debug_malloc_update_location((X),DMALLOC_LOCATION()) +#define dmalloc_touch_struct_ptr(TYPE,X,MEMBER) ((TYPE)debug_malloc_update_location_ptr((X), ((ptrdiff_t)& (((TYPE)0)->MEMBER)), DMALLOC_LOCATION())) + #define xalloc(X) ((char *)debug_malloc_pass(debug_xalloc(X))) #define xfree(X) debug_xfree(debug_malloc_pass((X))) void debug_malloc_dump_references(void *x, int indent, int depth, int flags); @@ -129,6 +132,7 @@ int dmalloc_is_invalid_memory_block(void *block); #define debug_malloc_copy_names(p,p2) 0 #define search_all_memheaders_for_references() #define dmalloc_find_name(X) "unknown (no dmalloc)" +#define dmalloc_touch_struct_ptr(TYPE,X,MEMBER) (X) #ifdef DMALLOC_TRACE #define debug_malloc_update_location(X,Y) (DMALLOC_TRACE_LOG(DMALLOC_LOCATION()),(X)) diff --git a/src/gc.c b/src/gc.c index 755e9fafa3482133d33e6f869c11340da2c5ae8b..38e5037de96201cc4aff6de152b4c4a99779aa0a 100644 --- a/src/gc.c +++ b/src/gc.c @@ -30,7 +30,7 @@ struct callback *gc_evaluator_callback=0; #include "block_alloc.h" -RCSID("$Id: gc.c,v 1.155 2001/06/27 02:06:41 hubbe Exp $"); +RCSID("$Id: gc.c,v 1.156 2001/06/28 10:24:21 hubbe Exp $"); /* Run garbage collect approximately every time * 20 percent of all arrays, objects and programs is @@ -690,8 +690,9 @@ void low_describe_something(void *a, low_describe_something(p, T_PROGRAM, indent, depth, flags); } - if(p && (p->flags & PROGRAM_USES_PARENT) && - PARENT_INFO(((struct object *)a))->parent) + if(p && + (p->flags & PROGRAM_USES_PARENT) && + LOW_PARENT_INFO(((struct object *)a),p)->parent) { fprintf(stderr,"%*s**Describing object's parent:\n",indent,""); describe_something( PARENT_INFO((struct object *)a)->parent, t, indent+2,depth-1, diff --git a/src/object.c b/src/object.c index 68db4d7c5991fdc132cca4d2ad1f05ca91712b1f..ad080f8322aecb9d7656ce8a1b70be627b7d2f00 100644 --- a/src/object.c +++ b/src/object.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: object.c,v 1.171 2001/06/23 21:52:10 hubbe Exp $"); +RCSID("$Id: object.c,v 1.172 2001/06/28 10:24:22 hubbe Exp $"); #include "object.h" #include "dynamic_buffer.h" #include "interpret.h" @@ -492,6 +492,7 @@ PMOD_EXPORT struct program *get_program_for_object_being_destructed(struct objec static void call_destroy(struct object *o, int foo) { int e; + debug_malloc_touch(o); if(!o || !o->prog) { #ifdef GC_VERBOSE if (Pike_in_gc > GC_PASS_PREPARE) @@ -630,6 +631,7 @@ void destruct(struct object *o) { if(LOW_PARENT_INFO(o,p)->parent) { + debug_malloc_touch(o); /* fprintf(stderr, "destruct(): Zapping parent.\n"); */ free_object(LOW_PARENT_INFO(o,p)->parent); LOW_PARENT_INFO(o,p)->parent=0; @@ -678,6 +680,8 @@ PMOD_EXPORT void destruct_objects_to_destruct(void) #endif next = o->next; + debug_malloc_touch(o); + debug_malloc_touch(next); /* Link object back to list of objects */ DOUBLELINK(first_object,o); @@ -1528,6 +1532,7 @@ void gc_free_all_unreferenced_objects(void) !find_destroy_called_mark(o)) gc_fatal(o,0,"Can't free a live object in gc_free_all_unreferenced_objects().\n"); #endif + debug_malloc_touch(o); destruct(o); gc_free_extra_ref(o); diff --git a/src/pike_memory.c b/src/pike_memory.c index 298279ca7fb8796185f599e3b384eab25e7018d9..a3d644b962add6405be0c9c1ab126ad328b90030 100644 --- a/src/pike_memory.c +++ b/src/pike_memory.c @@ -10,7 +10,7 @@ #include "pike_macros.h" #include "gc.h" -RCSID("$Id: pike_memory.c,v 1.105 2001/06/26 21:03:50 hubbe Exp $"); +RCSID("$Id: pike_memory.c,v 1.106 2001/06/28 10:24:22 hubbe Exp $"); /* strdup() is used by several modules, so let's provide it */ #ifndef HAVE_STRDUP @@ -2123,6 +2123,16 @@ void * debug_malloc_update_location(void *p,LOCATION location) return p; } +void * debug_malloc_update_location_ptr(void *p, + ptrdiff_t offset, + LOCATION location) +{ + if(p) + debug_malloc_update_location(*(void **)(((char *)p)+offset), location); + return p; +} + + /* another shared-string table... */ struct dmalloc_string { diff --git a/src/program.c b/src/program.c index c0a908d68194b9c154b2797fe26c01bd2dbf4adf..0b956316fbf789d29bbe5f0fde7626bf6e9aaf32 100644 --- a/src/program.c +++ b/src/program.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: program.c,v 1.333 2001/06/23 21:52:10 hubbe Exp $"); +RCSID("$Id: program.c,v 1.334 2001/06/28 10:24:22 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -4054,6 +4054,7 @@ struct program *compile(struct pike_string *prog, /* fprintf(stderr, "Placeholder already has storage!\n" "placeholder: %p, storage: %p, prog: %p, p: %p\n", placeholder, placeholder->storage, placeholder->prog, p); */ + debug_malloc_touch(placeholder); destruct(placeholder); } else { /* FIXME: Is this correct? */ @@ -4164,6 +4165,7 @@ struct program *compile(struct pike_string *prog, /* fprintf(stderr, "Placeholder already has storage!\n" "placeholder: %p, storage: %p, prog: %p, p: %p\n", placeholder, placeholder->storage, placeholder->prog, p); */ + debug_malloc_touch(placeholder); destruct(placeholder); } else { /* FIXME: Is this correct? */