pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:23:   #include "constants.h"   #include "interpret.h"   #include "bignum.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.137 2000/09/30 16:50:29 mast Exp $"); + RCSID("$Id: gc.c,v 1.138 2000/09/30 17:26:49 mast Exp $");      /* Run garbage collect approximately every time    * 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:242:    fprintf(stderr,"Objects allocated total : %ld\n",(long)num_allocs);    fprintf(stderr," threshold for next gc() : %ld\n",(long)alloc_threshold);    fprintf(stderr,"Average allocs per gc() : %f\n",objects_alloced);    fprintf(stderr,"Average frees per gc() : %f\n",objects_freed);    fprintf(stderr,"Second since last gc() : %ld\n",    DO_NOT_WARN((long)TIME(0) - (long)last_gc));    fprintf(stderr,"Projected garbage : %f\n", objects_freed * (double) num_allocs / (double) alloc_threshold);    fprintf(stderr,"in_gc : %d\n", Pike_in_gc);   }    + #ifdef DEBUG_MALLOC + #define VALID_PTR(P) ((P) && (int) (P) != 0x55555555) + #else + #define VALID_PTR(P) (P) + #endif +    TYPE_T attempt_to_identify(void *something)   {    struct array *a;    struct object *o;    struct program *p;    struct mapping *m;    struct multiset *mu;       a=&empty_array;    do    {    if(a==(struct array *)something) return T_ARRAY;    a=a->next; -  }while(a!=&empty_array); +  }while(VALID_PTR(a) && a!=&empty_array);    -  for(o=first_object;o;o=o->next) +  for(o=first_object;VALID_PTR(o);o=o->next)    if(o==(struct object *)something)    return T_OBJECT;    -  for(p=first_program;p;p=p->next) +  for(p=first_program;VALID_PTR(p);p=p->next)    if(p==(struct program *)something)    return T_PROGRAM;    -  for(m=first_mapping;m;m=m->next) +  for(m=first_mapping;VALID_PTR(m);m=m->next)    if(m==(struct mapping *)something)    return T_MAPPING;    else if (m->data == (struct mapping_data *) something)    return T_MAPPING_DATA;    -  for(mu=first_multiset;mu;mu=mu->next) +  for(mu=first_multiset;VALID_PTR(mu);mu=mu->next)    if(mu==(struct multiset *)something)    return T_MULTISET;       if(safe_debug_findstring((struct pike_string *)something))    return T_STRING;       return T_UNKNOWN;   }      void *check_for =0;
pike.git/src/gc.c:658:       if(!p)    {    fprintf(stderr,"%*s**The object is destructed.\n",indent,"");    p=id_to_program(((struct object *)a)->program_id);    }    if (p) {    fprintf(stderr,"%*s**Attempting to describe program object was instantiated from:\n",indent,"");   #ifdef DEBUG_MALLOC    if ((int) p == 0x55555555) -  fprintf(stderr, "%*%s**Zapped program pointer\n", indent, ""); +  fprintf(stderr, "%*s**Zapped program pointer.\n", indent, "");    else   #endif    low_describe_something(p, T_PROGRAM, indent, depth, flags);    }       if( ((struct object *)a)->parent)    {    fprintf(stderr,"%*s**Describing object's parent:\n",indent,"");    describe_something( ((struct object *)a)->parent, t, indent+2,depth-1,    (flags | DESCRIBE_SHORT | DESCRIBE_NO_REFS )
pike.git/src/gc.c:790: Inside #if defined(DEBUG_MALLOC)
   get_name_of_type(t));    } else   #endif /* DEBUG_MALLOC */    if (((ptrdiff_t)a) & 3) {    fprintf(stderr,"%*s**Location: %p Type: %s Misaligned address\n",indent,"",a,    get_name_of_type(t));    } else {    fprintf(stderr,"%*s**Location: %p Type: %s Refs: %d\n",indent,"",a,    get_name_of_type(t),    *(INT32 *)a); -  } +       #ifdef DEBUG_MALLOC    if(!(flags & DESCRIBE_NO_DMALLOC))    debug_malloc_dump_references(a,indent+2,depth-1,flags);   #endif       low_describe_something(a,t,indent,depth,flags); -  +  }    -  +     fprintf(stderr,"%*s*******************\n",indent,"");    d_flag=tmp;   }      PMOD_EXPORT void describe(void *x)   {    describe_something(x, attempt_to_identify(x), 0, 2, 0);   }      void debug_describe_svalue(struct svalue *s)