Branch: Tag:

1997-10-16

1997-10-16 06:34:28 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

more debug added to garbage collector

Rev: src/array.c:1.20
Rev: src/gc.c:1.17
Rev: src/gc.h:1.11
Rev: src/mapping.c:1.23
Rev: src/object.c:1.26
Rev: src/program.c:1.44
Rev: src/svalue.c:1.15
Rev: src/threads.c:1.45

145: Inside #if defined(DEBUG)
     static void *check_for =0;   static char *found_where=""; + static void *found_in=0; + static TYPE_T found_in_type=0; + void *gc_svalue_location=0;      static void gdb_gc_stop_here(void *a)   { -  fprintf(stderr,"One ref found%s.\n",found_where); +  fprintf(stderr,"**One ref found%s.\n",found_where); +  fprintf(stderr,"**Location of (short) svalue: %p\n",gc_svalue_location); +  describe_something(found_in, found_in_type);   } - #endif +     - INT32 gc_check(void *a) + TYPE_FIELD debug_gc_check_svalues(struct svalue *s, int num, TYPE_T t, void *data)   { - #ifdef DEBUG -  if(check_for) -  { -  if(check_for == a) -  { -  gdb_gc_stop_here(a); +  TYPE_FIELD ret; +  found_in=data; +  found_in_type=t; +  ret=gc_check_svalues(s,num); +  found_in_type=T_UNKNOWN; +  return ret;   } -  return 0; -  } - #endif -  return getmark(a)->refs++; - } +     - int gc_is_referenced(void *a) + void debug_gc_check_short_svalue(union anything *u, TYPE_T type, TYPE_T t, void *data)   { -  struct marker *m; -  m=getmark(a); - #ifdef DEBUG -  if(m->refs + m->xrefs > *(INT32 *)a) -  { -  INT32 refs=m->refs; -  INT32 xrefs=m->xrefs; -  TYPE_T t=attempt_to_identify(a); +  found_in=data; +  found_in_type=t; +  gc_check_short_svalue(u,type); +  found_in_type=T_UNKNOWN; + }    -  fprintf(stderr,"**An object of type %s at addres %p has wrong number of references.\n",get_name_of_type(t),a); -  fprintf(stderr,"**The object has %ld references, while gc() found %ld + %ld external.\n",(long)*(INT32 *)a,(long)refs,(long)xrefs); -  + void describe_something(void *a, TYPE_T t)   {    struct program *p=(struct program *)a; -  +  if(!a) return; +  fprintf(stderr,"**Location: %p Type: %s Refs: %d\n",a, +  get_name_of_type(t), +  *(INT32 *)a); +     switch(t)    {    case T_OBJECT:
215: Inside #if defined(DEBUG)
   }    }    + #endif    -  + INT32 gc_check(void *a) + { + #ifdef DEBUG +  if(check_for) +  { +  if(check_for == a) +  { +  gdb_gc_stop_here(a); +  } +  return 0; +  } + #endif +  return getmark(a)->refs++; + } +  + int gc_is_referenced(void *a) + { +  struct marker *m; +  m=getmark(a); + #ifdef DEBUG +  if(m->refs + m->xrefs > *(INT32 *)a) +  { +  INT32 refs=m->refs; +  INT32 xrefs=m->xrefs; +  TYPE_T t=attempt_to_identify(a); +  +  fprintf(stderr,"**Something has %ld references, while gc() found %ld + %ld external.\n",(long)*(INT32 *)a,(long)refs,(long)xrefs); +  describe_something(t, a); +     fprintf(stderr,"**Looking for references:\n");    check_for=a;