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.

196 lines
4.8 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. #ifdef UNICODE
  87. #define TSTR "%ws"
  88. #else
  89. #define TSTR "%s"
  90. #endif
  91. #define DBGSTR(str) \
  92. ((str) ? (str) : TEXT("(NULL)"))
  93. #define DBGMSG(Level, MsgAndArgs) \
  94. do \
  95. { \
  96. if( ( (Level) & 0xFFFF ) & MODULE_DEBUG ){ \
  97. _DbgMsg MsgAndArgs; \
  98. } \
  99. if( ( (Level) << 16 ) & MODULE_DEBUG ) \
  100. _DbgBreak(); \
  101. } \
  102. while (FALSE) \
  103. #define SPLASSERT(expr) \
  104. do \
  105. { \
  106. if (!(expr)) \
  107. { \
  108. _DbgMsg("Failed: %s\nLine %d, %s\n", #expr, __LINE__, __FILE__); \
  109. _DbgBreak(); \
  110. } \
  111. } \
  112. while (FALSE) \
  113. #define SINGLETHREAD_VAR(var) \
  114. DWORD dwSingleThread_##var;
  115. #define SINGLETHREAD(var) \
  116. _DbgSingleThread(&dwSingleThread_##var);
  117. #define SINGLETHREADNOT(var) \
  118. _DbgSingleThreadNot(&dwSingleThread_##var);
  119. #define SINGLETHREADRESET(var) \
  120. _DbgSingleThreadReset(&dwSingleThread_##var);
  121. #define VALID_PTR(x) \
  122. ((( x ) && (( x )->bValid( ))) ? \
  123. TRUE : \
  124. ( _DbgWarnInvalid( (PVOID)(x), MODULE_DEBUG, __LINE__, __FILE__, MODULE ), FALSE ))
  125. #define VALID_OBJ(x) \
  126. ((( x ).bValid( )) ? \
  127. TRUE : \
  128. ( _DbgWarnInvalid( (PVOID)&(x), MODULE_DEBUG, __LINE__, __FILE__, MODULE ), FALSE ))
  129. #define VALID_BASE(x) \
  130. (( x::bValid( )) ? \
  131. TRUE : \
  132. ( _DbgWarnInvalid( (PVOID)this, MODULE_DEBUG, __LINE__, __FILE__, MODULE ), FALSE ))
  133. #else // DBG not defined - expand all debug code appropriately (i.e. to nothing)
  134. #define MODULE_DEBUG_INIT(printMask, breakMask)
  135. #define DBGMSG(Level, MsgAndArgs)
  136. #define SPLASSERT(exp)
  137. #define SINGLETHREAD_VAR(var)
  138. #define SINGLETHREAD(var)
  139. #define SINGLETHREADNOT(var)
  140. #define SINGLETHREADRESET(var)
  141. #define VALID_PTR(x) \
  142. (( x ) && (( x )->bValid()))
  143. #define VALID_OBJ(x) \
  144. (( x ).bValid())
  145. #define VALID_BASE(x) \
  146. ( x::bValid( ))
  147. #endif // DBG
  148. // close C code brace
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152. #endif // _DEBUG_H