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.

126 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1994-1999 Microsoft Corporation
  3. Module Name :
  4. debugafx.h
  5. Abstract:
  6. Debugging routines using ATL extensions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager
  12. Revision History:
  13. 3/20/2000 sergeia Made this compatible to ATL, not MFC
  14. --*/
  15. #ifndef _DEBUGATL_H
  16. #define _DEBUGATL_H
  17. #if defined(_DEBUG) || DBG
  18. #undef ATLASSERT
  19. #undef ASSERT
  20. #undef _ASSERTE
  21. #undef VERIFY
  22. #define _ASSERTE(expr)\
  23. do { if (!(expr) &&\
  24. (IISUIFireAssert(__FILE__, __TIMESTAMP__, __LINE__, #expr)==1))\
  25. DebugBreak(); } while (0)
  26. #define ASSERT(expr) _ASSERTE(expr)
  27. #define VERIFY(expr) _ASSERTE(expr)
  28. #define ATLASSERT(expr) _ASSERTE(expr)
  29. #define ASSERT_PTR(ptr) _ASSERTE(ptr != NULL);
  30. #define ASSERT_READ_PTR(ptr) _ASSERTE(ptr != NULL && !IsBadReadPtr(ptr, sizeof(*ptr)));
  31. #define ASSERT_READ_PTR2(ptr, cb) _ASSERTE(ptr != NULL && !IsBadReadPtr(ptr, cb));
  32. #define ASSERT_WRITE_PTR(ptr) _ASSERTE(ptr != NULL && !IsBadWritePtr(ptr, sizeof(*ptr)));
  33. #define ASSERT_WRITE_PTR2(ptr, cb) _ASSERTE(ptr != NULL && !IsBadWritePtr(ptr, cb));
  34. #define ASSERT_READ_WRITE_PTR(ptr) ASSERT_READ_PTR(ptr); ASSERT_WRITE_PTR(ptr);
  35. #define ASSERT_READ_WRITE_PTR2(ptr, cb) ASSERT_READ_PTR2(ptr, cb); && ASSERT_WRITE_PTR2(ptr, cb);
  36. #define ASSERT_MSG(msg)\
  37. do { if (IISUIFireAssert(__FILE__, __TIMESTAMP__, __LINE__, msg)==1)\
  38. DebugBreak(); } while (0)
  39. int _EXPORT
  40. IISUIFireAssert(
  41. const char * filename,
  42. const char * timestamp,
  43. int linenum,
  44. const char * expr
  45. );
  46. #else
  47. //
  48. // Retail
  49. //
  50. #undef ATLASSERT
  51. #undef ASSERT
  52. #undef VERIFY
  53. #define ATLASSERT
  54. #define ASSERT
  55. #define VERIFY(exp) (exp)
  56. #define ASSERT_PTR(ptr)
  57. #define ASSERT_READ_PTR(ptr)
  58. #define ASSERT_READ_PTR2(ptr, cb)
  59. #define ASSERT_WRITE_PTR(ptr)
  60. #define ASSERT_WRITE_PTR2(ptr, cb)
  61. #define ASSERT_READ_WRITE_PTR(ptr)
  62. #define ASSERT_READ_WRITE_PTR2(ptr, cb)
  63. #define ASSERT_MSG(msg)
  64. #endif // _DEBUG || DBG
  65. #ifndef TRACE
  66. #define TRACE ATLTRACE
  67. #endif
  68. #ifndef TRACE0
  69. #ifdef _DEBUG
  70. #define TRACE0(fmt) TRACE(fmt)
  71. #define TRACE1(fmt, a1) TRACE(fmt, a1)
  72. #define TRACE2(fmt, a1, a2) TRACE(fmt, a1, a2)
  73. #define TRACE3(fmt, a1, a2, a3) TRACE(fmt, a1, a2, a3)
  74. #define TRACE4(fmt, a1, a2, a3, a4) TRACE(fmt, a1, a2, a3, a4)
  75. #else // _DEBUG
  76. #define TRACE0(fmt)
  77. #define TRACE1(fmt, a1)
  78. #define TRACE2(fmt, a1, a2)
  79. #define TRACE3(fmt, a1, a2, a3)
  80. #define TRACE4(fmt, a1, a2, a3, a4)
  81. #endif // _DEBUG
  82. #endif // TRACE0
  83. #if defined(_DEBUG) || DBG
  84. #define TRACEEOLID(msg)\
  85. do {TRACE("%s %d %s\n", __FILE__, __LINE__, msg); } while (FALSE)
  86. #define TRACEEOLERR(err,x) { if (err) TRACEEOLID(x) }
  87. #define TRACEEOL(msg)\
  88. do {TRACE("%s\n", msg);} while (FALSE)
  89. #else
  90. #define TRACEEOLID(msg)
  91. #define TRACEEOLERR(err,x)
  92. #define TRACEEOL(msg)
  93. #endif
  94. #define TRACE_RETURN(msg, err) TRACEEOLID(msg); return err;
  95. #define TRACE_NOTIMPL(msg) TRACE_RETURN(msg, E_NOTIMPL);
  96. #define TRACE_NOINTERFACE(msg) TRACE_RETURN(msg, E_NOINTERFACE);
  97. #define TRACE_UNEXPECTED(msg) TRACE_RETURN(msg, E_UNEXPECTED);
  98. #define TRACE_POINTER(msg) TRACE_RETURN(msg, E_POINTER);
  99. #endif // _DEBUGATL_H