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.

180 lines
6.1 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: cmdebug.h
  4. //
  5. // Module: CMDEBUG.LIB
  6. //
  7. // Synopsis: Header file for Internal CM Debugging functions.
  8. //
  9. // Copyright (c) 1997-1999 Microsoft Corporation
  10. //
  11. // Author: quintinb Created Header 08/19/99
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef CMDEBUG_H
  15. #define CMDEBUG_H
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. //
  20. // Macros for debugging support.
  21. //
  22. // MYDBGASSERT(x): If (!x) Assert MessageBox which has three option:
  23. // Abort to end the application,
  24. // Ignore to continue,
  25. // Retry to debug
  26. //
  27. // CMASSERTMSG(exp, msg) Similar to MYDBGASSERT. Except the msg is displayed instead of expression
  28. //
  29. // Use CMTRACE(x) for output, where x is a list of printf()-style parameters.
  30. // CMTRACEn() is TRACE with n printf arguments
  31. // For example, CMTRACE2(("This shows how to print stuff, like a string %s, and a number %u.","string",5));
  32. //
  33. // MYDBG is obsolete and equivalent to CMTRACE
  34. //
  35. // Use MYDBGTST(y,x) to output x if y is TRUE. For example,
  36. // MYDBGTST(1,("This always prints"));
  37. //
  38. // Use MYDBGSTR(x) for safe-printing of string pointers. For example,
  39. // MYDBG(("This would normally, fault - %s.",MYDBGSTR(NULL)));
  40. //
  41. // USE MYVERIFY for expressions executed for both debug and release version
  42. #ifdef DEBUG
  43. void MyDbgPrintfA(const char *pszFmt, ...);
  44. void MyDbgPrintfW(const WCHAR *pszFmt, ...);
  45. void MyDbgAssertA(const char *pszFile, unsigned nLine, const char *pszMsg);
  46. void MyDbgAssertW(const char *pszFile, unsigned nLine, WCHAR *pszMsg);
  47. void InvertPercentSAndPercentC(LPSTR pszFormat);
  48. int WINAPI wvsprintfWtoAWrapper(OUT LPSTR pszAnsiOut, IN LPCWSTR pszwFmt, IN va_list arglist);
  49. #define MYDBGASSERTA(x) (void)((x) || (MyDbgAssertA(__FILE__,__LINE__,#x),0))
  50. #define MYDBGASSERTW(x) (void)((x) || (MyDbgAssertW(__FILE__,__LINE__,L#x),0))
  51. #define MYVERIFYA(x) MYDBGASSERTA(x)
  52. #define MYVERIFYW(x) MYDBGASSERTW(x)
  53. #define MYDBGTSTA(y,x) if (y) MyDbgPrintfA x
  54. #define MYDBGTSTW(y,x) if (y) MyDbgPrintfW x
  55. // {MYDBGASSERT(pObj);pObj->AssertValid();}
  56. #define ASSERT_VALID(pObj) ((MYDBGASSERT(pObj),1) && ((pObj)->AssertValid(),1))
  57. #define MYDBGA(x) MyDbgPrintfA x
  58. #define MYDBGW(x) MyDbgPrintfW x
  59. #define MYDBGSTRA(x) ((x)?(x):"(null)")
  60. #define MYDBGSTRW(x) ((x)?(x):L"(null)")
  61. #define CMASSERTMSGA(exp, msg) (void)((exp) || (MyDbgAssertA(__FILE__,__LINE__,msg),0))
  62. #define CMASSERTMSGW(exp, msg) (void)((exp) || (MyDbgAssertW(__FILE__,__LINE__,msg),0))
  63. #define CMTRACEA(pszFmt) MyDbgPrintfA(pszFmt)
  64. #define CMTRACEW(pszFmt) MyDbgPrintfW(pszFmt)
  65. #define CMTRACEHRA(pszFile, hr) if (hr) MyDbgPrintfA("%s: returns error %x", pszFile, (hr));
  66. #define CMTRACEHRW(pszFile, hr) if (hr) MyDbgPrintfW(L"%s: returns error %x", pszFile, (hr));
  67. #define CMTRACE1A(pszFmt, arg1) MyDbgPrintfA(pszFmt, arg1)
  68. #define CMTRACE1W(pszFmt, arg1) MyDbgPrintfW(pszFmt, arg1)
  69. #define CMTRACE2A(pszFmt, arg1, arg2) MyDbgPrintfA(pszFmt, arg1, arg2)
  70. #define CMTRACE2W(pszFmt, arg1, arg2) MyDbgPrintfW(pszFmt, arg1, arg2)
  71. #define CMTRACE3A(pszFmt, arg1, arg2, arg3) MyDbgPrintfA(pszFmt, arg1, arg2, arg3)
  72. #define CMTRACE3W(pszFmt, arg1, arg2, arg3) MyDbgPrintfW(pszFmt, arg1, arg2, arg3)
  73. #ifdef UNICODE
  74. #define MyDbgPrintf MyDbgPrintfW
  75. #define MyDbgAssert MyDbgAssertW
  76. #define MYDBGTST(y,x) MYDBGTSTW(y,x)
  77. #define MYDBG(x) MYDBGW(x)
  78. #define MYDBGSTR(x) MYDBGSTRW(x)
  79. #define CMASSERTMSG(exp, msg) CMASSERTMSGW(exp, msg)
  80. #define CMTRACE(pszFmt) CMTRACEW(pszFmt)
  81. #define CMTRACEHR(pszFile, hr) CMTRACEHRW(pszFile, hr)
  82. #define CMTRACE1(pszFmt, arg1) CMTRACE1W(pszFmt, arg1)
  83. #define CMTRACE2(pszFmt, arg1, arg2) CMTRACE2W(pszFmt, arg1, arg2)
  84. #define CMTRACE3(pszFmt, arg1, arg2, arg3) CMTRACE3W(pszFmt, arg1, arg2, arg3)
  85. #define MYDBGASSERT MYDBGASSERTW
  86. #define MYVERIFY MYVERIFYW
  87. #else
  88. #define MyDbgPrintf MyDbgPrintfA
  89. #define MyDbgAssert MyDbgAssertA
  90. #define MYDBGTST(y,x) MYDBGTSTA(y,x)
  91. #define MYDBG(x) MYDBGA(x)
  92. #define MYDBGSTR(x) MYDBGSTRA(x)
  93. #define CMASSERTMSG(exp, msg) CMASSERTMSGA(exp, msg)
  94. #define CMTRACE(pszFmt) CMTRACEA(pszFmt)
  95. #define CMTRACEHR(pszFile, hr) CMTRACEHRA(pszFile, hr)
  96. #define CMTRACE1(pszFmt, arg1) CMTRACE1A(pszFmt, arg1)
  97. #define CMTRACE2(pszFmt, arg1, arg2) CMTRACE2A(pszFmt, arg1, arg2)
  98. #define CMTRACE3(pszFmt, arg1, arg2, arg3) CMTRACE3A(pszFmt, arg1, arg2, arg3)
  99. #define MYDBGASSERT MYDBGASSERTA
  100. #define MYVERIFY MYVERIFYA
  101. #endif
  102. #else // DEBUG
  103. #define ASSERT_VALID(pObj)
  104. #define MYDBG(x)
  105. #define MYDBGTST(y,x)
  106. #define MYDBGSTR(x)
  107. #define MYDBGASSERT(x)
  108. #define CMASSERTMSG(exp, msg)
  109. #define MYVERIFY(x) (x)
  110. #define CMTRACE(pszFmt)
  111. #define CMTRACEHR(pszFile, hr)
  112. #define CMTRACE1(pszFmt, arg1)
  113. #define CMTRACE2(pszFmt, arg1, arg2)
  114. #define CMTRACE3(pszFmt, arg1, arg2, arg3)
  115. #define MYDBGASSERTA(x)
  116. #define MYDBGASSERTW(x)
  117. #define MYVERIFYA(x)
  118. #define MYVERIFYW(x)
  119. #define MYDBGTSTA(y,x)
  120. #define MYDBGTSTW(y,x)
  121. #define ASSERT_VALID(pObj)
  122. #define MYDBGA(x)
  123. #define MYDBGW(x)
  124. #define MYDBGSTRA(x)
  125. #define MYDBGSTRW(x)
  126. #define CMASSERTMSGA(exp, msg)
  127. #define CMASSERTMSGW(exp, msg)
  128. #define CMTRACEA(pszFmt)
  129. #define CMTRACEW(pszFmt)
  130. #define CMTRACEHRA(pszFile, hr)
  131. #define CMTRACEHRW(pszFile, hr)
  132. #define CMTRACE1A(pszFmt, arg1)
  133. #define CMTRACE1W(pszFmt, arg1)
  134. #define CMTRACE2A(pszFmt, arg1, arg2)
  135. #define CMTRACE2W(pszFmt, arg1, arg2)
  136. #define CMTRACE3A(pszFmt, arg1, arg2, arg3)
  137. #define CMTRACE3W(pszFmt, arg1, arg2, arg3)
  138. #endif // DEBUG
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142. #endif