pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:18:   #include "error.h"   #include "pike_memory.h"   #include "pike_macros.h"   #include "pike_types.h"   #include "time_stuff.h"      #include "gc.h"   #include "main.h"   #include <math.h>    - RCSID("$Id: gc.c,v 1.30 1998/03/28 15:31:05 grubba Exp $"); + RCSID("$Id: gc.c,v 1.31 1998/04/06 04:25:26 hubbe Exp $");      /* Run garbage collect approximate every time we have    * 20 percent of all arrays, objects and programs is    * garbage.    */      #define GC_CONST 20   #define MIN_ALLOC_THRESHOLD 1000   #define MAX_ALLOC_THRESHOLD 10000000   #define MULTIPLIER 0.9
pike.git/src/gc.c:234: Inside #if defined(DEBUG)
   struct svalue *s=(struct svalue *)location;    fprintf(stderr,"**In index %ld\n",(long)(s-ITEM(a)));    return;    }    }   }      static void gdb_gc_stop_here(void *a)   {    fprintf(stderr,"***One ref found%s.\n",found_where); -  describe_something(found_in, found_in_type); +  describe_something(found_in, found_in_type, 0);    describe_location(found_in, found_in_type, gc_svalue_location);   }      void debug_gc_xmark_svalues(struct svalue *s, int num, char *fromwhere)   {    found_in=(void *)fromwhere;    found_in_type=-1;    gc_xmark_svalues(s,num);    found_in_type=T_UNKNOWN;    found_in=0;
pike.git/src/gc.c:279: Inside #if defined(DEBUG)
  {    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) + void describe_something(void *a, int t, int dm)   {    struct program *p=(struct program *)a;    if(!a) return; -  +  if(dm) +  debug_malloc_dump_references(a);    if(t==-1)    {    fprintf(stderr,"**Location description: %s\n",(char *)a);    return;    }       fprintf(stderr,"**Location: %p Type: %s Refs: %d\n",a,    get_name_of_type(t),    *(INT32 *)a);       switch(t)    {    case T_OBJECT:    p=((struct object *)a)->prog; -  +  fprintf(stderr,"**Parent identifier: %d\n",((struct object *)a)->parent_identifier); +  if( ((struct object *)a)->parent) +  { +  fprintf(stderr,"**Describing object's parent:\n"); +  describe_something( ((struct object *)a)->parent, t, 1); +  }else{ +  fprintf(stderr,"**There is no parent (any longer?)\n"); +  }    if(!p)    {    fprintf(stderr,"**The object is destructed.\n");    break;    }    fprintf(stderr,"**Attempting to describe program object was instantiated from:\n");       case T_PROGRAM:    {    char *tmp;    INT32 line,pos;       fprintf(stderr,"**Program id: %ld\n",(long)(p->id));    if(!p->num_linenumbers)    {    int e;    fprintf(stderr,"**The program was written in C.\n");    fprintf(stderr,"**identifiers:\n");    for(e=0;e<p->num_identifiers;e++) -  fprintf(stderr,"*** %s\n",p->identifiers[e].name->str); +  fprintf(stderr,"**** %s\n",p->identifiers[e].name->str);    }       for(pos=0;pos<(long)p->num_program && pos<100;pos++)    {    tmp=get_line(p->program+pos, p, &line);    if(tmp && line)    {    fprintf(stderr,"**Location: %s:%ld\n",tmp,(long)line);    break;    }
pike.git/src/gc.c:354: Inside #if defined(DEBUG)
   fprintf(stderr,"**String length is %d:\n",s->len);    if(s->len>77)    {    fprintf(stderr,"** \"%60s ...\"\n",s->str);    }else{    fprintf(stderr,"** \"%s\"\n",s->str);    }    break;    }    } +  fprintf(stderr,"*******************\n");   }    -  + void describe(void *x) + { +  describe_something(x, attempt_to_identify(x),1); + } +    #endif      INT32 gc_check(void *a)   {   #ifdef DEBUG    if(check_for)    {    if(check_for == a)    {    gdb_gc_stop_here(a);
pike.git/src/gc.c:444: Inside #if defined(DEBUG)
   if(!in_gc)    exit_gc();   }   #endif      int gc_is_referenced(void *a)   {    struct marker *m;    m=getmark(a);   #ifdef DEBUG -  if(m->refs + m->xrefs > *(INT32 *)a) +  if(m->refs + m->xrefs > *(INT32 *)a || +  (!(m->refs < *(INT32 *)a) && m->xrefs) )    {    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(a, t); +  describe_something(a, t, 1);       locate_references(a);       fatal("Ref counts are wrong (has %d, found %d + %d external)\n",    *(INT32 *)a,    refs,    xrefs);    }   #endif    return m->refs < *(INT32 *)a;
pike.git/src/gc.c:507:    }else{    m->flags |= GC_REFERENCED;    return 1;    }   }      int gc_do_free(void *a)   {    struct marker *m;    m=getmark(a); + #ifdef DEBUG +  if( !(m->flags & GC_REFERENCED) && m->flags & GC_XREFERENCED ) +  { +  INT32 refs=m->refs; +  INT32 xrefs=m->xrefs; +  TYPE_T t=attempt_to_identify(a); +  +  fprintf(stderr,"**gc_is_referenced failed, object has %ld references, while gc() found %ld + %ld external.\n",(long)*(INT32 *)a,(long)refs,(long)xrefs); +  describe_something(a, t, 1); +  +  locate_references(a); +  +  fatal("GC failed object (has %d, found %d + %d external)\n", +  *(INT32 *)a, +  refs, +  xrefs); +  } + #endif    return !(m->flags & GC_REFERENCED);   }      void do_gc(void)   {    double tmp;    INT32 tmp2;    double multiplier;       if(in_gc) return;