From 464706dfda60e47f8cbb4819932be43df514f334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Tue, 14 Sep 1999 12:38:51 -0700 Subject: [PATCH] more (better?) debug Rev: src/backend.c:1.44 Rev: src/interpreter.h:1.10 Rev: src/object.c:1.78 Rev: src/object.h:1.27 Rev: src/svalue.c:1.45 --- src/backend.c | 3 ++- src/interpreter.h | 6 +++-- src/object.c | 63 +++++++++++++++++++++++++++++++++++++++++++++-- src/object.h | 4 ++- src/svalue.c | 21 ++++++++++++---- 5 files changed, 86 insertions(+), 11 deletions(-) diff --git a/src/backend.c b/src/backend.c index 4621b6b593..8956e6eee6 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: backend.c,v 1.43 1999/09/06 10:48:06 grubba Exp $"); +RCSID("$Id: backend.c,v 1.44 1999/09/14 19:38:46 hubbe Exp $"); #include "fdlib.h" #include "backend.h" #include <errno.h> @@ -554,6 +554,7 @@ void do_debug(void) check_all_programs(); verify_all_objects(); verify_shared_strings_tables(); + check_all_objects(); call_callback(& do_debug_callbacks, 0); diff --git a/src/interpreter.h b/src/interpreter.h index 5d9e5b6994..3f566f0d4e 100644 --- a/src/interpreter.h +++ b/src/interpreter.h @@ -76,6 +76,8 @@ static int eval_instruction(unsigned char *pc) backlog[backlogp].pc=pc; debug_malloc_touch(fp->current_object); + if(d_flag>1) + check_object(fp->current_object); } if(t_flag > 2) @@ -1014,8 +1016,8 @@ static int eval_instruction(unsigned char *pc) CASE(F_RETURN); do_return: #if defined(PIKE_DEBUG) && defined(GC2) - if(d_flag>2) do_gc(); - if(d_flag>3) do_debug(); + if(d_flag>3) do_gc(); + if(d_flag>4) do_debug(); check_threads_etc(); #endif diff --git a/src/object.c b/src/object.c index a08cd7e946..7ba03ce0b7 100644 --- a/src/object.c +++ b/src/object.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: object.c,v 1.77 1999/09/10 00:11:22 hubbe Exp $"); +RCSID("$Id: object.c,v 1.78 1999/09/14 19:38:48 hubbe Exp $"); #include "object.h" #include "dynamic_buffer.h" #include "interpret.h" @@ -25,9 +25,11 @@ RCSID("$Id: object.c,v 1.77 1999/09/10 00:11:22 hubbe Exp $"); #include "cyclic.h" #include "security.h" #include "module_support.h" -#include "block_alloc.h" #include "fdlib.h" #include "mapping.h" +#include "constants.h" + +#include "block_alloc.h" #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -1407,3 +1409,60 @@ void exit_object(void) magic_set_index_program=0; } } + +#ifdef PIKE_DEBUG +void check_object(struct object *o) +{ + int e; + struct program *p; + debug_malloc_touch(o); + + if(o == fake_object) return; + + p=o->prog; + PUSH_FRAME(o); + + /* clear globals and call C initializers */ + for(e=p->num_inherits-1; e>=0; e--) + { + int q; + SET_FRAME_CONTEXT(p->inherits[e]); + + for(q=0;q<(int)pike_frame->context.prog->num_variable_index;q++) + { + int d=pike_frame->context.prog->variable_index[q]; + if(d<0 || d>=pike_frame->context.prog->num_identifiers) + fatal("Illegal index in variable_index!\n"); + + if(pike_frame->context.prog->identifiers[d].run_time_type == T_MIXED) + { + struct svalue *s; + s=(struct svalue *)(pike_frame->current_storage + + pike_frame->context.prog->identifiers[d].func.offset); + check_svalue(s); + }else{ + union anything *u; + u=(union anything *)(pike_frame->current_storage + + pike_frame->context.prog->identifiers[d].func.offset); + check_short_svalue(u, + pike_frame->context.prog->identifiers[d].run_time_type); + } + } + } + + POP_FRAME(); +} + +void check_all_objects(void) +{ + struct object *o, *next; + for(o=first_object;o;o=next) + { + add_ref(o); + check_object(o); + next=o->next; + free_object(o); + } +} + +#endif diff --git a/src/object.h b/src/object.h index e62f54c454..daa737ce20 100644 --- a/src/object.h +++ b/src/object.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: object.h,v 1.26 1999/08/18 00:26:41 hubbe Exp $ + * $Id: object.h,v 1.27 1999/09/14 19:38:50 hubbe Exp $ */ #ifndef OBJECT_H #define OBJECT_H @@ -95,6 +95,8 @@ struct magic_index_struct; void push_magic_index(struct program *type, int inherit_no, int parent_level); void init_object(void); void exit_object(void); +void check_object(struct object *o); +void check_all_objects(void); /* Prototypes end here */ #ifdef MALLOC_DEBUG diff --git a/src/svalue.c b/src/svalue.c index 004a0a6003..574b535195 100644 --- a/src/svalue.c +++ b/src/svalue.c @@ -22,7 +22,7 @@ #include <ctype.h> #include "queue.h" -RCSID("$Id: svalue.c,v 1.44 1999/09/10 00:11:23 hubbe Exp $"); +RCSID("$Id: svalue.c,v 1.45 1999/09/14 19:38:51 hubbe Exp $"); struct svalue dest_ob_zero = { T_INT, 0 }; @@ -927,12 +927,11 @@ void copy_svalues_recursively_no_free(struct svalue *to, } #ifdef PIKE_DEBUG -void check_short_svalue(union anything *u, TYPE_T type) +static void low_check_short_svalue(union anything *u, TYPE_T type) { static int inside=0; check_type(type); - check_refs2(u,type); if ((type > MAX_REF_TYPE)||(!u->refs)) return; switch(type) @@ -953,7 +952,7 @@ void check_short_svalue(union anything *u, TYPE_T type) case T_MAPPING: check_mapping(u->mapping); break; case T_ARRAY: check_array(u->array); break; case T_PROGRAM: check_program(u->program); break; -/* case T_OBJECT: check_object(u->object); break; */ + case T_OBJECT: check_object(u->object); break; /* case T_MULTISET: check_multiset(u->multiset); break; */ } inside=0; @@ -961,10 +960,22 @@ void check_short_svalue(union anything *u, TYPE_T type) } } +void check_short_svalue(union anything *u, TYPE_T type) +{ + if(type<=MAX_REF_TYPE && (3 & (long)(u->refs))) + fatal("Odd pointer! type=%d u->refs=%p\n",type,u->refs); + + check_refs2(u,type); + low_check_short_svalue(u,type); +} + void check_svalue(struct svalue *s) { + if(s->type<=MAX_REF_TYPE && (3 & (long)(s->u.refs))) + fatal("Odd pointer! type=%d u->refs=%p\n",s->type,s->u.refs); + check_refs(s); - check_short_svalue(& s->u, s->type); + low_check_short_svalue(& s->u, s->type); } #endif -- GitLab