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.

159 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1994-1999 Microsoft Corporation
  3. Module Name :
  4. debugafx.h
  5. Abstract:
  6. Debugging routines using AFX/MFC extensions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _DEBUGAFX_H
  14. #define _DEBUGAFX_H
  15. #if defined(_DEBUG) || DBG
  16. //
  17. // Defined private ASSERT macros because they're not available
  18. // in SDK builds (which always uses retail MFC)
  19. //
  20. #undef ATLASSERT
  21. #undef ASSERT
  22. #undef _ASSERTE
  23. #undef VERIFY
  24. #define _ASSERTE(expr)\
  25. do { if (!(expr) &&\
  26. (IISUIFireAssert(__FILE__, __TIMESTAMP__, __LINE__, #expr)==1))\
  27. DebugBreak(); } while (0)
  28. #define ASSERT(expr) _ASSERTE(expr)
  29. #define VERIFY(expr) _ASSERTE(expr)
  30. #define ATLASSERT(expr) _ASSERTE(expr)
  31. #define ASSERT_PTR(ptr) _ASSERTE(ptr != NULL);
  32. #define ASSERT_READ_PTR(ptr) _ASSERTE(ptr != NULL && !IsBadReadPtr(ptr, sizeof(*ptr)));
  33. #define ASSERT_READ_PTR2(ptr, cb) _ASSERTE(ptr != NULL && !IsBadReadPtr(ptr, cb));
  34. #define ASSERT_WRITE_PTR(ptr) _ASSERTE(ptr != NULL && !IsBadWritePtr(ptr, sizeof(*ptr)));
  35. #define ASSERT_WRITE_PTR2(ptr, cb) _ASSERTE(ptr != NULL && !IsBadWritePtr(ptr, cb));
  36. #define ASSERT_READ_WRITE_PTR(ptr) ASSERT_READ_PTR(ptr); ASSERT_WRITE_PTR(ptr);
  37. #define ASSERT_READ_WRITE_PTR2(ptr, cb) ASSERT_READ_PTR2(ptr, cb); && ASSERT_WRITE_PTR2(ptr, cb);
  38. #define ASSERT_MSG(msg)\
  39. do { if (IISUIFireAssert(__FILE__, __TIMESTAMP__, __LINE__, msg)==1)\
  40. DebugBreak(); } while (0)
  41. int COMDLL IISUIFireAssert(
  42. const char * filename,
  43. const char * timestamp,
  44. int linenum,
  45. const char * expr
  46. );
  47. #else
  48. //
  49. // Retail
  50. //
  51. #define ASSERT_PTR(ptr)
  52. #define ASSERT_READ_PTR(ptr)
  53. #define ASSERT_READ_PTR2(ptr, cb)
  54. #define ASSERT_WRITE_PTR(ptr)
  55. #define ASSERT_WRITE_PTR2(ptr, cb)
  56. #define ASSERT_READ_WRITE_PTR(ptr)
  57. #define ASSERT_READ_WRITE_PTR2(ptr, cb)
  58. #define ASSERT_MSG(msg)
  59. #endif // _DEBUG || DBG
  60. #if defined(_DEBUG) || DBG
  61. #ifndef _DEBUG
  62. //
  63. // SDK Build environment
  64. //
  65. extern COMDLL CDumpContext afxDump;
  66. extern COMDLL BOOL afxTraceEnabled;
  67. #endif // _DEBUG
  68. //
  69. // ENUM for special debug output control tokens
  70. //
  71. enum ENUM_DEBUG_AFX
  72. {
  73. EDBUG_AFX_EOL = -1
  74. };
  75. #define TRACEFMTPGM DbgFmtPgm(THIS_FILE, __LINE__)
  76. #define TRACEOUT(x) { afxDump << x; }
  77. #define TRACEEOL(x) { afxDump << x << EDBUG_AFX_EOL; }
  78. #define TRACEEOLID(x) { afxDump << TRACEFMTPGM << x << EDBUG_AFX_EOL; }
  79. #define TRACEEOLERR(err,x) { if (err) TRACEEOLID(x) }
  80. //
  81. // Append an EOL onto the debug output stream
  82. //
  83. COMDLL CDumpContext & operator <<(
  84. IN CDumpContext & out,
  85. IN ENUM_DEBUG_AFX edAfx
  86. );
  87. #ifndef UNICODE
  88. COMDLL CDumpContext & operator <<(
  89. IN CDumpContext & out,
  90. IN LPCWSTR pwchStr
  91. );
  92. #endif UNICODE
  93. //
  94. // Format a program name and line number for output (removes the path info)
  95. //
  96. COMDLL extern LPCSTR DbgFmtPgm(
  97. IN LPCSTR szFn,
  98. IN int line
  99. );
  100. COMDLL CDumpContext & operator <<(
  101. IN CDumpContext & out,
  102. IN const GUID & guid
  103. );
  104. #else // !_DEBUG
  105. //
  106. // Retail definitions
  107. //
  108. #define TRACEOUT(x) ;
  109. #define TRACEEOL(x) ;
  110. #define TRACEEOLID(x) ;
  111. #define TRACEEOLERR(err, x) ;
  112. #endif // _DEBUG
  113. #define TRACE_RETURN(msg, err) TRACEEOLID(msg); return err;
  114. #define TRACE_NOTIMPL(msg) TRACE_RETURN(msg, E_NOTIMPL);
  115. #define TRACE_NOINTERFACE(msg) TRACE_RETURN(msg, E_NOINTERFACE);
  116. #define TRACE_UNEXPECTED(msg) TRACE_RETURN(msg, E_UNEXPECTED);
  117. #define TRACE_POINTER(msg) TRACE_RETURN(msg, E_POINTER);
  118. #endif // _DEBUGAFX_H