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.

172 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. #include "kmode.h"
  22. // VC and Build use different debug defines.
  23. // The following makes it so either will
  24. // cause the inclusion of debugging code.
  25. #if !defined(_DEBUG) && defined(DBG)
  26. #define _DEBUG DBG
  27. #elif defined(_DEBUG) && !defined(DBG)
  28. #define DBG _DEBUG
  29. #endif
  30. /////////////////////////////////////////////////////////
  31. // Macros
  32. /////////////////////////////////////////////////////////
  33. //
  34. // These macros are used for debugging purposes. They expand
  35. // to white spaces on a free build. Here is a brief description
  36. // of what they do and how they are used:
  37. //
  38. // giDebugLevel
  39. // Global variable which set the current debug level to control
  40. // the amount of debug messages emitted.
  41. //
  42. // VERBOSE(msg)
  43. // Display a message if the current debug level is <= DBG_VERBOSE.
  44. //
  45. // TERSE(msg)
  46. // Display a message if the current debug level is <= DBG_TERSE.
  47. //
  48. // WARNING(msg)
  49. // Display a message if the current debug level is <= DBG_WARNING.
  50. // The message format is: WRN filename (linenumber): message
  51. //
  52. // ERR(msg)
  53. // Similiar to WARNING macro above - displays a message
  54. // if the current debug level is <= DBG_ERROR.
  55. //
  56. // ASSERT(cond)
  57. // Verify a condition is true. If not, force a breakpoint.
  58. //
  59. // ASSERTMSG(cond, msg)
  60. // Verify a condition is true. If not, display a message and
  61. // force a breakpoint.
  62. //
  63. // RIP(msg)
  64. // Display a message and force a breakpoint.
  65. //
  66. // Usage:
  67. // These macros require extra parantheses for the msg argument
  68. // example, ASSERTMSG(x > 0, ("x is less than 0\n"));
  69. // WARNING(("App passed NULL pointer, ignoring...\n"));
  70. //
  71. #define DBG_VERBOSE 1
  72. #define DBG_TERSE 2
  73. #define DBG_WARNING 3
  74. #define DBG_ERROR 4
  75. #define DBG_RIP 5
  76. #define DBG_NONE 6
  77. #if DBG
  78. #define DebugMsg DebugMessage
  79. //
  80. // Strip the directory prefix from a filename (ANSI version)
  81. //
  82. PCSTR
  83. StripDirPrefixA(
  84. IN PCSTR pstrFilename
  85. );
  86. extern INT giDebugLevel;
  87. #define DBGMSG(level, prefix, msg) { \
  88. if (giDebugLevel <= (level)) { \
  89. DebugMsg("%s %s (%d): ", prefix, StripDirPrefixA(__FILE__), __LINE__); \
  90. DebugMsg(msg); \
  91. } \
  92. }
  93. #define DBGPRINT(level, msg) { \
  94. if (giDebugLevel <= (level)) { \
  95. DebugMsg(msg); \
  96. } \
  97. }
  98. #define VERBOSE if(giDebugLevel <= DBG_VERBOSE) DebugMsg
  99. #define TERSE if(giDebugLevel <= DBG_TERSE) DebugMsg
  100. #define WARNING if(giDebugLevel <= DBG_WARNING) DebugMsg
  101. #define ERR if(giDebugLevel <= DBG_ERROR) DebugMsg
  102. #define ASSERT(cond) { \
  103. if (! (cond)) { \
  104. RIP(("\n")); \
  105. } \
  106. }
  107. #define ASSERTMSG(cond, msg) { \
  108. if (! (cond)) { \
  109. RIP(msg); \
  110. } \
  111. }
  112. #define RIP(msg) { \
  113. DBGMSG(DBG_RIP, "RIP", msg); \
  114. DebugBreak(); \
  115. }
  116. #else // !DBG
  117. #define DebugMsg NOP_FUNCTION
  118. #define VERBOSE NOP_FUNCTION
  119. #define TERSE NOP_FUNCTION
  120. #define WARNING NOP_FUNCTION
  121. #define ERR NOP_FUNCTION
  122. #define ASSERT(cond)
  123. #define ASSERTMSG(cond, msg)
  124. #define RIP(msg)
  125. #define DBGMSG(level, prefix, msg)
  126. #define DBGPRINT(level, msg)
  127. #endif
  128. /////////////////////////////////////////////////////////
  129. // ProtoTypes
  130. /////////////////////////////////////////////////////////
  131. BOOL DebugMessage(LPCSTR, ...);
  132. BOOL DebugMessage(LPCWSTR, ...);
  133. void Dump(PPUBLISHERINFO pPublisherInfo);
  134. void Dump(POEMDMPARAM pOemDMParam);
  135. #endif