From 044c62401a972f28a0c3bbc08cb1f6bd5bce56ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Wed, 14 Apr 1999 21:08:39 -0700 Subject: [PATCH] more debug Rev: src/constants.c:1.17 Rev: src/constants.h:1.9 Rev: src/docode.c:1.46 Rev: src/dynamic_load.c:1.35 Rev: src/interpret.c:1.120 Rev: src/modules/Image/encodings/_xpm.c:1.5 Rev: src/modules/Image/encodings/pcx.c:1.5 Rev: src/modules/Image/encodings/tga.c:1.5 Rev: src/modules/Image/encodings/xbm.c:1.3 Rev: src/modules/Image/encodings/xcf.c:1.7 Rev: src/opcodes.c:1.37 --- src/constants.c | 10 +++++++++- src/constants.h | 5 ++++- src/docode.c | 6 ++++-- src/dynamic_load.c | 14 ++++++++++++-- src/interpret.c | 22 +++++++++++++++++++++- src/modules/Image/encodings/_xpm.c | 3 ++- src/modules/Image/encodings/pcx.c | 3 ++- src/modules/Image/encodings/tga.c | 5 +++-- src/modules/Image/encodings/xbm.c | 3 ++- src/modules/Image/encodings/xcf.c | 3 ++- src/opcodes.c | 4 +++- 11 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/constants.c b/src/constants.c index 818180f2e9..7aaac6f47b 100644 --- a/src/constants.c +++ b/src/constants.c @@ -15,7 +15,7 @@ #include "error.h" #include "block_alloc.h" -RCSID("$Id: constants.c,v 1.16 1999/04/08 23:54:26 hubbe Exp $"); +RCSID("$Id: constants.c,v 1.17 1999/04/15 04:08:09 hubbe Exp $"); static INT32 num_callable=0; static struct mapping *builtin_constants = 0; @@ -90,6 +90,14 @@ struct callable *low_make_callable(c_fun fun, f->flags=flags; f->docode=docode; f->optimize=optimize; +#ifdef PIKE_DEBUG + { + struct pike_string *z=check_call(function_type_string,type); + f->may_return_void= z == void_type_string; + if(!z) fatal("Gnapp!\n"); + free_string(z); + } +#endif return f; } diff --git a/src/constants.h b/src/constants.h index 6c5c49a11c..73ffd33a92 100644 --- a/src/constants.h +++ b/src/constants.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: constants.h,v 1.8 1999/02/10 21:46:40 hubbe Exp $ + * $Id: constants.h,v 1.9 1999/04/15 04:08:10 hubbe Exp $ */ #ifndef ADD_EFUN_H #define ADD_EFUN_H @@ -28,6 +28,9 @@ struct callable struct pike_string *type; struct pike_string *name; INT16 flags; +#ifdef PIKE_DEBUG + INT8 may_return_void; +#endif optimize_fun optimize; docode_fun docode; struct callable *next; diff --git a/src/docode.c b/src/docode.c index 1bad0e9152..27afd98530 100644 --- a/src/docode.c +++ b/src/docode.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: docode.c,v 1.45 1999/03/11 13:44:27 hubbe Exp $"); +RCSID("$Id: docode.c,v 1.46 1999/04/15 04:08:12 hubbe Exp $"); #include "las.h" #include "program.h" #include "language.h" @@ -676,7 +676,9 @@ static int do_docode2(node *n,int flags) !(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND)); emit(F_APPLY,tmp1); } - if(n->type == void_type_string) return 0; + if(n->type == void_type_string) + return 0; + return 1; }else{ if(CAR(n)->u.sval.u.object == fake_object) diff --git a/src/dynamic_load.c b/src/dynamic_load.c index cedd5ae0ef..84c63e292b 100644 --- a/src/dynamic_load.c +++ b/src/dynamic_load.c @@ -8,7 +8,7 @@ # include "pike_macros.h" # include "main.h" -RCSID("$Id: dynamic_load.c,v 1.34 1999/02/10 21:46:43 hubbe Exp $"); +RCSID("$Id: dynamic_load.c,v 1.35 1999/04/15 04:08:13 hubbe Exp $"); #endif /* !TESTING */ @@ -279,10 +279,20 @@ void f_load_module(INT32 args) new_module->init=init; new_module->exit=exit; - pop_n_elems(args); start_new_program(); +#ifdef PIKE_DEBUG + { struct svalue *save_sp=sp; +#endif (*(modfun)init)(); +#ifdef PIKE_DEBUG + if(sp != save_sp) + fatal("load_module(%s) left %d droppings on stack!\n", + module_name, + sp-save_sp); + } +#endif + pop_n_elems(args); push_program(end_program()); } diff --git a/src/interpret.c b/src/interpret.c index 99f785f640..3d842e9599 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: interpret.c,v 1.119 1999/04/08 23:54:28 hubbe Exp $"); +RCSID("$Id: interpret.c,v 1.120 1999/04/15 04:08:14 hubbe Exp $"); #include "interpret.h" #include "object.h" #include "program.h" @@ -694,6 +694,7 @@ void mega_apply2(enum apply_type type, INT32 args, void *arg1, void *arg2) if(s->subtype == FUNCTION_BUILTIN) { #ifdef PIKE_DEBUG + struct svalue *expected_stack = sp-args; if(t_flag>1) { init_buf(); @@ -702,6 +703,25 @@ void mega_apply2(enum apply_type type, INT32 args, void *arg1, void *arg2) } #endif (*(s->u.efun->function))(args); + +#ifdef PIKE_DEBUG + if(sp != expected_stack + !s->u.efun->may_return_void) + { + if(sp < expected_stack) + fatal("Function popped too many arguments: %s\n", + s->u.efun->name->str); + if(sp>expected_stack+1) + fatal("Function left droppings on stack: %s\n", + s->u.efun->name->str); + if(sp == expected_stack && !s->u.efun->may_return_void) + fatal("Non-void function returned without return value on stack: %s %d\n", + s->u.efun->name->str,s->u.efun->may_return_void); + if(sp==expected_stack+1 && s->u.efun->may_return_void) + fatal("Void function returned with a value on the stack: %s %d\n", + s->u.efun->name->str, s->u.efun->may_return_void); + } +#endif + break; }else{ o=s->u.object; diff --git a/src/modules/Image/encodings/_xpm.c b/src/modules/Image/encodings/_xpm.c index 56931ce4e8..a04aeb13f6 100644 --- a/src/modules/Image/encodings/_xpm.c +++ b/src/modules/Image/encodings/_xpm.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: _xpm.c,v 1.4 1999/04/09 23:18:21 per Exp $"); +RCSID("$Id: _xpm.c,v 1.5 1999/04/15 04:08:34 hubbe Exp $"); #include "config.h" @@ -400,6 +400,7 @@ void init_image__xpm( ) add_constant(s,sp-1,0); free_string(s); } + pop_stack(); } void exit_image__xpm(void) diff --git a/src/modules/Image/encodings/pcx.c b/src/modules/Image/encodings/pcx.c index 435f305f56..1a732bf309 100644 --- a/src/modules/Image/encodings/pcx.c +++ b/src/modules/Image/encodings/pcx.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: pcx.c,v 1.4 1999/04/11 05:37:59 per Exp $"); +RCSID("$Id: pcx.c,v 1.5 1999/04/15 04:08:35 hubbe Exp $"); #include "config.h" @@ -599,6 +599,7 @@ void init_image_pcx( ) add_constant(s,sp-1,0); free_string(s); } + pop_stack(); opt_raw=make_shared_string("raw"); opt_dpy=make_shared_string("dpy"); opt_xdpy=make_shared_string("xdpy"); diff --git a/src/modules/Image/encodings/tga.c b/src/modules/Image/encodings/tga.c index 9fd7e6cf49..46f2053159 100644 --- a/src/modules/Image/encodings/tga.c +++ b/src/modules/Image/encodings/tga.c @@ -1,6 +1,6 @@ /* - * $Id: tga.c,v 1.4 1999/04/06 03:57:08 per Exp $ + * $Id: tga.c,v 1.5 1999/04/15 04:08:36 hubbe Exp $ * * Targa codec for pike. Based on the tga plugin for gimp. * @@ -72,7 +72,7 @@ #include "image.h" #include "colortable.h" -RCSID("$Id: tga.c,v 1.4 1999/04/06 03:57:08 per Exp $"); +RCSID("$Id: tga.c,v 1.5 1999/04/15 04:08:36 hubbe Exp $"); #ifndef MIN # define MIN(X,Y) ((X)<(Y)?(X):(Y)) @@ -946,6 +946,7 @@ void init_image_tga( ) add_constant(s,sp-1,0); free_string(s); } + pop_stack(); param_alpha=make_shared_string("alpha"); param_raw=make_shared_string("raw"); } diff --git a/src/modules/Image/encodings/xbm.c b/src/modules/Image/encodings/xbm.c index cad8b7b09c..e5d2241b74 100644 --- a/src/modules/Image/encodings/xbm.c +++ b/src/modules/Image/encodings/xbm.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: xbm.c,v 1.2 1999/04/12 11:41:14 mirar Exp $"); +RCSID("$Id: xbm.c,v 1.3 1999/04/15 04:08:38 hubbe Exp $"); #include "config.h" @@ -438,6 +438,7 @@ void init_image_xbm( ) add_constant(s,sp-1,0); free_string(s); } + pop_stack(); param_name=make_shared_string("name"); param_fg=make_shared_string("fg"); param_bg=make_shared_string("bg"); diff --git a/src/modules/Image/encodings/xcf.c b/src/modules/Image/encodings/xcf.c index 546ba99ab2..5c16c5bcc2 100644 --- a/src/modules/Image/encodings/xcf.c +++ b/src/modules/Image/encodings/xcf.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: xcf.c,v 1.6 1999/04/13 12:32:47 mirar Exp $"); +RCSID("$Id: xcf.c,v 1.7 1999/04/15 04:08:39 hubbe Exp $"); #include "config.h" @@ -1320,6 +1320,7 @@ void init_image_xcf() add_constant(s,sp-1,0); free_string(s); } + pop_stack(); #define STRING(X) s_##X = make_shared_binary_string(#X,sizeof( #X )-sizeof("")); #include "xcf_constant_strings.h" #undef STRING diff --git a/src/opcodes.c b/src/opcodes.c index 14ab7ceb8b..9bb62807c4 100644 --- a/src/opcodes.c +++ b/src/opcodes.c @@ -23,7 +23,7 @@ #include "module_support.h" #include "security.h" -RCSID("$Id: opcodes.c,v 1.36 1999/04/13 20:10:08 hubbe Exp $"); +RCSID("$Id: opcodes.c,v 1.37 1999/04/15 04:08:15 hubbe Exp $"); void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind) { @@ -527,6 +527,8 @@ void f_cast(void) { #ifdef PIKE_DEBUG struct svalue *save_sp=sp; + if(sp[-2].type != T_STRING) + fatal("Cast expression destroyed stack or left droppings!\n"); #endif o_cast(sp[-2].u.string, compile_type_to_runtime_type(sp[-2].u.string)); -- GitLab