pike.git / src / error.c

version» Context lines:

pike.git/src/error.c:13:   #include "array.h"   #include "object.h"   #include "main.h"   #include "builtin_functions.h"   #include "backend.h"   #include "operators.h"   #include "module_support.h"   #include "threads.h"   #include "gc.h"    - RCSID("$Id: error.c,v 1.51 2000/05/25 02:18:35 hubbe Exp $"); + RCSID("$Id: error.c,v 1.52 2000/07/07 01:24:14 hubbe Exp $");      #undef ATTRIBUTE   #define ATTRIBUTE(X)    - JMP_BUF *recoveries=0; +       #ifdef PIKE_DEBUG   void check_recovery_context(void)   {    char foo; - #define TESTILITEST ((((char *)recoveries)-((char *)&foo))*STACK_DIRECTION) -  if(recoveries && TESTILITEST > 0) -  fatal("Recoveries is out biking (recoveries=%p, sp=%p, %d)!\n",recoveries, &foo,TESTILITEST); + #define TESTILITEST ((((char *)Pike_interpreter.recoveries)-((char *)&foo))*STACK_DIRECTION) +  if(Pike_interpreter.recoveries && TESTILITEST > 0) +  fatal("Recoveries is out biking (Pike_interpreter.recoveries=%p, Pike_sp=%p, %d)!\n",Pike_interpreter.recoveries, &foo,TESTILITEST);       /* Add more stuff here when required */   }      void pike_gdb_breakpoint(void)   {   }   #endif      JMP_BUF *init_recovery(JMP_BUF *r DEBUG_LINE_ARGS)   {    check_recovery_context();   #ifdef PIKE_DEBUG    r->line=line;    r->file=file;    OED_FPRINTF((stderr, "init_recovery(%p) %s:%d\n", r, file, line));   #endif -  r->fp=fp; -  r->sp=sp-evaluator_stack; -  r->mark_sp=mark_sp - mark_stack; -  r->previous=recoveries; +  r->frame_pointer=Pike_fp; +  r->stack_pointer=Pike_sp-Pike_interpreter.evaluator_stack; +  r->mark_sp=Pike_mark_sp - Pike_interpreter.mark_stack; +  r->previous=Pike_interpreter.recoveries;    r->onerror=0;    r->severity=THROW_ERROR; -  recoveries=r; +  Pike_interpreter.recoveries=r;    check_recovery_context();    return r;   }      void pike_throw(void) ATTRIBUTE((noreturn))   { -  while(recoveries && throw_severity > recoveries->severity) +  while(Pike_interpreter.recoveries && throw_severity > Pike_interpreter.recoveries->severity)    { -  while(recoveries->onerror) +  while(Pike_interpreter.recoveries->onerror)    { -  (*recoveries->onerror->func)(recoveries->onerror->arg); -  recoveries->onerror=recoveries->onerror->previous; +  (*Pike_interpreter.recoveries->onerror->func)(Pike_interpreter.recoveries->onerror->arg); +  Pike_interpreter.recoveries->onerror=Pike_interpreter.recoveries->onerror->previous;    }    -  recoveries=recoveries->previous; +  Pike_interpreter.recoveries=Pike_interpreter.recoveries->previous;    }    -  if(!recoveries) +  if(!Pike_interpreter.recoveries)    fatal("No error recovery context.\n");      #ifdef PIKE_DEBUG -  if(sp - evaluator_stack < recoveries->sp) +  if(Pike_sp - Pike_interpreter.evaluator_stack < Pike_interpreter.recoveries->stack_pointer)    fatal("Stack error in error.\n");   #endif    -  while(fp != recoveries->fp) +  while(Pike_fp != Pike_interpreter.recoveries->frame_pointer)    {   #ifdef PIKE_DEBUG -  if(!fp) +  if(!Pike_fp)    fatal("Popped out of stack frames.\n");   #endif    POP_PIKE_FRAME();    }    -  pop_n_elems(sp - evaluator_stack - recoveries->sp); -  mark_sp = mark_stack + recoveries->mark_sp; +  pop_n_elems(Pike_sp - Pike_interpreter.evaluator_stack - Pike_interpreter.recoveries->stack_pointer); +  Pike_mark_sp = Pike_interpreter.mark_stack + Pike_interpreter.recoveries->mark_sp;    -  while(recoveries->onerror) +  while(Pike_interpreter.recoveries->onerror)    { -  (*recoveries->onerror->func)(recoveries->onerror->arg); -  recoveries->onerror=recoveries->onerror->previous; +  (*Pike_interpreter.recoveries->onerror->func)(Pike_interpreter.recoveries->onerror->arg); +  Pike_interpreter.recoveries->onerror=Pike_interpreter.recoveries->onerror->previous;    }    -  longjmp(recoveries->recovery,1); +  longjmp(Pike_interpreter.recoveries->recovery,1);   }      void push_error(char *description)   {    push_text(description);    f_backtrace(0);    f_aggregate(2);   }      struct svalue throw_value = { T_INT };   int throw_severity;   static const char *in_error;      void low_error(char *buf) ATTRIBUTE((noreturn))   {    push_error(buf);    free_svalue(& throw_value); -  throw_value = *--sp; +  throw_value = *--Pike_sp;    throw_severity = THROW_ERROR;    in_error=0;    pike_throw(); /* Hope someone is catching, or we will be out of balls. */   }      /* FIXME: NOTE: This function uses a static buffer.    * Check sizes of arguments passed!    */   void va_error(const char *fmt, va_list args) ATTRIBUTE((noreturn))   {
pike.git/src/error.c:140:    }       in_error=buf;      #ifdef HAVE_VSNPRINTF    vsnprintf(buf, 4090, fmt, args);   #else /* !HAVE_VSNPRINTF */    VSPRINTF(buf, fmt, args);   #endif /* HAVE_VSNPRINTF */    -  if(!recoveries) +  if(!Pike_interpreter.recoveries)    {   #ifdef PIKE_DEBUG    dump_backlog();   #endif       fprintf(stderr,"No error recovery context!\n%s",buf);    exit(99);    }       if((long)strlen(buf) >= (long)sizeof(buf))
pike.git/src/error.c:172:       if(in_error)    {    const char *tmp=in_error;    in_error=0;    fatal("Recursive error() calls, original error: %s",tmp);    }       in_error=text;    -  if(!recoveries) +  if(!Pike_interpreter.recoveries)    {   #ifdef PIKE_DEBUG    dump_backlog();   #endif       fprintf(stderr,"No error recovery context!\n%s():%s",name,text);    if(file)    fprintf(stderr,"at %s:%d\n",file,line);    exit(99);    }
pike.git/src/error.c:209:    }       f_aggregate(args + 3);    f_aggregate(1);       f_add(2);       f_aggregate(2);       free_svalue(& throw_value); -  throw_value = *--sp; +  throw_value = *--Pike_sp;    throw_severity=THROW_ERROR;       in_error=0;    pike_throw(); /* Hope someone is catching, or we will be out of balls. */   }      void exit_on_error(void *msg)   {    ONERROR tmp;    SET_ONERROR(tmp,fatal_on_error,"Fatal in exit_on_error!");
pike.git/src/error.c:288:    if(Pike_in_gc)    {    fprintf(stderr,"Pike was in GC stage %d when this fatal occured:\n",Pike_in_gc);    Pike_in_gc=0;    }    }       (void)VFPRINTF(stderr, fmt, args);       d_flag=t_flag=0; -  if(Pike_sp && evaluator_stack) +  if(Pike_sp && Pike_interpreter.evaluator_stack)    {    fprintf(stderr,"Attempting to dump backlog (may fail)...\n");    push_error("Backtrace at time of fatal:\n");    APPLY_MASTER("describe_backtrace",1); -  if(sp[-1].type==T_STRING) -  write_to_stderr(sp[-1].u.string->str, sp[-1].u.string->len); +  if(Pike_sp[-1].type==T_STRING) +  write_to_stderr(Pike_sp[-1].u.string->str, Pike_sp[-1].u.string->len);    }else{    fprintf(stderr,"No stack - no backtrace.\n");    }    fflush(stderr);    abort();   }      #if 1      #define ERR_DECLARE
pike.git/src/error.c:339:    {    case 0:    pop_n_elems(args);    ref_push_string(GENERIC_ERROR_THIS->desc);    break;    case 1:    pop_n_elems(args);    ref_push_array(GENERIC_ERROR_THIS->backtrace);    break;    default: -  index_error("error->`[]", sp-args, args, NULL, sp-args, +  index_error("error->`[]", Pike_sp-args, args, NULL, Pike_sp-args,    "Index %d is out of range 0 - 1.\n", ind);    break;    }   }         void f_error_describe(INT32 args)   {    pop_n_elems(args); -  ref_push_object(fp->current_object); +  ref_push_object(Pike_fp->current_object);    APPLY_MASTER("describe_backtrace",1);   }      void f_error_backtrace(INT32 args)   {    pop_n_elems(args);    ref_push_array(GENERIC_ERROR_THIS->backtrace);   }      #ifdef ERROR_DEBUG
pike.git/src/error.c:441:    push_int(0);    push_text(func);       for (i=0;i<args;i++)    push_svalue(base_sp + i);    f_aggregate(args + 3);    f_aggregate(1);    f_add(2);    }    -  if(sp[-1].type!=T_ARRAY) +  if(Pike_sp[-1].type!=T_ARRAY)    fatal("Error failed to generate a backtrace!\n");    -  ERROR_STRUCT(generic,o)->backtrace=sp[-1].u.array; -  sp--; -  dmalloc_touch_svalue(sp); +  ERROR_STRUCT(generic,o)->backtrace=Pike_sp[-1].u.array; +  Pike_sp--; +  dmalloc_touch_svalue(Pike_sp);       free_svalue(& throw_value);    throw_value.type=T_OBJECT;    throw_value.u.object=o;    throw_severity = THROW_ERROR;    in_error=0;    pike_throw(); /* Hope someone is catching, or we will be out of balls. */   }      void generic_error(
pike.git/src/error.c:555:   void wrong_number_of_args_error(char *name, int args, int expected)   {    char *msg;    if(expected>args)    {    msg="Too few arguments";    }else{    msg="Too many arguments";    }    -  new_error(name, msg, sp-args, args, 0,0); +  new_error(name, msg, Pike_sp-args, args, 0,0);   }      #ifdef PIKE_DEBUG   static void gc_check_throw_value(struct callback *foo, void *bar, void *gazonk)   {    debug_gc_xmark_svalues(&throw_value,1," in the throw value");   }   #endif      void init_error(void)