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.

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