1998-04-06
1998-04-06 04:29:27 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
-
8fb1e14708b285a6cf5f5eaee30793843f95d942
(48 lines)
(+42/-6)
[
Show
| Annotate
]
Branch: 7.9
more debug added
Rev: src/backend.c:1.26
Rev: src/dmalloc.h:1.6
Rev: src/gc.c:1.31
Rev: src/gc.h:1.17
Rev: src/pike_memory.c:1.19
25:
#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
241: Inside #if defined(DEBUG)
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);
}
286: Inside #if defined(DEBUG)
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);
304: Inside #if defined(DEBUG)
{
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");
323: Inside #if defined(DEBUG)
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++)
361: Inside #if defined(DEBUG)
break;
}
}
+ fprintf(stderr,"*******************\n");
}
-
+ void describe(void *x)
+ {
+ describe_something(x, attempt_to_identify(x),1);
+ }
+
#endif
INT32 gc_check(void *a)
451:
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);
514:
{
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);
}