debug.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _DEBUG_H
  2. #define _DEBUG_H
  3. #ifdef HAVE_CONFIG_H
  4. # include "config.h"
  5. #endif
  6. #if !HAVE_SIGACTION /* old "weird signals" */
  7. # define sigaction sigvec
  8. # ifndef sa_handler
  9. # define sa_handler sv_handler
  10. # define sa_mask sv_mask
  11. # define sa_flags sv_flags
  12. # endif
  13. #endif
  14. #if !HAVE_SIGEMPTYSET
  15. /* and they probably won't have sigemptyset, dammit */
  16. # define sigemptyset(x) ((*(int *)(x))=0)
  17. #endif
  18. /*
  19. * Undefine this to completely disable context debugging.
  20. * WARNING: DO NOT send in bug reports if you undefine this!
  21. */
  22. #define DEBUG_CONTEXT
  23. /*
  24. * Handy aliases for memory tracking and core dumps
  25. */
  26. #ifdef DEBUG_CONTEXT
  27. # include "main.h"
  28. # define Context eggContext(__FILE__, __LINE__, NULL)
  29. # define ContextNote(note) eggContextNote(__FILE__, __LINE__, NULL, note)
  30. #else
  31. # define Context {}
  32. # define ContextNote(note) {}
  33. #endif
  34. #ifdef DEBUG_ASSERT
  35. # define Assert(expr) do { \
  36. if (!(expr)) \
  37. eggAssert(__FILE__, __LINE__, NULL); \
  38. } while (0)
  39. #else
  40. # define Assert(expr) do { } while (0)
  41. #endif
  42. #define debug0(x) putlog(LOG_DEBUG,"*",x)
  43. #define debug1(x,a1) putlog(LOG_DEBUG,"*",x,a1)
  44. #define debug2(x,a1,a2) putlog(LOG_DEBUG,"*",x,a1,a2)
  45. #define debug3(x,a1,a2,a3) putlog(LOG_DEBUG,"*",x,a1,a2,a3)
  46. #define debug4(x,a1,a2,a3,a4) putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
  47. #ifndef MAKING_MODS
  48. void sdprintf (char *, ...);
  49. void init_signals();
  50. void eggContext(const char *, int, const char *);
  51. void eggContextNote(const char *, int, const char *, const char *);
  52. void eggAssert(const char *, int, const char *);
  53. #endif /* !MAKING_MODS */
  54. #endif /* !_DEBUG_H */