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.

311 lines
11 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. scdebug.h
  5. Abstract:
  6. Contains debug macros used by the Service Controller.
  7. Author:
  8. Dan Lafferty (danl) 22-Apr-1991
  9. Environment:
  10. User Mode -Win32
  11. Revision History:
  12. 10-Apr-1992 JohnRo
  13. Added SC_ASSERT() and SCC_ASSERT() macros.
  14. 16-Apr-1992 JohnRo
  15. Added debug flags for config APIs and database lock APIs.
  16. Include <debugfmt.h> to get FORMAT_ equates.
  17. Made changes suggested by PC-LINT.
  18. 21-Apr-1992 JohnRo
  19. Added SC_LOG0(), etc.
  20. 12-Nov-1995 AnirudhS
  21. Make SC_LOG macros use one DbgPrint instead of two.
  22. 15-May-1996 AnirudhS
  23. Have SC_LOG macros print the thread id.
  24. --*/
  25. #ifndef SCDEBUG_H
  26. #define SCDEBUG_H
  27. #include <debugfmt.h> // FORMAT_ equates.
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. //
  32. // Debug macros and constants.
  33. //
  34. #if !DBG || defined(lint) || defined(_lint)
  35. #define DEBUG_STATE 0
  36. #define STATIC static
  37. #else // just DBG
  38. #define DEBUG_STATE 1
  39. #define STATIC
  40. #endif // just DBG
  41. //
  42. // The following macros allow debug print syntax to look like:
  43. //
  44. // SC_LOG1(TRACE, "An error occured: " FORMAT_DWORD "\n",status)
  45. //
  46. #if DBG
  47. //
  48. // Server-side debugging macros.
  49. //
  50. #define SC_LOG0(level, string) \
  51. KdPrintEx((DPFLTR_SCSERVER_ID, \
  52. DEBUG_##level, \
  53. "[SC] %lx: " string, \
  54. GetCurrentThreadId()))
  55. #define SC_LOG1(level, string, var) \
  56. KdPrintEx((DPFLTR_SCSERVER_ID, \
  57. DEBUG_##level, \
  58. "[SC] %lx: " string, \
  59. GetCurrentThreadId(), \
  60. var))
  61. #define SC_LOG2(level, string, var1, var2) \
  62. KdPrintEx((DPFLTR_SCSERVER_ID, \
  63. DEBUG_##level, \
  64. "[SC] %lx: " string, \
  65. GetCurrentThreadId(), \
  66. var1, \
  67. var2))
  68. #define SC_LOG3(level, string, var1, var2, var3) \
  69. KdPrintEx((DPFLTR_SCSERVER_ID, \
  70. DEBUG_##level, \
  71. "[SC] %lx: " string, \
  72. GetCurrentThreadId(), \
  73. var1, \
  74. var2, \
  75. var3))
  76. #define SC_LOG4(level, string, var1, var2, var3, var4) \
  77. KdPrintEx((DPFLTR_SCSERVER_ID, \
  78. DEBUG_##level, \
  79. "[SC] %lx: " string, \
  80. GetCurrentThreadId(), \
  81. var1, \
  82. var2, \
  83. var3, \
  84. var4))
  85. #define SC_LOG(level, string, var) \
  86. KdPrintEx((DPFLTR_SCSERVER_ID, \
  87. DEBUG_##level, \
  88. "[SC] %lx: " string, \
  89. GetCurrentThreadId(), \
  90. var))
  91. #define SC_ASSERT(boolExpr) ASSERT(boolExpr)
  92. #define SVCHOST_LOG0(level, string) \
  93. KdPrintEx((DPFLTR_SVCHOST_ID, \
  94. DEBUG_##level, \
  95. "[SVCHOST] %lx.%lx: " string, \
  96. GetCurrentProcessId(), \
  97. GetCurrentThreadId()))
  98. #define SVCHOST_LOG1(level, string, var) \
  99. KdPrintEx((DPFLTR_SVCHOST_ID, \
  100. DEBUG_##level, \
  101. "[SVCHOST] %lx.%lx: " string, \
  102. GetCurrentProcessId(), \
  103. GetCurrentThreadId(), \
  104. var))
  105. #define SVCHOST_LOG2(level, string, var1, var2) \
  106. KdPrintEx((DPFLTR_SVCHOST_ID, \
  107. DEBUG_##level, \
  108. "[SVCHOST] %lx.%lx: " string, \
  109. GetCurrentProcessId(), \
  110. GetCurrentThreadId(), \
  111. var1, \
  112. var2))
  113. #define SVCHOST_LOG3(level, string, var1, var2, var3) \
  114. KdPrintEx((DPFLTR_SVCHOST_ID, \
  115. DEBUG_##level, \
  116. "[SVCHOST] %lx.%lx: " string, \
  117. GetCurrentProcessId(), \
  118. GetCurrentThreadId(), \
  119. var1, \
  120. var2, \
  121. var3))
  122. #define SVCHOST_LOG4(level, string, var1, var2, var3, var4) \
  123. KdPrintEx((DPFLTR_SVCHOST_ID, \
  124. DEBUG_##level, \
  125. "[SVCHOST] %lx.%lx: " string, \
  126. GetCurrentProcessId(), \
  127. GetCurrentThreadId(), \
  128. var1, \
  129. var2, \
  130. var3, \
  131. var4))
  132. #define SVCHOST_LOG(level, string, var) \
  133. KdPrintEx((DPFLTR_SVCHOST_ID, \
  134. DEBUG_##level, \
  135. "[SVCHOST] %lx.%lx: " string, \
  136. GetCurrentProcessId(), \
  137. GetCurrentThreadId(), \
  138. var))
  139. //
  140. // Client-side debugging macros.
  141. //
  142. #define SCC_LOG0(level, string) \
  143. KdPrintEx((DPFLTR_SCCLIENT_ID, \
  144. DEBUG_##level, \
  145. "[SC-CLIENT] %lx: " string, \
  146. GetCurrentProcessId()))
  147. #define SCC_LOG1(level, string, var) \
  148. KdPrintEx((DPFLTR_SCCLIENT_ID, \
  149. DEBUG_##level, \
  150. "[SC-CLIENT] %lx: " string, \
  151. GetCurrentProcessId(), \
  152. var))
  153. #define SCC_LOG2(level, string, var1, var2) \
  154. KdPrintEx((DPFLTR_SCCLIENT_ID, \
  155. DEBUG_##level, \
  156. "[SC-CLIENT] %lx: " string, \
  157. GetCurrentProcessId(), \
  158. var1, \
  159. var2))
  160. #define SCC_LOG3(level, string, var1, var2, var3) \
  161. KdPrintEx((DPFLTR_SCCLIENT_ID, \
  162. DEBUG_##level, \
  163. "[SC-CLIENT] %lx: " string, \
  164. GetCurrentProcessId(), \
  165. var1, \
  166. var2, \
  167. var3))
  168. #define SCC_LOG(level, string, var) \
  169. KdPrintEx((DPFLTR_SCCLIENT_ID, \
  170. DEBUG_##level, \
  171. "[SC-CLIENT] %lx: " string, \
  172. GetCurrentProcessId(), \
  173. var))
  174. #define SCC_ASSERT(boolExpr) ASSERT(boolExpr)
  175. #else
  176. #define SC_ASSERT(boolExpr)
  177. #define SC_LOG0(level, string)
  178. #define SC_LOG1(level, string, var)
  179. #define SC_LOG2(level, string, var1, var2)
  180. #define SC_LOG3(level, string, var1, var2, var3)
  181. #define SC_LOG4(level, string, var1, var2, var3, var4)
  182. #define SC_LOG(level, string, var)
  183. #define SVCHOST_LOG0(level, string)
  184. #define SVCHOST_LOG1(level, string, var)
  185. #define SVCHOST_LOG2(level, string, var1, var2)
  186. #define SVCHOST_LOG3(level, string, var1, var2, var3)
  187. #define SVCHOST_LOG4(level, string, var1, var2, var3, var4)
  188. #define SVCHOST_LOG(level, string, var)
  189. #define SCC_ASSERT(boolExpr)
  190. #define SCC_LOG0(level, string)
  191. #define SCC_LOG1(level, string, var)
  192. #define SCC_LOG2(level, string, var1, var2)
  193. #define SCC_LOG3(level, string, var1, var2, var3)
  194. #define SCC_LOG(level, string, var)
  195. #endif
  196. //
  197. // Debug output is filtered at two levels: A global level and a component
  198. // specific level.
  199. //
  200. // Each debug output request specifies a component id and a filter level
  201. // or mask. These variables are used to access the debug print filter
  202. // database maintained by the system. The component id selects a 32-bit
  203. // mask value and the level either specified a bit within that mask or is
  204. // as mask value itself.
  205. //
  206. // If any of the bits specified by the level or mask are set in either the
  207. // component mask or the global mask, then the debug output is permitted.
  208. // Otherwise, the debug output is filtered and not printed.
  209. //
  210. // The component mask for filtering the debug output of this component is
  211. // Kd_SCSERVER_Mask or Kd_SCCLIENT_Mask and may be set via the registry or
  212. // the kernel debugger.
  213. //
  214. // The global mask for filtering the debug output of all components is
  215. // Kd_WIN2000_Mask and may be set via the registry or the kernel debugger.
  216. //
  217. // The registry key for setting the mask value for this component is:
  218. //
  219. // HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\
  220. // Session Manager\Debug Print Filter\SCSERVER or SCCLIENT
  221. //
  222. // The key "Debug Print Filter" may have to be created in order to create
  223. // the component key.
  224. //
  225. #define DEBUG_ERROR (0x00000001 | DPFLTR_MASK)
  226. #define DEBUG_WARNING (0x00000002 | DPFLTR_MASK)
  227. #define DEBUG_TRACE (0x00000004 | DPFLTR_MASK)
  228. #define DEBUG_INFO (0x00000008 | DPFLTR_MASK)
  229. #define DEBUG_SECURITY (0x00000010 | DPFLTR_MASK)
  230. #define DEBUG_CONFIG (0x00000020 | DPFLTR_MASK)
  231. #define DEBUG_DEPEND (0x00000040 | DPFLTR_MASK)
  232. #define DEBUG_DEPEND_DUMP (0x00000080 | DPFLTR_MASK)
  233. #define DEBUG_CONFIG_API (0x00000100 | DPFLTR_MASK)
  234. #define DEBUG_LOCK_API (0x00000200 | DPFLTR_MASK)
  235. #define DEBUG_ACCOUNT (0x00000400 | DPFLTR_MASK)
  236. #define DEBUG_USECOUNT (0x00000800 | DPFLTR_MASK)
  237. #define DEBUG_NETBIOS (0x00001000 | DPFLTR_MASK)
  238. #define DEBUG_THREADS (0x00002000 | DPFLTR_MASK)
  239. #define DEBUG_BSM (0x00004000 | DPFLTR_MASK)
  240. #define DEBUG_SHUTDOWN (0x00008000 | DPFLTR_MASK)
  241. #define DEBUG_WHY (0x00010000 | DPFLTR_MASK)
  242. #define DEBUG_BOOT (0x00020000 | DPFLTR_MASK)
  243. #define DEBUG_HANDLE (0x00040000 | DPFLTR_MASK)
  244. #define DEBUG_LOCKS (0x10000000 | DPFLTR_MASK)
  245. #define DEBUG_ALL (0xffffffff | DPFLTR_MASK)
  246. #ifdef __cplusplus
  247. }
  248. #endif
  249. #endif // def SCDEBUG_H