From 0b694455d53f33112c8474a9fba2846c73b49051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Mon, 19 Jan 1998 16:43:14 -0800 Subject: [PATCH] more debug in gc() Rev: src/gc.c:1.26 Rev: src/gc.h:1.15 Rev: src/program.c:1.51 --- src/gc.c | 32 ++++++++++++++++++++++++++++---- src/gc.h | 2 ++ src/program.c | 20 +++++++++++--------- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/gc.c b/src/gc.c index 39518ac5de..f96489e0c0 100644 --- a/src/gc.c +++ b/src/gc.c @@ -157,10 +157,6 @@ TYPE_T attempt_to_identify(void *something) if(p==(struct program *)something) return T_PROGRAM; - for(m=first_mapping;m;m=m->next) - if(m==(struct program *)something) - return T_MAPPING; - for(m=first_mapping;m;m=m->next) if(m==(struct mapping *)something) return T_MAPPING; @@ -188,6 +184,22 @@ void describe_location(void *memblock, TYPE_T type, void *location) switch(type) { + case T_PROGRAM: + { + struct program *p=(struct program *)memblock; + char *ptr=(char *)location; + if(ptr >= (char *)p->inherits && ptr<(char*)(p->inherits+p->num_inherits)) + fprintf(stderr,"**In inherit block.\n"); + + if(ptr >= (char *)p->strings && ptr<(char*)(p->strings+p->num_strings)) + fprintf(stderr,"**In string block.\n"); + + if(ptr >= (char *)p->identifiers && ptr<(char*)(p->identifiers+p->num_identifiers)) + fprintf(stderr,"**In identifier block.\n"); + + return; + } + case T_OBJECT: { struct object *o=(struct object *)memblock; @@ -260,6 +272,18 @@ void debug_gc_check_short_svalue(union anything *u, TYPE_T type, TYPE_T t, void found_in=0; } + +int debug_gc_check(void *x, TYPE_T t, void *data) +{ + int ret; + found_in=data; + found_in_type=t; + ret=gc_check(x); + found_in_type=T_UNKNOWN; + found_in=0; + return ret; +} + void describe_something(void *a, int t) { struct program *p=(struct program *)a; diff --git a/src/gc.h b/src/gc.h index 5549738311..7f7be54e47 100644 --- a/src/gc.h +++ b/src/gc.h @@ -34,6 +34,7 @@ void describe_location(void *memblock, TYPE_T type, void *location); void debug_gc_xmark_svalues(struct svalue *s, int num, char *fromwhere); TYPE_FIELD debug_gc_check_svalues(struct svalue *s, int num, TYPE_T t, void *data); void debug_gc_check_short_svalue(union anything *u, TYPE_T type, TYPE_T t, void *data); +int debug_gc_check(void *x, TYPE_T t, void *data); void describe_something(void *a, int t); INT32 gc_check(void *a); int gc_is_referenced(void *a); @@ -49,6 +50,7 @@ void do_gc(void); #define debug_gc_check_svalues(S,N,T,V) gc_check_svalues(S,N) #define debug_gc_check_short_svalue(S,N,T,V) gc_check_short_svalue(S,N) #define debug_gc_xmark_svalue(S,N,X) gc_xmark_svalue(S,N) +#define debug_gc_check(VP,T,V) gc_check(VP) #define GC_FREE() do { num_objects-- ; }while(0) #endif diff --git a/src/program.c b/src/program.c index a89e745385..a4d2602fe6 100644 --- a/src/program.c +++ b/src/program.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: program.c,v 1.50 1998/01/16 23:02:40 hubbe Exp $"); +RCSID("$Id: program.c,v 1.51 1998/01/20 00:43:14 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -1858,41 +1858,43 @@ void gc_check_all_programs(void) for(p=first_program;p;p=p->next) { int e; - gc_check_svalues(p->constants, p->num_constants); + debug_gc_check_svalues(p->constants, p->num_constants, T_PROGRAM, p); for(e=0;e<p->num_inherits;e++) { if(p->inherits[e].parent) { #ifdef DEBUG - if(gc_check(p->inherits[e].parent)==-2) + if(debug_gc_check(p->inherits[e].parent,T_PROGRAM,p)==-2) fprintf(stderr,"(program at 0x%lx -> inherit[%d].parent)\n", (long)p, e); #else - gc_check(p->inherits[e].parent); + debug_gc_check(p->inherits[e].parent, T_PROGRAM, p); #endif } if(d_flag && p->inherits[e].name) - gc_check(p->inherits[e].name); + debug_gc_check(p->inherits[e].name, T_PROGRAM, p); if(e) - gc_check(p->inherits[e].prog); + debug_gc_check(p->inherits[e].prog, T_PROGRAM, p); } +#ifdef DEBUG if(d_flag) { int e; for(e=0;e<(int)p->num_strings;e++) - gc_check(p->strings[e]); + debug_gc_check(p->strings[e], T_PROGRAM, p); for(e=0;e<(int)p->num_identifiers;e++) { - gc_check(p->identifiers[e].name); - gc_check(p->identifiers[e].type); + debug_gc_check(p->identifiers[e].name, T_PROGRAM, p); + debug_gc_check(p->identifiers[e].type, T_PROGRAM, p); } } +#endif } } -- GitLab