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.

192 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. debug.h
  6. Abstract:
  7. PrintUI core debugging macros/tools.
  8. Author:
  9. Lazar Ivanov (LazarI) Jul-05-2000
  10. Revision History:
  11. --*/
  12. #ifndef _DEBUG_H
  13. #define _DEBUG_H
  14. // open C code brace
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. ///////////////////////
  19. // core debug macros &
  20. // functions
  21. //
  22. #define DBG_NONE 0x0000
  23. #define DBG_INFO 0x0001
  24. #define DBG_WARN 0x0002
  25. #define DBG_WARNING 0x0002
  26. #define DBG_ERROR 0x0004
  27. #define DBG_TRACE 0x0008
  28. #define DBG_SECURITY 0x0010
  29. #define DBG_EXEC 0x0020
  30. #define DBG_PORT 0x0040
  31. #define DBG_NOTIFY 0x0080
  32. #define DBG_PAUSE 0x0100
  33. #define DBG_THREADM 0x0400
  34. #define DBG_MIN 0x0800
  35. #define DBG_TIME 0x1000
  36. #define DBG_FOLDER 0x2000
  37. #define DBG_NOHEAD 0x8000
  38. #if DBG
  39. VOID
  40. _DbgSingleThreadReset(
  41. const DWORD *pdwThreadId
  42. );
  43. VOID
  44. _DbgSingleThread(
  45. const DWORD *pdwThreadId
  46. );
  47. VOID
  48. _DbgSingleThreadNot(
  49. const DWORD *pdwThreadId
  50. );
  51. VOID
  52. _DbgMsg(
  53. LPCSTR pszMsgFormat,
  54. ...
  55. );
  56. VOID
  57. _DbgWarnInvalid(
  58. PVOID pvObject,
  59. UINT uDbg,
  60. UINT uLine,
  61. LPCSTR pszFileA,
  62. LPCSTR pszModuleA
  63. );
  64. HRESULT
  65. _DbgInit(
  66. VOID
  67. );
  68. HRESULT
  69. _DbgDone(
  70. VOID
  71. );
  72. VOID
  73. _DbgBreak(
  74. VOID
  75. );
  76. #define DBG_PRINT_MASK 0xffff
  77. #define DBG_BREAK_SHIFT 16
  78. #define DBG_PRINT(x) (x)
  79. #define DBG_BREAK(x) (((x) << DBG_BREAK_SHIFT)|(x))
  80. #ifndef MODULE
  81. #define MODULE "PRINTUI:"
  82. #endif
  83. extern DWORD MODULE_DEBUG;
  84. #define MODULE_DEBUG_INIT(printMask, breakMask) \
  85. (DBG_PRINT(printMask) | DBG_BREAK(breakMask))
  86. #define TSTR "%ws"
  87. #define DBGSTR(str) \
  88. ((str) ? (str) : TEXT("(NULL)"))
  89. #define DBGMSG(Level, MsgAndArgs) \
  90. do \
  91. { \
  92. if( ( (Level) & 0xFFFF ) & MODULE_DEBUG ){ \
  93. _DbgMsg MsgAndArgs; \
  94. } \
  95. if( ( (Level) << 16 ) & MODULE_DEBUG ) \
  96. _DbgBreak(); \
  97. } \
  98. while (FALSE) \
  99. #define SPLASSERT(expr) \
  100. do \
  101. { \
  102. if (!(expr)) \
  103. { \
  104. _DbgMsg("Failed: %s\nLine %d, %s\n", #expr, __LINE__, __FILE__); \
  105. _DbgBreak(); \
  106. } \
  107. } \
  108. while (FALSE) \
  109. #define SINGLETHREAD_VAR(var) \
  110. DWORD dwSingleThread_##var;
  111. #define SINGLETHREAD(var) \
  112. _DbgSingleThread(&dwSingleThread_##var);
  113. #define SINGLETHREADNOT(var) \
  114. _DbgSingleThreadNot(&dwSingleThread_##var);
  115. #define SINGLETHREADRESET(var) \
  116. _DbgSingleThreadReset(&dwSingleThread_##var);
  117. #define VALID_PTR(x) \
  118. ((( x ) && (( x )->bValid( ))) ? \
  119. TRUE : \
  120. ( _DbgWarnInvalid( (PVOID)(x), MODULE_DEBUG, __LINE__, __FILE__, MODULE ), FALSE ))
  121. #define VALID_OBJ(x) \
  122. ((( x ).bValid( )) ? \
  123. TRUE : \
  124. ( _DbgWarnInvalid( (PVOID)&(x), MODULE_DEBUG, __LINE__, __FILE__, MODULE ), FALSE ))
  125. #define VALID_BASE(x) \
  126. (( x::bValid( )) ? \
  127. TRUE : \
  128. ( _DbgWarnInvalid( (PVOID)this, MODULE_DEBUG, __LINE__, __FILE__, MODULE ), FALSE ))
  129. #else // DBG not defined - expand all debug code appropriately (i.e. to nothing)
  130. #define MODULE_DEBUG_INIT(printMask, breakMask)
  131. #define DBGMSG(Level, MsgAndArgs)
  132. #define SPLASSERT(exp)
  133. #define SINGLETHREAD_VAR(var)
  134. #define SINGLETHREAD(var)
  135. #define SINGLETHREADNOT(var)
  136. #define SINGLETHREADRESET(var)
  137. #define VALID_PTR(x) \
  138. (( x ) && (( x )->bValid()))
  139. #define VALID_OBJ(x) \
  140. (( x ).bValid())
  141. #define VALID_BASE(x) \
  142. ( x::bValid( ))
  143. #endif // DBG
  144. // close C code brace
  145. #ifdef __cplusplus
  146. }
  147. #endif
  148. #endif // _DEBUG_H