pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: gc.c,v 1.197 2003/09/09 08:29:31 mast Exp $ + || $Id: gc.c,v 1.198 2003/09/09 14:30:17 mast Exp $   */      #include "global.h"      struct callback *gc_evaluator_callback=0;      #include "array.h"   #include "multiset.h"   #include "mapping.h"   #include "object.h"
pike.git/src/gc.c:24:   #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.197 2003/09/09 08:29:31 mast Exp $"); + RCSID("$Id: gc.c,v 1.198 2003/09/09 14:30:17 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 2000000000   #define MULTIPLIER 0.9
pike.git/src/gc.c:686: Inside #if defined(PIKE_DEBUG)
   if (!found_where) Pike_fatal("found_where is zero.\n");   #endif    fprintf(stderr,"***One %sref found%s. ",    weak ? "weak " : "",    found_where?found_where:"");    if (found_in) {    if (gc_svalue_location)    describe_location(found_in , found_in_type, gc_svalue_location,0,1,0);    else {    fputc('\n', stderr); -  describe_something(found_in, found_in_type, 2, 0, DESCRIBE_MEM, 0); +  describe_something(found_in, found_in_type, 0, 0, DESCRIBE_MEM, 0);    }    }    else    fputc('\n', stderr);    fprintf(stderr,"----------end------------\n");   }      void debug_gc_xmark_svalues(struct svalue *s, ptrdiff_t num, char *fromwhere)   {    char *old_found_where = found_where;
pike.git/src/gc.c:844: Inside #if defined(PIKE_DEBUG)
   for (o = objects_to_destruct; o && o != (struct object *) a; o = o->next) {}    if (o)    fprintf(stderr,"%*s**The object is on objects_to_destruct.\n",indent,"");    }       if(!p)    {    fprintf(stderr,"%*s**The object is destructed.\n",indent,"");    p=id_to_program(((struct object *)a)->program_id);    } +     if (p) { -  +  size_t inh_idx, var_idx, var_count = 0; +  +  fprintf (stderr, "%*s**Object variables:\n", indent, ""); +  +  for (inh_idx = 0; inh_idx < p->num_inherits; inh_idx++) { +  struct inherit *inh = p->inherits + inh_idx; +  struct program *p2 = inh->prog; +  +  if (inh->inherit_level) { +  if (inh->name) { +  fprintf (stderr, "%*s**%*s=== In inherit ", +  indent, "", inh->inherit_level + 1, ""); +  push_string (inh->name); +  print_svalue (stderr, --Pike_sp); +  fprintf (stderr, ", program %d:\n", inh->prog->id); +  } +  else +  fprintf (stderr, "%*s**%*s=== In nameless inherit, program %d:\n", +  indent, "", inh->inherit_level + 1, "", inh->prog->id); +  } +  +  for (var_idx = 0; var_idx < p2->num_variable_index; var_idx++) { +  struct identifier *id = p2->identifiers + p2->variable_index[var_idx]; +  void *ptr; +  +  fprintf (stderr, "%*s**%*srtt: %-8s name: ", +  indent, "", inh->inherit_level + 1, "", +  get_name_of_type (id->run_time_type)); +  +  if (id->name->size_shift) { +  push_string (id->name); +  print_svalue (stderr, --Pike_sp); +  } +  else +  fprintf (stderr, "%-20s", id->name->str); +  +  fprintf (stderr, " off: %4"PRINTPTRDIFFT"d value: ", +  inh->storage_offset + id->func.offset); +  +  ptr = PIKE_OBJ_STORAGE ((struct object *) a) + +  inh->storage_offset + id->func.offset; +  if (id->run_time_type == T_MIXED) +  push_svalue ((struct svalue *) ptr); +  else +  assign_from_short_svalue_no_free ( +  Pike_sp++, (union anything *) ptr, id->run_time_type); +  print_svalue (stderr, Pike_sp - 1); +  pop_stack(); +  +  fputc ('\n', stderr); +  var_count++; +  } +  } +  +  if (!var_count) +  fprintf (stderr, "%*s** (none)\n", indent, ""); +     fprintf(stderr,"%*s**Describing program of object:\n",indent,"");   #ifdef DEBUG_MALLOC    if ((int) p == 0x55555555)    fprintf(stderr, "%*s**Zapped program pointer.\n", indent, "");    else   #endif    low_describe_something(p, T_PROGRAM, indent, depth, flags, 0); -  } +     -  if(p && -  (p->flags & PROGRAM_USES_PARENT) && +  if((p->flags & PROGRAM_USES_PARENT) &&    LOW_PARENT_INFO(((struct object *)a),p)->parent)    { -  +  if (depth) {    fprintf(stderr,"%*s**Describing parent of object:\n",indent,"");    describe_something( PARENT_INFO((struct object *)a)->parent, T_OBJECT,    indent+2, depth-1,    (flags | DESCRIBE_SHORT | DESCRIBE_NO_REFS )    & ~ (DESCRIBE_MEM),    0); -  +  } +  else +  fprintf (stderr, "%*s**Object got a parent.\n", indent, "");    }else{    fprintf(stderr,"%*s**There is no parent (any longer?)\n",indent,"");    } -  +  }    break;       case T_PROGRAM:    {    char *tmp;    INT32 line; -  int foo=0; +  ptrdiff_t id_idx, id_count = 0; +  struct inherit *inh = p->inherits, *next_inh = p->inherits + 1; +  ptrdiff_t inh_id_end = p->num_identifier_references;       fprintf(stderr,"%*s**Program id: %ld, flags: %x\n",indent,"",    (long)(p->id),    p->flags);       if(p->flags & PROGRAM_HAS_C_METHODS)    {    fprintf(stderr,"%*s**The program was written in C.\n",indent,"");    }       tmp = debug_get_program_line(p, &line);    if(strcmp(tmp, "-"))    {    fprintf(stderr,"%*s**Location: %s:%ld\n",    indent, "", tmp, (long)line); -  foo=1; -  break; +     } - #if 0 -  if(!foo && p->num_linenumbers>1 && EXTRACT_UCHAR(p->linenumbers)=='\177') -  { -  fprintf(stderr,"%*s**From file: %s\n",indent,"",p->linenumbers+1); -  foo=1; +  +  fprintf (stderr, "%*s**Identifiers:\n", indent, ""); +  +  for (id_idx = 0; id_idx < p->num_identifier_references; id_idx++) { +  struct reference *id_ref = p->identifier_references + id_idx; +  struct inherit *id_inh; +  struct identifier *id; +  const char *type; +  char prot[100], descr[120]; +  +  while (next_inh < p->inherits + p->num_inherits && +  id_idx == next_inh->identifier_level) { +  inh = next_inh++; +  inh_id_end = inh->identifier_level + inh->prog->num_identifier_references; +  if (inh->name) { +  fprintf (stderr, "%*s**%*s=== In inherit ", +  indent, "", inh->inherit_level + 1, ""); +  push_string (inh->name); +  print_svalue (stderr, --Pike_sp); +  fprintf (stderr, ", program %d:\n", inh->prog->id);    } - #endif +  else +  fprintf (stderr, "%*s**%*s=== In nameless inherit, program %d:\n", +  indent, "", inh->inherit_level + 1, "", inh->prog->id); +  }    -  if(!foo) -  { -  int e; -  fprintf(stderr,"%*s**identifiers:\n",indent,""); -  for(e=0;e<p->num_identifier_references;e++) -  fprintf(stderr,"%*s**** %s\n",indent,"",ID_FROM_INT(p,e)->name->str); +  while (id_idx == inh_id_end) { +  int cur_lvl = inh->inherit_level; +  if (inh->name) { +  fprintf (stderr, "%*s**%*s=== End of inherit ", +  indent, "", inh->inherit_level + 1, ""); +  push_string (inh->name); +  print_svalue (stderr, --Pike_sp); +  fputc ('\n', stderr); +  } +  else +  fprintf (stderr, "%*s**%*s=== End of nameless inherit\n", +  indent, "", inh->inherit_level + 1, ""); +  while (inh > p->inherits) { /* Paranoia. */ +  if ((--inh)->inherit_level < cur_lvl) break; +  } +  inh_id_end = inh->identifier_level + inh->prog->num_identifier_references; +  }    -  fprintf(stderr,"%*s**num inherits: %d\n",indent,"",p->num_inherits); +  if (id_ref->id_flags & ID_HIDDEN || +  (id_ref->id_flags & (ID_INHERITED|ID_PRIVATE)) == +  (ID_INHERITED|ID_PRIVATE)) continue; +  +  id_inh = INHERIT_FROM_PTR (p, id_ref); +  id = id_inh->prog->identifiers + id_ref->identifier_offset; +  +  if (IDENTIFIER_IS_PIKE_FUNCTION (id->identifier_flags)) type = "fun"; +  else if (IDENTIFIER_IS_FUNCTION (id->identifier_flags)) type = "cfun"; +  else if (IDENTIFIER_IS_CONSTANT (id->identifier_flags)) type = "const"; +  else if (IDENTIFIER_IS_ALIAS (id->identifier_flags)) type = "alias"; +  else if (IDENTIFIER_IS_VARIABLE (id->identifier_flags)) type = "var"; +  else type = "???"; +  +  prot[0] = prot[1] = 0; +  if (id_ref->id_flags & ID_PRIVATE) { +  strcat (prot, ",pri"); +  if (!(id_ref->id_flags & ID_STATIC)) strcat (prot, ",!sta");    } -  +  else +  if (id_ref->id_flags & ID_STATIC) strcat (prot, ",sta"); +  if (id_ref->id_flags & ID_NOMASK) strcat (prot, ",nom"); +  if (id_ref->id_flags & ID_PUBLIC) strcat (prot, ",pub"); +  if (id_ref->id_flags & ID_PROTECTED) strcat (prot, ",pro"); +  if (id_ref->id_flags & ID_INLINE) strcat (prot, ",inl"); +  if (id_ref->id_flags & ID_OPTIONAL) strcat (prot, ",opt"); +  if (id_ref->id_flags & ID_EXTERN) strcat (prot, ",ext"); +  if (id_ref->id_flags & ID_VARIANT) strcat (prot, ",var"); +  if (id_ref->id_flags & ID_ALIAS) strcat (prot, ",ali");    -  +  sprintf (descr, "%s: %s", type, prot + 1); +  fprintf (stderr, "%*s**%*s%-18s name: ", +  indent, "", id_inh->inherit_level + 1, "", descr); +  +  if (id->name->size_shift) { +  push_string (id->name); +  print_svalue (stderr, --Pike_sp); +  } +  else +  fprintf (stderr, "%-20s", id->name->str); +  +  if (id->identifier_flags & IDENTIFIER_C_FUNCTION) +  fprintf (stderr, " addr: %p", id->func.c_fun); +  else if (IDENTIFIER_IS_VARIABLE (id->identifier_flags)) +  fprintf (stderr, " rtt: %s off: %"PRINTPTRDIFFT"d", +  get_name_of_type (id->run_time_type), id->func.offset); +  else if (IDENTIFIER_IS_PIKE_FUNCTION (id->identifier_flags)) +  fprintf (stderr, " pc: %"PRINTPTRDIFFT"d", id->func.offset); +  else if (IDENTIFIER_IS_CONSTANT (id->identifier_flags)) { +  fputs (" value: ", stderr); +  print_svalue (stderr, &id_inh->prog->constants[id->func.offset].sval); +  } +  +  fputc ('\n', stderr); +  id_count++; +  } +  +  if (!id_count) +  fprintf (stderr, "%*s** (none)\n", indent, ""); +     if(flags & DESCRIBE_MEM)    {   #define FOO(NUMTYPE,TYPE,NAME) \    fprintf(stderr, "%*s* " #NAME " %p[%"PRINTSIZET"u]\n", \    indent, "", p->NAME, p->PIKE_CONCAT(num_,NAME));   #include "program_areas.h"    }       break;    }
pike.git/src/gc.c:1073:    }       fprintf(stderr,"%*s*******************\n",indent,"");    d_flag=tmp;   }      PMOD_EXPORT void describe(void *x)   {    void *inblock;    int type = attempt_to_identify(x, &inblock); -  describe_something(x, type, 0, 2, 0, inblock); +  describe_something(x, type, 0, 0, 0, inblock);   }      void debug_describe_svalue(struct svalue *s)   {    fprintf(stderr,"Svalue at %p is:\n",s);    switch(s->type)    {    case T_INT:    fprintf(stderr," %"PRINTPIKEINT"d\n",s->u.integer);    break;
pike.git/src/gc.c:1108:    {    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,0,2,0,0); +  describe_something(s->u.refs,s->type,0,0,0,0);   }      void gc_watch(void *a)   {    struct marker *m;    init_gc();    m = get_marker(a);    if (!(m->flags & GC_WATCHED)) {    m->flags |= GC_WATCHED;    fprintf(stderr, "## Watching thing %p.\n", a);