pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:22:   #include "time_stuff.h"   #include "constants.h"   #include "interpret.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.52 2000/03/07 23:51:29 hubbe Exp $"); + RCSID("$Id: gc.c,v 1.53 2000/04/08 02:01:08 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:124: Inside #if defined(PIKE_DEBUG)
  }      static void *check_for =0;   static char *found_where="";   static void *found_in=0;   static int found_in_type=0;   void *gc_svalue_location=0;      void describe_location(void *memblock, TYPE_T type, void *location)   { +  struct program *p;    if(!location) return; -  fprintf(stderr,"**Location of (short) svalue: %p\n",location); + /* fprintf(stderr,"**Location of (short) svalue: %p\n",location); */    -  +  if(type==T_UNKNOWN) type=attempt_to_identify(memblock); +  fprintf(stderr," <from %s %p offset %ld>\n", +  get_name_of_type(type), +  memblock, +  ((long)location - (long)memblock)); +     switch(type)    { -  +  case T_UNKNOWN: +  for(p=first_program;p;p=p->next) +  { +  if(memblock == (void *)p->program) +  { +  fprintf(stderr," **In memory block for program at %p\n",p); +  memblock=p; +  type=T_PROGRAM; +  goto describe_program_location; +  } +  } +  break; +     case T_PROGRAM: -  +  describe_program_location:    { -  +  long e;    struct program *p=(struct program *)memblock;    char *ptr=(char *)location; -  +  +  if(location == (void *)&p->prev) +  fprintf(stderr," **In p->prev\n"); +  +  if(location == (void *)&p->next) +  fprintf(stderr," **In p->next\n"); +     if(ptr >= (char *)p->inherits && ptr<(char*)(p->inherits+p->num_inherits)) -  fprintf(stderr,"**In inherit block.\n"); +  { +  e=((long)ptr - (long)(p->inherits)) / sizeof(struct inherit); +  fprintf(stderr," **In p->inherits[%ld] (%s)\n", +  e, +  p->inherits[e].name ? p->inherits[e].name->str : "no name"); +  return; +  }    -  if(ptr >= (char *)p->strings && ptr<(char*)(p->strings+p->num_strings)) -  fprintf(stderr,"**In string block.\n"); +  if(ptr >= (char *)p->constants && ptr<(char*)(p->constants+p->num_constants)) +  { +  e=((long)ptr - (long)(p->constants)) / sizeof(struct program_constant); +  fprintf(stderr," **In p->constants[%ld] (%s)\n", +  e, +  p->constants[e].name ? p->constants[e].name->str : "no name"); +  return; +  }    -  +     if(ptr >= (char *)p->identifiers && ptr<(char*)(p->identifiers+p->num_identifiers)) -  fprintf(stderr,"**In identifier block.\n"); +  { +  e=((long)ptr - (long)(p->identifiers)) / sizeof(struct identifier); +  fprintf(stderr," **In p->identifiers[%ld] (%s)\n", +  e, +  p->identifiers[e].name ? p->constants[e].name->str : "no name"); +  return; +  }    -  + #define FOO(NTYP,TYP,NAME) \ +  if(location == (void *)&p->NAME) fprintf(stderr," **In p->" #NAME "\n"); \ +  if(ptr >= (char *)p->NAME && ptr<(char*)(p->NAME+p->PIKE_CONCAT(num_,NAME))) \ +  fprintf(stderr," **In p->" #NAME "[%ld]\n",((long)ptr - (long)(p->NAME)) / sizeof(TYP)); + #include "program_areas.h" +     return;    }       case T_OBJECT:    {    struct object *o=(struct object *)memblock; -  if(o->prog) +  struct program *p; +  +  if(location == (void *)&o->parent) fprintf(stderr," **In o->parent\n"); +  if(location == (void *)&o->prog) fprintf(stderr," **In o->prog\n"); +  if(location == (void *)&o->next) fprintf(stderr," **In o->next\n"); +  if(location == (void *)&o->prev) fprintf(stderr," **In o->prev\n"); +  +  p=o->prog; +  +  if(!o->prog)    { -  +  p=id_to_program(o->program_id); +  if(p) +  fprintf(stderr," **(We are lucky, found program for destructed object)\n"); +  } +  +  if(p) +  {    INT32 e,d; -  for(e=0;e<(INT32)o->prog->num_inherits;e++) +  for(e=0;e<(INT32)p->num_inherits;e++)    { -  struct inherit tmp=o->prog->inherits[e]; +  struct inherit tmp=p->inherits[e];    char *base=o->storage + tmp.storage_offset;       for(d=0;d<(INT32)tmp.prog->num_identifiers;d++)    {    struct identifier *id=tmp.prog->identifiers+d;    if(!IDENTIFIER_IS_VARIABLE(id->identifier_flags)) continue;       if(location == (void *)(base + id->func.offset))    { -  fprintf(stderr,"**In variable %s\n",id->name->str); +  fprintf(stderr," **In variable %s\n",id->name->str);    }    } -  +  +  if((char *)location >= base && (char *)location <= base + +  ( tmp.prog->storage_needed - tmp.prog->inherits[0].storage_offset )) +  { +  fprintf(stderr," **In storage for inherit %d",e); +  if(tmp.name) +  fprintf(stderr," (%s)",tmp.name->str); +  fprintf(stderr,"\n");    } -  +     } -  +  }    return;    }       case T_ARRAY:    {    struct array *a=(struct array *)memblock;    struct svalue *s=(struct svalue *)location; -  fprintf(stderr,"**In index %ld\n",(long)(s-ITEM(a))); +  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, 0);    describe_location(found_in, found_in_type, gc_svalue_location);
pike.git/src/gc.c:245: Inside #if defined(PIKE_DEBUG)
   case T_FUNCTION:    if(attempt_to_identify(a) != T_OBJECT)    {    fprintf(stderr,"**Builtin function!\n");    break;    }       case T_OBJECT:    p=((struct object *)a)->prog;    fprintf(stderr,"**Parent identifier: %d\n",((struct object *)a)->parent_identifier); +  fprintf(stderr,"**Program id: %ld\n",((struct object *)a)->program_id); +     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; +  p=id_to_program(((struct object *)a)->program_id); +  +  if(!p) break;    }    fprintf(stderr,"**Attempting to describe program object was instantiated from:\n");       case T_PROGRAM:    {    char *tmp;    INT32 line,pos;    int foo=0;       fprintf(stderr,"**Program id: %ld\n",(long)(p->id));
pike.git/src/gc.c:306: Inside #if defined(PIKE_DEBUG)
   fprintf(stderr,"**** %s\n",p->identifiers[e].name->str);   #else    fprintf(stderr,"**identifiers:\n");    for(e=0;e<p->num_identifier_references;e++)    fprintf(stderr,"**** %s\n",ID_FROM_INT(p,e)->name->str);      #endif       fprintf(stderr,"**num inherits: %d\n",p->num_inherits);    } + #define FOO(NUMTYPE,TYPE,NAME) \ +  fprintf(stderr,"* " #NAME " %p[%d]\n",p->NAME,p->PIKE_CONCAT(num_,NAME)); + #include "program_areas.h"       break;    }       case T_ARRAY:    fprintf(stderr,"**Describing array:\n");    debug_dump_array((struct array *)a);    break;       case T_MAPPING:
pike.git/src/gc.c:399:    fprintf(stderr," %f\n",s->u.float_number);    break;       case T_FUNCTION:    if(s->subtype == FUNCTION_BUILTIN)    {    fprintf(stderr," Builtin function: %s\n",s->u.efun->name->str);    }else{    if(!s->u.object->prog)    { +  struct program *p=id_to_program(s->u.object->program_id); +  if(p) +  { +  fprintf(stderr," Function (destructed) name: %s\n",ID_FROM_INT(p,s->subtype)->name->str); +  }else{    fprintf(stderr," Function in destructed object.\n"); -  +  }    }else{    fprintf(stderr," Function name: %s\n",ID_FROM_INT(s->u.object->prog,s->subtype)->name->str);    }    }    }    describe_something(s->u.refs,s->type,1);   }      #endif    - INT32 gc_check(void *a) + INT32 real_gc_check(void *a)   {   #ifdef PIKE_DEBUG    if(check_for)    {    if(check_for == a)    {    gdb_gc_stop_here(a);    }    return 0;    }