Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.2 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // MISC
  3. ///////////////////////////////////////////////////////////////////////////////
  4. #ifdef DEBUG
  5. #include <windows.h> // required to avoid error while building platform.h
  6. #include <platform.h> // for __endexcept
  7. #pragma warning(disable: 4127)
  8. #endif
  9. ///////////////////////////////////////////////////////////////////////////////
  10. // ASSERT
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #ifdef DEBUG
  13. // to use within classes that define this member fct
  14. #define ASSERTVALIDSTATE() _DbgAssertValidState()
  15. #ifdef RBDEBUG
  16. #ifndef _RBDEBUG_H
  17. #include "rbdebug.h"
  18. #endif
  19. #ifdef _X86_
  20. #define ASSERT(a) do { CRBDebug::Init(); if ((a)) {;} else { \
  21. if (RBD_ASSERT_BEEP & CRBDebug::_dwFlags) { Beep(1000, 500); } \
  22. else {;} \
  23. if (RBD_ASSERT_TRACE & CRBDebug::_dwFlags) \
  24. { TRACE(TF_ASSERT, TEXT("ASSERT: " TEXT(#a))); } else {;} \
  25. if (RBD_ASSERT_STOP & CRBDebug::_dwFlags) { _try { _asm int 3 } \
  26. _except (EXCEPTION_EXECUTE_HANDLER) {;} } else {;} \
  27. }} while (0)
  28. #else
  29. #define ASSERT(a) do { CRBDebug::Init(); if ((a)) {;} else { \
  30. if (RBD_ASSERT_BEEP & CRBDebug::_dwFlags) { Beep(1000, 500); } \
  31. else {;} \
  32. if (RBD_ASSERT_TRACE & CRBDebug::_dwFlags) \
  33. { TRACE(TF_ASSERT, TEXT("ASSERT: " TEXT(#a))); } else {;} \
  34. if (RBD_ASSERT_STOP & CRBDebug::_dwFlags) { _try { DebugBreak(); } \
  35. _except (EXCEPTION_EXECUTE_HANDLER) {;} __endexcept } else {;} \
  36. }} while (0)
  37. #endif
  38. #else
  39. #ifdef _X86_
  40. #define ASSERT(a) do { if ((a)) {;} else { Beep(1000, 500); \
  41. _try { _asm int 3 } _except (EXCEPTION_EXECUTE_HANDLER) {;} } } \
  42. while (0)
  43. #else
  44. #define ASSERT(a) do { if ((a)) {;} else { Beep(1000, 500); \
  45. _try { DebugBreak(); } _except (EXCEPTION_EXECUTE_HANDLER) {;} \
  46. __endexcept } } while (0)
  47. #endif
  48. #endif
  49. #else
  50. #define ASSERT(a)
  51. #define ASSERTVALIDSTATE()
  52. #endif
  53. ///////////////////////////////////////////////////////////////////////////////
  54. // TRACE
  55. ///////////////////////////////////////////////////////////////////////////////
  56. #ifdef DEBUG
  57. #ifdef RBDEBUG
  58. #ifndef _RBDEBUG_H
  59. #include "rbdebug.h"
  60. #endif
  61. #define TRACE CRBDebug::SetTraceFileAndLine(__FILE__, __LINE__); \
  62. CRBDebug::TraceMsg
  63. #else
  64. #define TRACE DbgTrace
  65. #endif
  66. #else
  67. #define TRACE 1 ? (void)0 : (void)
  68. #endif
  69. ///////////////////////////////////////////////////////////////////////////////
  70. // Others
  71. ///////////////////////////////////////////////////////////////////////////////
  72. #ifdef DEBUG
  73. #define INCDEBUGCOUNTER(a) ++(a)
  74. #define DECDEBUGCOUNTER(a) --(a)
  75. #define DEBUG_ONLY(a) a
  76. void __cdecl DbgTrace(DWORD dwFlags, LPTSTR pszMsg, ...);
  77. #else
  78. #define INCDEBUGCOUNTER(a)
  79. #define DECDEBUGCOUNTER(a)
  80. #define DEBUG_ONLY(a)
  81. #endif