netcdf-c/libdap2/dapdebug.h

75 lines
1.7 KiB
C
Raw Normal View History

2011-04-18 02:56:10 +08:00
/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
#ifndef DEBUG_H
#define DEBUG_H
2017-07-14 01:45:52 +08:00
#if 0
2013-02-26 12:31:06 +08:00
#define DAPDEBUG 1
2013-11-15 06:13:20 +08:00
#define OCDEBUG 1
2013-02-26 12:31:06 +08:00
#endif
#include "ocdebug.h"
#ifdef DAPDEBUG
# define DEBUG
# if DAPDEBUG > 0
# define DEBUG1
# endif
# if DAPDEBUG > 1
# define DEBUG2
# endif
2012-02-04 05:31:50 +08:00
# if DAPDEBUG > 2
# define DEBUG3
# endif
#endif
2011-11-14 12:20:19 +08:00
2011-04-18 02:56:10 +08:00
#undef PARSEDEBUG
2016-04-07 09:51:40 +08:00
/* Warning: setting CATCHERROR has significant performance impact */
2017-07-15 05:32:17 +08:00
#undef CATCHERROR
2011-04-18 02:56:10 +08:00
#include <stdarg.h>
#include <assert.h>
#ifdef DAPDEBUG
2011-04-18 02:56:10 +08:00
#undef CATCHERROR
#define CATCHERROR
#endif
#define PANIC(msg) assert(dappanic(msg));
#define PANIC1(msg,arg) assert(dappanic(msg,arg));
#define PANIC2(msg,arg1,arg2) assert(dappanic(msg,arg1,arg2));
#define ASSERT(expr) if(!(expr)) {PANIC(#expr);} else {}
extern int ncdap3debug;
extern int dappanic(const char* fmt, ...);
#define MEMCHECK(var,throw) {if((var)==NULL) return (throw);}
#ifdef CATCHERROR
/* Place breakpoint on dapbreakpoint to catch errors close to where they occur*/
#define THROW(e) dapthrow(e,__LINE__,__FILE__)
#define THROWCHK(e) (void)dapthrow(e,__LINE__,__FILE__)
2011-04-18 02:56:10 +08:00
extern int dapbreakpoint(int err);
extern int dapthrow(int err, int lineno, const char* filename);
2011-04-18 02:56:10 +08:00
#else
#define THROW(e) (e)
#define THROWCHK(e)
#endif
#ifdef DEBUG
#define SHOWFETCH (1)
#else
#define SHOWFETCH FLAGSET(nccomm->controls,NCF_SHOWFETCH)
#endif
#define LOG0(level,msg) nclog(level,msg)
#define LOG1(level,msg,a1) nclog(level,msg,a1)
#define LOG2(level,msg,a1,a2) nclog(level,msg,a1,a2)
2011-04-18 02:56:10 +08:00
#endif /*DEBUG_H*/