Leaked source code of windows server 2003
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.

102 lines
2.7 KiB

  1. #ifndef DEBUG_H
  2. #define DEBUG_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <windows.h>
  7. //
  8. // Macros for debugging support.
  9. //
  10. // ASSERT(exp) Popup a dialogbox, if exp is FALSE
  11. // ASSERTMSG(exp, msg) Similar to ASSERT. Except the msg is displayed instead of the expression
  12. //
  13. // Use TRACE(x) for output, where x is a list of printf()-style parameters.
  14. // TRACEn() is TRACE with n printf arguments
  15. // For example, TRACE2("This shows how to print stuff, like a string %s, and a number %u.","string",5);
  16. //
  17. // USE VERIFY for expressions executed for both debug and release version
  18. //
  19. #undef ASSERT
  20. #undef ASSERTMSG
  21. //
  22. // Used by atl
  23. //
  24. #ifdef _ATL_NO_DEBUG_CRT
  25. #define _ASSERTE ASSERT
  26. #define _ASSERT ASSERT
  27. #endif
  28. //
  29. // Trace out the function name
  30. //
  31. #ifdef ENABLE_PROFILE
  32. #define PROFILE(pszFunctionName) TRACE(pszFunctionName)
  33. #else
  34. #define PROFILE(pszFunctionName) ((void)0)
  35. #endif
  36. //
  37. // Define TRACE here. To disable TRACE in retail version, define NO_RETAIL_TRACE
  38. //
  39. #if ( defined(DEBUG) || defined(_DEBUG) || !defined(NO_RETAIL_TRACE))
  40. #include "satrace.h"
  41. #define TRACE(pszFmt) SATraceString(pszFmt)
  42. #define TRACE1(pszFmt, arg1) SATracePrintf(pszFmt, arg1)
  43. #define TRACE2(pszFmt, arg1, arg2) SATracePrintf(pszFmt, arg1, arg2)
  44. #define TRACE3(pszFmt, arg1, arg2, arg3) SATracePrintf(pszFmt, arg1, arg2, arg3)
  45. #else
  46. #define TRACE(pszFmt) ((void)0)
  47. #define TRACE1(pszFmt, arg1) ((void)0)
  48. #define TRACE2(pszFmt, arg1, arg2) ((void)0)
  49. #define TRACE3(pszFmt, arg1, arg2, arg3) ((void)0)
  50. #endif
  51. /*
  52. #define TRACE(pszFmt) TraceMessageA(pszFmt)
  53. #define TRACE1(pszFmt, arg1) TraceMessageA(pszFmt, arg1)
  54. #define TRACE2(pszFmt, arg1, arg2) TraceMessageA(pszFmt, arg1, arg2)
  55. #define TRACE3(pszFmt, arg1, arg2, arg3) TraceMessageA(pszFmt, arg1, arg2, arg3)
  56. */
  57. #if ( defined(DEBUG) || defined(_DEBUG))
  58. #ifdef UNICODE
  59. #define AssertMessage AssertMessageW
  60. #else
  61. #define AssertMessage AssertMessageA
  62. #endif
  63. void AssertMessage(const TCHAR *pszFile, unsigned nLine, const TCHAR *pszMsg);
  64. #define ASSERT(x) (void)((x) || (AssertMessage(TEXT(__FILE__),__LINE__,TEXT(#x)),0))
  65. #define ASSERTMSG(exp, msg) (void)((exp) || (AssertMessage(TEXT(__FILE__),__LINE__,msg),0))
  66. #define VERIFY(x) ASSERT(x)
  67. // {ASSERT(pObj);pObj->AssertValid();}
  68. #define ASSERT_VALID(pObj) ((ASSERT(pObj),1) && ((pObj)->AssertValid(),1))
  69. #else // DEBUG
  70. #define ASSERT_VALID(pObj)
  71. #define ASSERT(x) ((void)0)
  72. #define ASSERTMSG(exp, msg) ((void)0)
  73. #define VERIFY(x) (x)
  74. #endif
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif