debug.hpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef DEBUG_H
  2. #define DEBUG_H
  3. #ifndef CWDEBUG
  4. #include <iostream> // std::cerr
  5. #include <cstdlib> // std::exit, EXIT_FAILURE
  6. #define AllocTag1(p)
  7. #define AllocTag2(p, desc)
  8. #define AllocTag_dynamic_description(p, data)
  9. #define AllocTag(p, data)
  10. #define Debug(STATEMENT...)
  11. #define Dout(cntrl, data)
  12. #define DoutFatal(cntrl, data) LibcwDoutFatal(, , cntrl, data)
  13. #define ForAllDebugChannels(STATEMENT...)
  14. #define ForAllDebugObjects(STATEMENT...)
  15. #define LibcwDebug(dc_namespace, STATEMENT...)
  16. #define LibcwDout(dc_namespace, d, cntrl, data)
  17. #define LibcwDoutFatal(dc_namespace, d, cntrl, data) do { ::std::cerr << data << ::std::endl; ::std::exit(EXIT_FAILURE); } while(1)
  18. #define LibcwdForAllDebugChannels(dc_namespace, STATEMENT...)
  19. #define LibcwdForAllDebugObjects(dc_namespace, STATEMENT...)
  20. #define NEW(x) new x
  21. #define CWDEBUG_ALLOC 0
  22. #define CWDEBUG_MAGIC 0
  23. #define CWDEBUG_LOCATION 0
  24. #define CWDEBUG_LIBBFD 0
  25. #define CWDEBUG_DEBUG 0
  26. #define CWDEBUG_DEBUGOUTPUT 0
  27. #define CWDEBUG_DEBUGM 0
  28. #define CWDEBUG_DEBUGT 0
  29. #define CWDEBUG_MARKER 0
  30. #define turnOnAllDebug(p)
  31. #define turnOffAllDebug(p)
  32. #else // CWDEBUG
  33. // This must be defined before <libcwd/debug.h> is included and must be the
  34. // name of the namespace containing your `dc' (Debug Channels) namespace
  35. // (see below). You can use any namespace(s) you like, except existing
  36. // namespaces (like ::, ::std and ::libcwd).
  37. #define DEBUGCHANNELS ::objsim::debug::channels
  38. #include <libcwd/debug.h>
  39. namespace objsim {
  40. namespace debug {
  41. void init(void); // Initialize debugging code from main().
  42. void init_thread(void); // Initialize debugging code from new threads.
  43. namespace channels { // This is the DEBUGCHANNELS namespace, see above.
  44. namespace dc { // 'dc' is defined inside DEBUGCHANNELS.
  45. using namespace libcwd::channels::dc;
  46. using libcwd::channel_ct;
  47. // Add the declaration of new debug channels here
  48. // and add their definition in a custom debug.cc file.
  49. extern channel_ct custom;
  50. extern channel_ct layer;
  51. extern channel_ct simloop;
  52. extern channel_ct element;
  53. extern channel_ct con;
  54. extern channel_ct input;
  55. extern channel_ct smod;
  56. extern channel_ct anyopt;
  57. extern channel_ct learn;
  58. extern channel_ct main;
  59. extern channel_ct para;
  60. extern channel_ct utils;
  61. extern channel_ct chunk;
  62. } // namespace dc
  63. } // namespace DEBUGCHANNELS
  64. }
  65. }
  66. void turnOnAllDebug();
  67. void turnOffAllDebug();
  68. #endif // CWDEBUG
  69. #endif // DEBUG_H