dapdebug.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*********************************************************************
  2. * Copyright 1993, UCAR/Unidata
  3. * See netcdf/COPYRIGHT file for copying and redistribution conditions.
  4. * $Header: /upc/share/CVS/netcdf-3/libncdap3/dapdebug.h,v 1.33 2009/12/03 18:53:16 dmh Exp $
  5. *********************************************************************/
  6. #ifndef DEBUG_H
  7. #define DEBUG_H
  8. #include "ocdebug.h"
  9. #ifdef DAPDEBUG
  10. # define DEBUG
  11. # if DAPDEBUG > 0
  12. # define DEBUG1
  13. # endif
  14. # if DAPDEBUG > 1
  15. # define DEBUG2
  16. # endif
  17. # if DAPDEBUG > 2
  18. # define DEBUG3
  19. # endif
  20. #endif
  21. #undef PARSEDEBUG
  22. #include <stdarg.h>
  23. #include <assert.h>
  24. /* Warning: setting CATCHERROR has significant performance impact */
  25. #undef CATCHERROR
  26. #ifdef DEBUG
  27. #undef CATCHERROR
  28. #define CATCHERROR
  29. #endif
  30. #define PANIC(msg) assert(dappanic(msg));
  31. #define PANIC1(msg,arg) assert(dappanic(msg,arg));
  32. #define PANIC2(msg,arg1,arg2) assert(dappanic(msg,arg1,arg2));
  33. #define ASSERT(expr) if(!(expr)) {PANIC(#expr);} else {}
  34. extern int ncdap3debug;
  35. extern int dappanic(const char* fmt, ...);
  36. #define MEMCHECK(var,throw) {if((var)==NULL) return (throw);}
  37. #ifdef CATCHERROR
  38. /* Place breakpoint on dapbreakpoint to catch errors close to where they occur*/
  39. #define THROW(e) dapthrow(e)
  40. #define THROWCHK(e) (void)dapthrow(e)
  41. extern int dapbreakpoint(int err);
  42. extern int dapthrow(int err);
  43. #else
  44. #define THROW(e) (e)
  45. #define THROWCHK(e)
  46. #endif
  47. #ifdef DEBUG
  48. #define SHOWFETCH (1)
  49. #define LOG0(level,msg) fprintf(stderr,msg)
  50. #define LOG1(level,msg,a1) fprintf(stderr,msg,a1)
  51. #define LOG2(level,msg,a1,a2) fprintf(stderr,msg,a1,a2)
  52. #else
  53. #define SHOWFETCH FLAGSET(nccomm->controls,NCF_SHOWFETCH)
  54. #define LOG0(level,msg) nclog(level,msg)
  55. #define LOG1(level,msg,a1) nclog(level,msg,a1)
  56. #define LOG2(level,msg,a1,a2) nclog(level,msg,a1,a2)
  57. #endif
  58. #endif /*DEBUG_H*/