forked from Unidata/netcdf-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dapdebug.h
74 lines (58 loc) · 1.61 KB
/
dapdebug.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
#ifndef DEBUG_H
#define DEBUG_H
#if 0
#define DAPDEBUG 1
#define OCDEBUG 1
#endif
#include "ocdebug.h"
#ifdef DAPDEBUG
# define DEBUG
# if DAPDEBUG > 0
# define DEBUG1
# endif
# if DAPDEBUG > 1
# define DEBUG2
# endif
# if DAPDEBUG > 2
# define DEBUG3
# endif
#endif
#undef PARSEDEBUG
/* Warning: setting CATCHERROR has significant performance impact */
#define CATCHERROR
#include <stdarg.h>
#include <assert.h>
#ifdef DAPDEBUG
#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)
#define THROWCHK(e) (void)dapthrow(e)
extern int dapbreakpoint(int err);
extern int dapthrow(int err);
#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)
#endif /*DEBUG_H*/