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.161 2008/05/27 19:10:33 grubba Exp $ + || $Id: error.c,v 1.162 2008/05/27 19:36:00 grubba 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"
pike.git/src/error.c:921:   #define DWERROR(X) fprintf X   #else /* !ERROR_DEBUG */   #define DWERROR(X)   #endif /* ERROR_DEBUG */      #define INIT_ERROR(FEL)\    va_list foo; \    struct object *o; \    va_start(foo,desc); \    ASSERT_THREAD_SWAPPED_IN(); \ -  o=low_clone(PIKE_CONCAT(FEL,_error_program)); \ +  o=fast_clone_object(PIKE_CONCAT(FEL,_error_program)); \    DWERROR((stderr, "%s(): Throwing a " #FEL " error\n", func))      #define ERROR_DONE(FOO) \    PIKE_CONCAT(FOO,_error_va(o,func, \    base_sp, args, \    desc, &foo)); \    va_end(foo)      #define ERROR_STRUCT(STRUCT,O) \    ((struct PIKE_CONCAT(STRUCT,_error_struct) *)((O)->storage + PIKE_CONCAT(STRUCT,_error_offset)))
pike.git/src/error.c:963:    *    * o A backtrace is assigned to error_backtrace.    *    * o If func is specified, a frame is constructed for at the end of    * backtrace using it as function name and base_sp[0..args-1] as    * arguments.    *    * o If fmt is specified, an error message is created from it and    * fmt_args using string_builder_vsprintf. (fmt_args is passed as a    * va_list pointer to be able to pass NULL if fmt is NULL.) -  * -  * Note: error_message and error_backtrace are not freed before being -  * assigned. +     */   PMOD_EXPORT DECLSPEC(noreturn) void generic_error_va(    struct object *o, const char *func, const struct svalue *base_sp, int args,    const char *fmt, va_list *fmt_args)   {    struct generic_error_struct *err =    (struct generic_error_struct *) get_storage (o, generic_error_program);      #ifdef PIKE_DEBUG    if (!err)
pike.git/src/error.c:998:    struct string_builder s;    init_string_builder(&s, 0);    string_builder_vsprintf(&s, fmt, *fmt_args);      #if 0    if (!master_program) {    fprintf(stderr, "ERROR: %s\n", s.s->str);    }   #endif    +  if (err->error_message) free_string(err->error_message);    err->error_message = finish_string_builder(&s);    }       f_backtrace(0);       if(func)    {    int i;    push_int(0);    push_int(0);
pike.git/src/error.c:1020:    for (i=0;i<args;i++)    push_svalue(base_sp + i);    f_aggregate(args + 3);    f_aggregate(1);    f_add(2);    }       if(Pike_sp[-1].type!=PIKE_T_ARRAY)    Pike_fatal("f_backtrace failed to generate a backtrace!\n");    +  if (err->error_backtrace) free_array(err->error_backtrace);    err->error_backtrace=Pike_sp[-1].u.array;    Pike_sp--;    dmalloc_touch_svalue(Pike_sp);       free_svalue(& throw_value);    throw_value.type=PIKE_T_OBJECT;    throw_value.subtype = 0;    throw_value.u.object=o;    throw_severity = THROW_ERROR;    in_error=0;       dmalloc_touch_svalue(& throw_value);       pike_throw(); /* Hope someone is catching, or we will be out of balls. */   }       -  + /* Throw a preallocated error object. +  * +  * NOTE: The object MUST NOT have been cloned by a plain low_clone()! +  * At least fast_clone_object() MUST have been used, or the object +  * data must have been properly initialized in some other way! +  */   PMOD_EXPORT DECLSPEC(noreturn) void throw_error_object(    struct object *o,    const char *func,    struct svalue *base_sp, int args,    const char *desc, ...) ATTRIBUTE((noreturn))   {    va_list foo;    va_start(foo,desc);    ASSERT_THREAD_SWAPPED_IN();    DWERROR((stderr, "%s(): Throwing an error object\n", func));