netcdf-c/libdap2/dapdebug.h
Dennis Heimbigner 6934aa2e8b Thread safety: step 1: cleanup
re: https://github.com/Unidata/netcdf-c/issues/1373 (partial)

* Mark some global constants be const to indicate to make them easier to track.
* Hide direct access to the ncrc_globalstate behind a function call.
* Convert dispatch tables to constants (except the user defined ones)
  This has some consequences in terms of function arguments needing to be marked
  as const also.
* Remove some no longer needed global fields
* Aggregate all the globals in nclog.c
* Uniformly replace nc_sizevector{0,1} with NC_coord_{zero,one}
* Uniformly replace nc_ptrdffvector1 with NC_stride_one
* Remove some obsolete code
2019-03-30 14:06:20 -06:00

78 lines
1.7 KiB
C

/*********************************************************************
* Copyright 2018, 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
/* Dump info about constraint processing */
#undef DCEVERBOSE
#undef PARSEDEBUG
/* Warning: setting CATCHERROR has significant performance impact */
#undef 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,__LINE__,__FILE__)
#define THROWCHK(e) (void)dapthrow(e,__LINE__,__FILE__)
extern int dapbreakpoint(int err);
extern int dapthrow(int err, int lineno, const char* filename);
#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*/