diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 7a3fe5ecbaa0b6694a117537b935612b40bbfe3e..d97ed4fc7d0dc4a9b65a46c61a9f8b301052fdd3 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: builtin_functions.c,v 1.154 1999/03/10 02:41:15 hubbe Exp $"); +RCSID("$Id: builtin_functions.c,v 1.155 1999/03/17 21:49:22 hubbe Exp $"); #include "interpret.h" #include "svalue.h" #include "pike_macros.h" @@ -3723,6 +3723,12 @@ void f__locate_references(INT32 args) locate_references(sp[-args].u.refs); pop_n_elems(args-1); } + +void f__describe(INT32 args) +{ + debug_describe_svalue(sp-1); +} + #endif void f_map_array(INT32 args) @@ -4043,6 +4049,7 @@ void init_builtin_efuns(void) /* function(1=mixed:1) */ ADD_EFUN("_locate_references",f__locate_references,tFunc(tSetvar(1,tMix),tVar(1)),OPT_SIDE_EFFECT); + ADD_EFUN("_describe",f__describe,tFunc(tSetvar(1,tMix),tVar(1)),OPT_SIDE_EFFECT); #endif } diff --git a/src/gc.c b/src/gc.c index 602e24007801fba1f442fb00c13cbfaf0caaf4b9..36a3886dc17981f65d229ffaeb270fac858ebd7a 100644 --- a/src/gc.c +++ b/src/gc.c @@ -20,12 +20,13 @@ struct callback *gc_evaluator_callback=0; #include "pike_macros.h" #include "pike_types.h" #include "time_stuff.h" +#include "constants.h" #include "gc.h" #include "main.h" #include <math.h> -RCSID("$Id: gc.c,v 1.40 1998/12/16 07:49:35 hubbe Exp $"); +RCSID("$Id: gc.c,v 1.41 1999/03/17 21:49:24 hubbe Exp $"); /* Run garbage collect approximate every time we have * 20 percent of all arrays, objects and programs is @@ -315,6 +316,13 @@ void describe_something(void *a, int t, int dm) switch(t) { + 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); @@ -336,26 +344,50 @@ void describe_something(void *a, int t, int dm) { char *tmp; INT32 line,pos; + int foo=0; fprintf(stderr,"**Program id: %ld\n",(long)(p->id)); if(p->flags & PROGRAM_HAS_C_METHODS) { - 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); } - - for(pos=0;pos<(long)p->num_program && pos<100;pos++) + for(pos=0;pos<100;pos++) { tmp=get_line(p->program+pos, p, &line); if(tmp && line) { fprintf(stderr,"**Location: %s:%ld\n",tmp,(long)line); + foo=1; break; } + if(pos+1>=(long)p->num_program) + break; + } +#if 0 + if(!foo && p->num_linenumbers>1 && EXTRACT_UCHAR(p->linenumbers)=='\177') + { + fprintf(stderr,"**From file: %s\n",p->linenumbers+1); + foo=1; } +#endif + + if(!foo) + { + int e; +#if 0 + fprintf(stderr,"**identifiers:\n"); + for(e=0;e<p->num_identifiers;e++) + 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); + } + break; } @@ -402,6 +434,19 @@ void debug_describe_svalue(struct svalue *s) case T_FLOAT: 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) + { + 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); }