From 0abfe069b983506f6d936b4b631f8466d98f009c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Mon, 13 Jul 1998 01:41:52 +0200 Subject: [PATCH] Added extra debug for SET_ONERROR() and UNSET_ONERROR(). Rev: src/error.h:1.19 --- src/error.h | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/error.h b/src/error.h index 3eefbc0036..eb93727049 100644 --- a/src/error.h +++ b/src/error.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: error.h,v 1.18 1998/04/17 05:08:01 hubbe Exp $ + * $Id: error.h,v 1.19 1998/07/12 23:41:52 grubba Exp $ */ #ifndef ERROR_H #define ERROR_H @@ -38,6 +38,10 @@ struct frame; typedef struct ONERROR { struct ONERROR *previous; +#ifdef DEBUG + const char *file; + int line; +#endif /* DEBUG */ error_call func; void *arg; } ONERROR; @@ -60,22 +64,41 @@ extern int throw_severity; #define SETJMP(X) setjmp((init_recovery(&X)->recovery)) #define UNSETJMP(X) recoveries=X.previous; +#ifdef DEBUG #define SET_ONERROR(X,Y,Z) \ do{ \ if(!recoveries) break; \ X.func=(error_call)(Y); \ X.arg=(void *)(Z); \ X.previous=recoveries->onerror; \ + X.file = __FILE__; \ + X.line = __LINE__; \ recoveries->onerror=&X; \ }while(0) -#ifdef DEBUG #define UNSET_ONERROR(X) do {\ - if(!recoveries) break; \ - if(recoveries->onerror != &(X)) fatal("UNSET_ONERROR out of sync.\n"); \ - recoveries->onerror=(X).previous; \ + if(!recoveries) break; \ + if(recoveries->onerror != &(X)) { \ + if (recoveries->onerror) { \ + fatal("UNSET_ONERROR out of sync.\n" \ + "Last SET_ONERROR is from %s:%d\n", \ + recoveries->onerror->file, recoveries->onerror->line ); \ + } else { \ + fatal("UNSET_ONERROR out of sync.\n"); \ + } \ + } \ + recoveries->onerror=(X).previous; \ } while(0) #else +#define SET_ONERROR(X,Y,Z) \ + do{ \ + if(!recoveries) break; \ + X.func=(error_call)(Y); \ + X.arg=(void *)(Z); \ + X.previous=recoveries->onerror; \ + recoveries->onerror=&X; \ + }while(0) + #define UNSET_ONERROR(X) recoveries && (recoveries->onerror=X.previous) #endif -- GitLab