ref: ce708f49bf5ec6c6b3fe1bb29d401c42b841b649
dir: /error.c/
#include <u.h> #include <libc.h> #include "dat.h" #include "fns.h" s8 envpidx = -1; /* the index in _privates holding the Errenv location. hack: hoping that this will be the same across all processes */ Errenv **envpp = nil; extern int dprint(char *fmt, ...); void showerrenv(char *msg) { u8 i; Errenv *env = *envpp; dprint("%s", msg); dprint("env 0x%p env->nlabel %hhud\n", env, env->nlabel); for(i = 0; i < env->nlabel; i++){ dprint("i %hhud pc 0x%p\n", i, env->label[i][JMPBUFPC]); } } void nexterror(void) { Errenv *env = *envpp; // showerrenv("nexterror before\n"); longjmp(env->label[--env->nlabel], 1); } void error(s8 *fmt, ...) { va_list arg; char buf[ERRMAX]; va_start(arg, fmt); vseprint(buf, buf+ERRMAX, fmt, arg); va_end(arg); // dprint("error: %s\n", buf); errstr(buf, ERRMAX); nexterror(); }