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.

170 lines
4.3 KiB

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved.
  7. //
  8. // FILE: Debug.H
  9. //
  10. //
  11. // PURPOSE: Define common data types, and external function prototypes
  12. // for debugging functions.
  13. //
  14. // PLATFORMS:
  15. //
  16. // Windows 2000, Windows XP, Windows Server 2003
  17. //
  18. //
  19. #ifndef _DEBUG_H
  20. #define _DEBUG_H
  21. // VC and Build use different debug defines.
  22. // The following makes it so either will
  23. // cause the inclusion of debugging code.
  24. #if !defined(_DEBUG) && defined(DBG)
  25. #define _DEBUG DBG
  26. #elif defined(_DEBUG) && !defined(DBG)
  27. #define DBG _DEBUG
  28. #endif
  29. /////////////////////////////////////////////////////////
  30. // Macros
  31. /////////////////////////////////////////////////////////
  32. //
  33. // These macros are used for debugging purposes. They expand
  34. // to white spaces on a free build. Here is a brief description
  35. // of what they do and how they are used:
  36. //
  37. // giDebugLevel
  38. // Global variable which set the current debug level to control
  39. // the amount of debug messages emitted.
  40. //
  41. // VERBOSE(msg)
  42. // Display a message if the current debug level is <= DBG_VERBOSE.
  43. //
  44. // TERSE(msg)
  45. // Display a message if the current debug level is <= DBG_TERSE.
  46. //
  47. // WARNING(msg)
  48. // Display a message if the current debug level is <= DBG_WARNING.
  49. // The message format is: WRN filename (linenumber): message
  50. //
  51. // ERR(msg)
  52. // Similiar to WARNING macro above - displays a message
  53. // if the current debug level is <= DBG_ERROR.
  54. //
  55. // ASSERT(cond)
  56. // Verify a condition is true. If not, force a breakpoint.
  57. //
  58. // ASSERTMSG(cond, msg)
  59. // Verify a condition is true. If not, display a message and
  60. // force a breakpoint.
  61. //
  62. // RIP(msg)
  63. // Display a message and force a breakpoint.
  64. //
  65. // Usage:
  66. // These macros require extra parantheses for the msg argument
  67. // example, ASSERTMSG(x > 0, ("x is less than 0\n"));
  68. // WARNING(("App passed NULL pointer, ignoring...\n"));
  69. //
  70. #define DBG_VERBOSE 1
  71. #define DBG_TERSE 2
  72. #define DBG_WARNING 3
  73. #define DBG_ERROR 4
  74. #define DBG_RIP 5
  75. #define DBG_NONE 6
  76. #if DBG
  77. #define DebugMsg DebugMessage
  78. //
  79. // Strip the directory prefix from a filename (ANSI version)
  80. //
  81. PCSTR
  82. StripDirPrefixA(
  83. IN PCSTR pstrFilename
  84. );
  85. extern INT giDebugLevel;
  86. #define DBGMSG(level, prefix, msg) { \
  87. if (giDebugLevel <= (level)) { \
  88. DebugMsg("%s %s (%d): ", prefix, StripDirPrefixA(__FILE__), __LINE__); \
  89. DebugMsg(msg); \
  90. } \
  91. }
  92. #define DBGPRINT(level, msg) { \
  93. if (giDebugLevel <= (level)) { \
  94. DebugMsg(msg); \
  95. } \
  96. }
  97. #define VERBOSE if(giDebugLevel <= DBG_VERBOSE) DebugMsg
  98. #define TERSE if(giDebugLevel <= DBG_TERSE) DebugMsg
  99. #define WARNING if(giDebugLevel <= DBG_WARNING) DebugMsg
  100. #define ERR if(giDebugLevel <= DBG_ERROR) DebugMsg
  101. #define ASSERT(cond) { \
  102. if (! (cond)) { \
  103. RIP(("\n")); \
  104. } \
  105. }
  106. #define ASSERTMSG(cond, msg) { \
  107. if (! (cond)) { \
  108. RIP(msg); \
  109. } \
  110. }
  111. #define RIP(msg) { \
  112. DBGMSG(DBG_RIP, "RIP", msg); \
  113. DebugBreak(); \
  114. }
  115. #else // !DBG
  116. #define DebugMsg NOP_FUNCTION
  117. #define VERBOSE NOP_FUNCTION
  118. #define TERSE NOP_FUNCTION
  119. #define WARNING NOP_FUNCTION
  120. #define ERR NOP_FUNCTION
  121. #define ASSERT(cond)
  122. #define ASSERTMSG(cond, msg)
  123. #define RIP(msg)
  124. #define DBGMSG(level, prefix, msg)
  125. #define DBGPRINT(level, msg)
  126. #endif
  127. /////////////////////////////////////////////////////////
  128. // ProtoTypes
  129. /////////////////////////////////////////////////////////
  130. BOOL DebugMessage(LPCSTR, ...);
  131. BOOL DebugMessage(LPCWSTR, ...);
  132. void Dump(PPUBLISHERINFO pPublisherInfo);
  133. void Dump(POEMDMPARAM pOemDMParam);
  134. #endif