debug.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef _DEBUG_H
  2. #define _DEBUG_H
  3. #ifdef HAVE_CONFIG_H
  4. # include "config.h"
  5. #endif
  6. #define GET_BUFS 30
  7. #define get_buf_inc() if (++current_get_buf == GET_BUFS) current_get_buf = 0;
  8. #define Context do { \
  9. simple_snprintf(get_buf[current_get_buf], sizeof(get_buf[current_get_buf]), "Context: %s:%d", __FILE__, __LINE__); \
  10. get_buf_inc(); \
  11. } while (0)
  12. #define ContextNote(_from, _buf) do { \
  13. simple_snprintf(get_buf[current_get_buf], sizeof(get_buf[current_get_buf]), "%s: %s", _from, _buf); \
  14. get_buf_inc(); \
  15. } while(0)
  16. /*
  17. * Handy aliases for memory tracking and core dumps
  18. */
  19. #define debug0(x) putlog(LOG_DEBUG,"*",x)
  20. #define debug1(x,a1) putlog(LOG_DEBUG,"*",x,a1)
  21. #define debug2(x,a1,a2) putlog(LOG_DEBUG,"*",x,a1,a2)
  22. #define debug3(x,a1,a2,a3) putlog(LOG_DEBUG,"*",x,a1,a2,a3)
  23. #define debug4(x,a1,a2,a3,a4) putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
  24. #include "net.h"
  25. extern bool sdebug, segfaulted;
  26. extern size_t current_get_buf;
  27. extern char get_buf[GET_BUFS][SGRAB + 5];
  28. void setlimits();
  29. void sdprintf (const char *, ...) __attribute__((format(printf, 1, 2)));
  30. void init_signals();
  31. void init_debug();
  32. void got_int(int z);
  33. #endif /* !_DEBUG_H */