From 294dc509f9513cff9fef4eec2fa65b90ff397d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Sun, 3 Aug 1997 02:55:11 -0700 Subject: [PATCH] more debug and better error messages Rev: src/error.c:1.7 Rev: src/interpret.c:1.44 Rev: src/language.yacc:1.44 Rev: src/las.c:1.35 Rev: src/program.c:1.36 --- src/error.c | 2 +- src/interpret.c | 5 ++++- src/language.yacc | 21 +++++++++++++++++++-- src/las.c | 12 +++++++++++- src/program.c | 13 +++++++++++-- 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/error.c b/src/error.c index 1e0c968a68..0207417f14 100644 --- a/src/error.c +++ b/src/error.c @@ -35,7 +35,7 @@ void throw() ATTRIBUTE((noreturn)) #ifdef DEBUG if(sp - evaluator_stack < recoveries->sp) - fatal("Error in error.\n"); + fatal("Stack error in error.\n"); #endif while(fp != recoveries->fp) diff --git a/src/interpret.c b/src/interpret.c index 34219756a7..25cdaa884a 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: interpret.c,v 1.43 1997/07/19 20:25:24 hubbe Exp $"); +RCSID("$Id: interpret.c,v 1.44 1997/08/03 09:55:06 hubbe Exp $"); #include "interpret.h" #include "object.h" #include "program.h" @@ -521,6 +521,9 @@ static void eval_instruction(unsigned char *pc) if(fp->fun>=0 && fp->current_object->prog && fp->locals+fp->num_locals > sp) fatal("Stack error (stupid!).\n"); + + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error (underflow)\n"); if(d_flag > 9) do_debug(); diff --git a/src/language.yacc b/src/language.yacc index a9e7a33ba2..d48a2668b9 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -156,7 +156,7 @@ /* This is the grammar definition of Pike. */ #include "global.h" -RCSID("$Id: language.yacc,v 1.43 1997/06/07 01:16:26 hubbe Exp $"); +RCSID("$Id: language.yacc,v 1.44 1997/08/03 09:55:07 hubbe Exp $"); #ifdef HAVE_MEMORY_H #include <memory.h> #endif @@ -542,6 +542,10 @@ def: modifiers type_or_error optional_stars F_IDENTIFIER '(' arguments ')' } dooptcode($4, $9, $<string>8, $1); +#ifdef DEBUG + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error (underflow)\n"); +#endif } if(local_variables->current_return_type) { @@ -560,7 +564,7 @@ def: modifiers type_or_error optional_stars F_IDENTIFIER '(' arguments ')' | error ';' { yyerrok; } { reset_type_stack(); - if(num_parse_error>5) YYACCEPT; +/* if(num_parse_error>5) YYACCEPT; */ } ; @@ -891,6 +895,10 @@ lambda: F_LAMBDA mknode(F_ARG_LIST,$4,mknode(F_RETURN,mkintnode(0),0)), type, 0); +#ifdef DEBUG + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error (underflow)\n"); +#endif free_string(name); free_string(type); comp_stackp=$<number>2; @@ -1348,6 +1356,11 @@ void yyerror(char *str) extern int num_parse_error; extern int cumulative_parse_error; +#ifdef DEBUG + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error (underflow)\n"); +#endif + if (num_parse_error > 5) return; num_parse_error++; cumulative_parse_error++; @@ -1365,6 +1378,10 @@ void yyerror(char *str) sp++; SAFE_APPLY_MASTER("compile_error",3); pop_stack(); +#ifdef DEBUG + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error (underflow)\n"); +#endif }else{ (void)fprintf(stderr, "%s:%ld: %s\n", current_file->str, diff --git a/src/las.c b/src/las.c index 4597137111..386ec58766 100644 --- a/src/las.c +++ b/src/las.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: las.c,v 1.34 1997/05/22 23:27:32 hubbe Exp $"); +RCSID("$Id: las.c,v 1.35 1997/08/03 09:55:09 hubbe Exp $"); #include "language.h" #include "interpret.h" @@ -2037,6 +2037,11 @@ int dooptcode(struct pike_string *name, int args, vargs, ret; struct svalue *foo; +#ifdef DEBUG + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error before dooptcode (underflow)\n"); +#endif + #ifdef DEBUG if(a_flag > 1) fprintf(stderr,"Doing function '%s' at %x\n",name->str,PC); @@ -2084,6 +2089,11 @@ int dooptcode(struct pike_string *name, do_code_block(n); } +#ifdef DEBUG + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error after do_code_block (underflow)\n"); +#endif + ret=define_function(name, type, modifiers, diff --git a/src/program.c b/src/program.c index e0f9fdaf2a..4cc6967ce4 100644 --- a/src/program.c +++ b/src/program.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: program.c,v 1.35 1997/07/18 01:44:22 hubbe Exp $"); +RCSID("$Id: program.c,v 1.36 1997/08/03 09:55:11 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -113,7 +113,12 @@ int find_module_identifier(struct pike_string *ident) { JMP_BUF tmp; - if(SETJMP(tmp)) +#ifdef DEBUG + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error in compiation (underflow)\n"); +#endif + + if(SETJMP(tmp)) { ONERROR tmp; SET_ONERROR(tmp,exit_on_error,"Error in handle_error in master object!"); @@ -1518,6 +1523,10 @@ void compile() init_node=0; yyparse(); /* Parse da program */ +#ifdef DEBUG + if(recoveries && sp-evaluator_stack < recoveries->sp) + fatal("Stack error in compilation (underflow after yyparse)\n"); +#endif free_all_local_names(); } -- GitLab