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.

319 lines
10 KiB

  1. #ifndef _SRVDEBUG_
  2. #define _SRVDEBUG_
  3. #ifdef MEMPRINT
  4. #include <memprint.h>
  5. #endif
  6. //
  7. // Debugging macros
  8. //
  9. #ifndef DBG
  10. #define DBG 0
  11. #endif
  12. #if !DBG
  13. #undef SRVDBG
  14. #define SRVDBG 0
  15. #undef SRVDBG2
  16. #define SRVDBG2 0
  17. #define SRVFASTCALL FASTCALL
  18. #else
  19. #ifndef SRVDBG
  20. #define SRVDBG 0
  21. #endif
  22. #ifndef SRVDBG2
  23. #define SRVDBG2 0
  24. #endif
  25. #define SRVFASTCALL
  26. #endif
  27. #ifndef SRVDBG_LIST
  28. #define SRVDBG_LIST 0
  29. #endif
  30. #ifndef SRVDBG_LOCK
  31. #define SRVDBG_LOCK 0
  32. #endif
  33. #ifndef SRVDBG_STATS
  34. #define SRVDBG_STATS 0
  35. #endif
  36. #ifndef SRVDBG_STATS2
  37. #define SRVDBG_STATS2 0
  38. #endif
  39. #ifndef SRVDBG_HANDLES
  40. #define SRVDBG_HANDLES 0
  41. #endif
  42. #undef IF_DEBUG
  43. #undef IF_SMB_DEBUG
  44. #if 0
  45. #define STATIC static
  46. #else
  47. #define STATIC
  48. #endif
  49. #define DEBUG_TRACE1 (ULONGLONG)0x0000000000000001
  50. #define DEBUG_TRACE2 (ULONGLONG)0x0000000000000002
  51. #define DEBUG_REFCNT (ULONGLONG)0x0000000000000004
  52. #define DEBUG_HEAP (ULONGLONG)0x0000000000000008
  53. #define DEBUG_WORKER1 (ULONGLONG)0x0000000000000010
  54. #define DEBUG_WORKER2 (ULONGLONG)0x0000000000000020
  55. #define DEBUG_NET1 (ULONGLONG)0x0000000000000040
  56. #define DEBUG_NET2 (ULONGLONG)0x0000000000000080
  57. #define DEBUG_FSP1 (ULONGLONG)0x0000000000000100
  58. #define DEBUG_FSP2 (ULONGLONG)0x0000000000000200
  59. #define DEBUG_FSD1 (ULONGLONG)0x0000000000000400
  60. #define DEBUG_FSD2 (ULONGLONG)0x0000000000000800
  61. #define DEBUG_SCAV1 (ULONGLONG)0x0000000000001000
  62. #define DEBUG_SCAV2 (ULONGLONG)0x0000000000002000
  63. #define DEBUG_BLOCK1 (ULONGLONG)0x0000000000004000
  64. #define DEBUG_IPX_PIPES (ULONGLONG)0x0000000000008000
  65. #define DEBUG_HANDLES (ULONGLONG)0x0000000000010000
  66. #define DEBUG_IPX (ULONGLONG)0x0000000000020000
  67. #define DEBUG_TDI (ULONGLONG)0x0000000000040000
  68. #define DEBUG_OPLOCK (ULONGLONG)0x0000000000080000
  69. #define DEBUG_NETWORK_ERRORS (ULONGLONG)0x0000000000100000
  70. #define DEBUG_FILE_CACHE (ULONGLONG)0x0000000000200000
  71. #define DEBUG_IPX2 (ULONGLONG)0x0000000000400000
  72. #define DEBUG_LOCKS (ULONGLONG)0x0000000000800000
  73. #define DEBUG_SEARCH (ULONGLONG)0x0000000001000000
  74. #define DEBUG_BRUTE_FORCE_REWIND (ULONGLONG)0x0000000002000000
  75. #define DEBUG_COMM (ULONGLONG)0x0000000004000000
  76. #define DEBUG_XACTSRV (ULONGLONG)0x0000000008000000
  77. #define DEBUG_API_ERRORS (ULONGLONG)0x0000000010000000
  78. #define DEBUG_STOP_ON_ERRORS (ULONGLONG)0x0000000020000000 // If set, stop on internal errs
  79. #define DEBUG_SMB_ERRORS (ULONGLONG)0x0000000040000000
  80. #define DEBUG_ERRORS (ULONGLONG)0x0000000080000000
  81. #define DEBUG_LICENSE (ULONGLONG)0x0000000100000000
  82. #define DEBUG_WORKITEMS (ULONGLONG)0x0000000200000000
  83. #define DEBUG_IPXNAMECLAIM (ULONGLONG)0x0000000400000000
  84. #define DEBUG_SENDS2OTHERCPU (ULONGLONG)0x0000001000000000
  85. #define DEBUG_REBALANCE (ULONGLONG)0x0000002000000000
  86. #define DEBUG_PNP (ULONGLONG)0x0000004000000000
  87. #define DEBUG_SNAPSHOT (ULONGLONG)0x0000008000000000
  88. #define DEBUG_DFS (ULONGLONG)0x0000010000000000
  89. #define DEBUG_SIPX (ULONGLONG)0x0000020000000000
  90. #define DEBUG_CREATE (ULONGLONG)0x0000080000000000
  91. #define DEBUG_SECSIG (ULONGLONG)0x0000100000000000
  92. #define DEBUG_STUCK_OPLOCK (ULONGLONG)0x0000200000000000
  93. //
  94. // SMB debug flags.
  95. //
  96. #define DEBUG_SMB_ADMIN1 (ULONGLONG)0x0000000000000001
  97. #define DEBUG_SMB_ADMIN2 (ULONGLONG)0x0000000000000002
  98. #define DEBUG_SMB_TREE1 (ULONGLONG)0x0000000000000004
  99. #define DEBUG_SMB_TREE2 (ULONGLONG)0x0000000000000008
  100. #define DEBUG_SMB_DIRECTORY1 (ULONGLONG)0x0000000000000010
  101. #define DEBUG_SMB_DIRECTORY2 (ULONGLONG)0x0000000000000020
  102. #define DEBUG_SMB_OPEN_CLOSE1 (ULONGLONG)0x0000000000000040
  103. #define DEBUG_SMB_OPEN_CLOSE2 (ULONGLONG)0x0000000000000080
  104. #define DEBUG_SMB_FILE_CONTROL1 (ULONGLONG)0x0000000000000100
  105. #define DEBUG_SMB_FILE_CONTROL2 (ULONGLONG)0x0000000000000200
  106. #define DEBUG_SMB_READ_WRITE1 (ULONGLONG)0x0000000000000400
  107. #define DEBUG_SMB_READ_WRITE2 (ULONGLONG)0x0000000000000800
  108. #define DEBUG_SMB_LOCK1 (ULONGLONG)0x0000000000001000
  109. #define DEBUG_SMB_LOCK2 (ULONGLONG)0x0000000000002000
  110. #define DEBUG_SMB_RAW1 (ULONGLONG)0x0000000000004000
  111. #define DEBUG_SMB_RAW2 (ULONGLONG)0x0000000000008000
  112. #define DEBUG_SMB_MPX1 (ULONGLONG)0x0000000000010000
  113. #define DEBUG_SMB_MPX2 (ULONGLONG)0x0000000000020000
  114. #define DEBUG_SMB_SEARCH1 (ULONGLONG)0x0000000000040000
  115. #define DEBUG_SMB_SEARCH2 (ULONGLONG)0x0000000000080000
  116. #define DEBUG_SMB_TRANSACTION1 (ULONGLONG)0x0000000000100000
  117. #define DEBUG_SMB_TRANSACTION2 (ULONGLONG)0x0000000000200000
  118. #define DEBUG_SMB_PRINT1 (ULONGLONG)0x0000000000400000
  119. #define DEBUG_SMB_PRINT2 (ULONGLONG)0x0000000000800000
  120. #define DEBUG_SMB_MESSAGE1 (ULONGLONG)0x0000000001000000
  121. #define DEBUG_SMB_MESSAGE2 (ULONGLONG)0x0000000002000000
  122. #define DEBUG_SMB_MISC1 (ULONGLONG)0x0000000004000000
  123. #define DEBUG_SMB_MISC2 (ULONGLONG)0x0000000008000000
  124. #define DEBUG_SMB_QUERY_SET1 (ULONGLONG)0x0000000010000000
  125. #define DEBUG_SMB_QUERY_SET2 (ULONGLONG)0x0000000020000000
  126. #define DEBUG_SMB_TRACE (ULONGLONG)0x0000000100000000
  127. // Which WMI events should be built into the server?
  128. #define BUILD_FLAGS (DEBUG_SMB_ERRORS | DEBUG_ERRORS | DEBUG_NETWORK_ERRORS | DEBUG_SNAPSHOT)
  129. #define BUILD_FLAGS_SMB (0)
  130. #define IF_DEBUG(flag) if (BUILD_FLAGS & DEBUG_ ## flag) \
  131. if ( SRV_WMI_LEVEL( VERBOSE ) && SRV_WMI_FLAGON( ERRORS ) && (KeGetCurrentIrql() < DISPATCH_LEVEL) )
  132. #define IF_SMB_DEBUG(flag) if (BUILD_FLAGS_SMB & DEBUG_SMB_ ## flag) \
  133. if ( SRV_WMI_LEVEL( VERBOSE ) && SRV_WMI_FLAGON( ERRORS ) && (KeGetCurrentIrql() < DISPATCH_LEVEL) )
  134. #define IF_STRESS() if( SRV_WMI_LEVEL( VERBOSE ) && SRV_WMI_FLAGON( STRESS ) && (KeGetCurrentIrql() < DISPATCH_LEVEL) )
  135. #ifdef SYSCACHE_DEBUGGING
  136. #define IF_SYSCACHE() if( SRV_WMI_LEVEL( VERBOSE ) && SRV_WMI_FLAGON( SYSCACHE ) && (KeGetCurrentIrql() < DISPATCH_LEVEL) )
  137. #define IF_SYSCACHE_RFCB( INRFCB ) if( (INRFCB->SrvCatch < 0) && SRV_WMI_LEVEL( VERBOSE ) && SRV_WMI_FLAGON( SYSCACHE ) && (KeGetCurrentIrql() < DISPATCH_LEVEL) )
  138. #else
  139. #define IF_SYSCACHE() if( FALSE )
  140. #define IF_SYSCACHE_RFCB( INRFCB ) if( FALSE )
  141. #endif
  142. #if !SRVDBG
  143. #define DEBUG if (FALSE)
  144. #define SrvPrint0(fmt) KdPrint((fmt))
  145. #define SrvPrint1(fmt,v0) KdPrint((fmt,v0))
  146. #define SrvPrint2(fmt,v0,v1) KdPrint((fmt,v0,v1))
  147. #define SrvPrint3(fmt,v0,v1,v2) KdPrint((fmt,v0,v1,v2))
  148. #define SrvPrint4(fmt,v0,v1,v2,v3) KdPrint((fmt,v0,v1,v2,v3))
  149. #define SrvHPrint0(fmt)
  150. #define SrvHPrint1(fmt,v0)
  151. #define SrvHPrint2(fmt,v0,v1)
  152. #define SrvHPrint3(fmt,v0,v1,v2)
  153. #define SrvHPrint4(fmt,v0,v1,v2,v3)
  154. #else
  155. #define SrvHPrint0(fmt) DbgPrint( fmt )
  156. #define SrvHPrint1(fmt,v0) DbgPrint( fmt, v0 )
  157. #define SrvHPrint2(fmt,v0,v1) DbgPrint( fmt, v0, v1 )
  158. #define SrvHPrint3(fmt,v0,v1,v2) DbgPrint( fmt, v0, v1, v2 )
  159. #define SrvHPrint4(fmt,v0,v1,v2,v3) DbgPrint( fmt, v0, v1, v2, v3 )
  160. #define DEBUG if (TRUE)
  161. #define SrvPrint0(fmt) DbgPrint((fmt))
  162. #define SrvPrint1(fmt,v0) DbgPrint((fmt),(v0))
  163. #define SrvPrint2(fmt,v0,v1) DbgPrint((fmt),(v0),(v1))
  164. #define SrvPrint3(fmt,v0,v1,v2) DbgPrint((fmt),(v0),(v1),(v2))
  165. #define SrvPrint4(fmt,v0,v1,v2,v3) DbgPrint((fmt),(v0),(v1),(v2),(v3))
  166. #define PRINT_LITERAL(literal) DbgPrint( #literal" = %lx\n", (literal) )
  167. #endif // else !SRVDBG
  168. //
  169. // Macros for list debugging. These verify that lists are good whenever
  170. // a list operation is made.
  171. //
  172. #if SRVDBG_LIST || SRVDBG_LOCK
  173. ULONG
  174. SrvCheckListIntegrity (
  175. IN PLIST_ENTRY ListHead,
  176. IN ULONG MaxEntries
  177. );
  178. #endif
  179. #if !SRVDBG_LIST
  180. #define SrvInsertHeadList(head,entry) InsertHeadList(head,entry)
  181. #define SrvInsertTailList(head,entry) InsertTailList(head,entry)
  182. #define SrvRemoveEntryList(head,entry) RemoveEntryList(entry)
  183. #else // !SRVDBG_LIST
  184. VOID
  185. SrvIsEntryInList (
  186. IN PLIST_ENTRY ListHead,
  187. IN PLIST_ENTRY ListEntry
  188. );
  189. VOID
  190. SrvIsEntryNotInList (
  191. IN PLIST_ENTRY ListHead,
  192. IN PLIST_ENTRY ListEntry
  193. );
  194. #define SrvInsertHeadList(head,entry) \
  195. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  196. SrvIsEntryNotInList(head,entry); \
  197. InsertHeadList(head,entry)
  198. #define SrvInsertTailList(head,entry) \
  199. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  200. SrvIsEntryNotInList(head,entry); \
  201. InsertTailList(head,entry)
  202. #define SrvRemoveEntryList(head,entry) \
  203. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  204. SrvIsEntryInList( head, entry ); \
  205. RemoveEntryList(entry)
  206. #endif // else !SRVDBG_LIST
  207. //
  208. // Macros for statistics arithmetics.
  209. //
  210. #if !SRVDBG_STATS
  211. #define INCREMENT_DEBUG_STAT( _stat_ )
  212. #define DECREMENT_DEBUG_STAT( _stat_ )
  213. #else // !SRVDBG_STATS
  214. #define INCREMENT_DEBUG_STAT( _stat_ ) (_stat_)++
  215. #define DECREMENT_DEBUG_STAT( _stat_ ) (_stat_)--
  216. #endif // else !SRVDBG_STATS
  217. #if !SRVDBG_STATS2
  218. #define INCREMENT_DEBUG_STAT2( _stat_ )
  219. #define DECREMENT_DEBUG_STAT2( _stat_ )
  220. #else // !SRVDBG_STATS2
  221. #define INCREMENT_DEBUG_STAT2( _stat_ ) (_stat_)++
  222. #define DECREMENT_DEBUG_STAT2( _stat_ ) (_stat_)--
  223. #endif // else !SRVDBG_STATS2
  224. //
  225. // Macros for handle tracing.
  226. //
  227. #if !SRVDBG_HANDLES
  228. #define SRVDBG_CLAIM_HANDLE(_a_,_b_,_c_,_d_)
  229. #define SRVDBG_RELEASE_HANDLE(_a_,_b_,_c_,_d_)
  230. #else
  231. VOID
  232. SrvdbgClaimOrReleaseHandle (
  233. IN HANDLE Handle,
  234. IN PSZ HandleType,
  235. IN ULONG Location,
  236. IN BOOLEAN Release,
  237. IN PVOID Data
  238. );
  239. #define SRVDBG_CLAIM_HANDLE(_a_,_b_,_c_,_d_) SrvdbgClaimOrReleaseHandle((_a_),(_b_),(_c_),FALSE,(_d_))
  240. #define SRVDBG_RELEASE_HANDLE(_a_,_b_,_c_,_d_) SrvdbgClaimOrReleaseHandle((_a_),(_b_),(_c_),TRUE,(_d_))
  241. #endif
  242. #endif // ndef _SRVDEBUG_