pike.git / src / error.c

version» Context lines:

pike.git/src/error.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: error.c,v 1.123 2004/05/19 00:04:38 nilsson Exp $ + || $Id: error.c,v 1.124 2004/06/01 19:12:06 mast Exp $   */      #define NO_PIKE_SHORTHAND   #include "global.h"   #include "svalue.h"   #include "pike_macros.h"   #include "pike_error.h"   #include "interpret.h"   #include "stralloc.h"   #include "builtin_functions.h"   #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.123 2004/05/19 00:04:38 nilsson Exp $"); + RCSID("$Id: error.c,v 1.124 2004/06/01 19:12:06 mast Exp $");      /* __attribute__ only applies to function declarations, not    definitions, so we disable them here. */   #undef ATTRIBUTE   #define ATTRIBUTE(X)      PMOD_EXPORT const char msg_fatal_error[] =    "%s:%d: Fatal error:\n";   #ifdef PIKE_DEBUG   PMOD_EXPORT const char msg_unsetjmp_nosync_1[] =
pike.git/src/error.c:50:   PMOD_EXPORT const char msg_bad_arg[] =    "Bad argument %d to %s(). Expected %s.\n";   PMOD_EXPORT const char msg_bad_arg_2[] =    "Bad argument %d to %s(). %s\n";   PMOD_EXPORT const char msg_out_of_mem[] =    "Out of memory.\n";   PMOD_EXPORT const char msg_div_by_zero[] =    "Division by zero.\n";      /* -  * Attempt to inhibit throwing of errors if possible. -  * Used by exit_on_error() to avoid infinite sprintf() loops. -  */ - int Pike_inhibit_errors = 0; -  - /* +     * Recoveries handling.    */      JMP_BUF *recoveries=0;      #ifdef PIKE_DEBUG   PMOD_EXPORT void check_recovery_context(void)   {    char foo;   #define TESTILITEST ((((char *)Pike_interpreter.recoveries)-((char *)&foo))*STACK_DIRECTION)
pike.git/src/error.c:298:       f_aggregate(2);       move_svalue (&throw_value, --Pike_sp);    throw_severity=THROW_ERROR;       in_error=0;    pike_throw(); /* Hope someone is catching, or we will be out of balls. */   }    + static int inhibit_errors = 0; +    PMOD_EXPORT void exit_on_error(const void *msg)   {    ONERROR tmp;    SET_ONERROR(tmp,fatal_on_error,"Fatal in exit_on_error!");    d_flag=0; -  +  Pike_interpreter.trace_level = 0;    -  /* Tell sprintf(), describe_svalue() et al not to throw errors -  * if possible. -  */ -  Pike_inhibit_errors = 1; +  if (inhibit_errors) +  fprintf (stderr, "Got recursive error in exit_on_error: %s\n", (char *) msg);    -  +  else { +  dynamic_buffer save_buf; +  char *s; +  struct svalue thrown; +  +  inhibit_errors = 1; +    #ifdef PIKE_DEBUG    if (d_flag) {    fprintf(stderr,"%s\n",(char *)msg);    dump_backlog();    }   #endif -  +     fprintf(stderr,"%s\n",(char *)msg); - #ifdef PIKE_DEBUG -  { -  dynamic_buffer save_buf; -  char *s; -  struct svalue thrown; +  +  /* We've reserved LOW_SVALUE_STACK_MARGIN and LOW_C_STACK_MARGIN +  * for this. */ +  Pike_interpreter.svalue_stack_margin = 0; +  Pike_interpreter.c_stack_margin = 0;    fprintf(stderr,"Attempting to dump raw error: (may fail)\n");    init_buf(&save_buf);    move_svalue (&thrown, &throw_value);    throw_value.type = PIKE_T_INT;    describe_svalue(&thrown,0,0);    free_svalue (&thrown);    s=simple_free_buf(&save_buf);    fprintf(stderr,"%s\n",s);    free(s);    } - #endif +     exit(1);   }      #ifdef __NT__   /* Wrapper around abort() to avoid interactive requesters on NT. */   int fnordel=0;   static void do_abort()   {    if (!d_flag && !getenv("PIKE_DEBUG")) {    exit(-6); /* -SIGIOT */