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.

323 lines
9.9 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_COMPRESSION (ULONGLONG)0x0000040000000000
  91. #define DEBUG_CREATE (ULONGLONG)0x0000080000000000
  92. #define DEBUG_SECSIG (ULONGLONG)0x0000100000000000
  93. #define DEBUG_STUCK_OPLOCK (ULONGLONG)0x0000200000000000
  94. #ifdef INCLUDE_SMB_PERSISTENT
  95. #define DEBUG_PERSISTENT (ULONGLONG)0x0000400000000000
  96. #endif
  97. //
  98. // SMB debug flags.
  99. //
  100. #define DEBUG_SMB_ADMIN1 (ULONGLONG)0x0000000000000001
  101. #define DEBUG_SMB_ADMIN2 (ULONGLONG)0x0000000000000002
  102. #define DEBUG_SMB_TREE1 (ULONGLONG)0x0000000000000004
  103. #define DEBUG_SMB_TREE2 (ULONGLONG)0x0000000000000008
  104. #define DEBUG_SMB_DIRECTORY1 (ULONGLONG)0x0000000000000010
  105. #define DEBUG_SMB_DIRECTORY2 (ULONGLONG)0x0000000000000020
  106. #define DEBUG_SMB_OPEN_CLOSE1 (ULONGLONG)0x0000000000000040
  107. #define DEBUG_SMB_OPEN_CLOSE2 (ULONGLONG)0x0000000000000080
  108. #define DEBUG_SMB_FILE_CONTROL1 (ULONGLONG)0x0000000000000100
  109. #define DEBUG_SMB_FILE_CONTROL2 (ULONGLONG)0x0000000000000200
  110. #define DEBUG_SMB_READ_WRITE1 (ULONGLONG)0x0000000000000400
  111. #define DEBUG_SMB_READ_WRITE2 (ULONGLONG)0x0000000000000800
  112. #define DEBUG_SMB_LOCK1 (ULONGLONG)0x0000000000001000
  113. #define DEBUG_SMB_LOCK2 (ULONGLONG)0x0000000000002000
  114. #define DEBUG_SMB_RAW1 (ULONGLONG)0x0000000000004000
  115. #define DEBUG_SMB_RAW2 (ULONGLONG)0x0000000000008000
  116. #define DEBUG_SMB_MPX1 (ULONGLONG)0x0000000000010000
  117. #define DEBUG_SMB_MPX2 (ULONGLONG)0x0000000000020000
  118. #define DEBUG_SMB_SEARCH1 (ULONGLONG)0x0000000000040000
  119. #define DEBUG_SMB_SEARCH2 (ULONGLONG)0x0000000000080000
  120. #define DEBUG_SMB_TRANSACTION1 (ULONGLONG)0x0000000000100000
  121. #define DEBUG_SMB_TRANSACTION2 (ULONGLONG)0x0000000000200000
  122. #define DEBUG_SMB_PRINT1 (ULONGLONG)0x0000000000400000
  123. #define DEBUG_SMB_PRINT2 (ULONGLONG)0x0000000000800000
  124. #define DEBUG_SMB_MESSAGE1 (ULONGLONG)0x0000000001000000
  125. #define DEBUG_SMB_MESSAGE2 (ULONGLONG)0x0000000002000000
  126. #define DEBUG_SMB_MISC1 (ULONGLONG)0x0000000004000000
  127. #define DEBUG_SMB_MISC2 (ULONGLONG)0x0000000008000000
  128. #define DEBUG_SMB_QUERY_SET1 (ULONGLONG)0x0000000010000000
  129. #define DEBUG_SMB_QUERY_SET2 (ULONGLONG)0x0000000020000000
  130. #define DEBUG_SMB_TRACE (ULONGLONG)0x0000000100000000
  131. // Which WMI events should be built into the server?
  132. #define BUILD_FLAGS (DEBUG_SMB_ERRORS | DEBUG_ERRORS | DEBUG_NETWORK_ERRORS | DEBUG_SNAPSHOT)
  133. #define BUILD_FLAGS_SMB (0)
  134. #define IF_DEBUG(flag) if (BUILD_FLAGS & DEBUG_ ## flag) \
  135. if ( SRV_WMI_LEVEL( VERBOSE ) && SRV_WMI_FLAGON( ERRORS ) && (KeGetCurrentIrql() < DISPATCH_LEVEL) )
  136. #define IF_SMB_DEBUG(flag) if (BUILD_FLAGS_SMB & DEBUG_SMB_ ## flag) \
  137. if ( SRV_WMI_LEVEL( VERBOSE ) && SRV_WMI_FLAGON( ERRORS ) && (KeGetCurrentIrql() < DISPATCH_LEVEL) )
  138. #define IF_STRESS() if( SRV_WMI_LEVEL( VERBOSE ) && SRV_WMI_FLAGON( STRESS ) && (KeGetCurrentIrql() < DISPATCH_LEVEL) )
  139. #if !SRVDBG
  140. #define DEBUG if (FALSE)
  141. #define SrvPrint0(fmt) KdPrint((fmt))
  142. #define SrvPrint1(fmt,v0) KdPrint((fmt,v0))
  143. #define SrvPrint2(fmt,v0,v1) KdPrint((fmt,v0,v1))
  144. #define SrvPrint3(fmt,v0,v1,v2) KdPrint((fmt,v0,v1,v2))
  145. #define SrvPrint4(fmt,v0,v1,v2,v3) KdPrint((fmt,v0,v1,v2,v3))
  146. #define SrvHPrint0(fmt)
  147. #define SrvHPrint1(fmt,v0)
  148. #define SrvHPrint2(fmt,v0,v1)
  149. #define SrvHPrint3(fmt,v0,v1,v2)
  150. #define SrvHPrint4(fmt,v0,v1,v2,v3)
  151. #else
  152. #define SrvHPrint0(fmt) DbgPrint( fmt )
  153. #define SrvHPrint1(fmt,v0) DbgPrint( fmt, v0 )
  154. #define SrvHPrint2(fmt,v0,v1) DbgPrint( fmt, v0, v1 )
  155. #define SrvHPrint3(fmt,v0,v1,v2) DbgPrint( fmt, v0, v1, v2 )
  156. #define SrvHPrint4(fmt,v0,v1,v2,v3) DbgPrint( fmt, v0, v1, v2, v3 )
  157. #define DEBUG if (TRUE)
  158. #define SrvPrint0(fmt) DbgPrint((fmt))
  159. #define SrvPrint1(fmt,v0) DbgPrint((fmt),(v0))
  160. #define SrvPrint2(fmt,v0,v1) DbgPrint((fmt),(v0),(v1))
  161. #define SrvPrint3(fmt,v0,v1,v2) DbgPrint((fmt),(v0),(v1),(v2))
  162. #define SrvPrint4(fmt,v0,v1,v2,v3) DbgPrint((fmt),(v0),(v1),(v2),(v3))
  163. #define PRINT_LITERAL(literal) DbgPrint( #literal" = %lx\n", (literal) )
  164. #endif // else !SRVDBG
  165. //
  166. // Macros for list debugging. These verify that lists are good whenever
  167. // a list operation is made.
  168. //
  169. #if SRVDBG_LIST || SRVDBG_LOCK
  170. ULONG
  171. SrvCheckListIntegrity (
  172. IN PLIST_ENTRY ListHead,
  173. IN ULONG MaxEntries
  174. );
  175. #endif
  176. #if !SRVDBG_LIST
  177. #define SrvInsertHeadList(head,entry) InsertHeadList(head,entry)
  178. #define SrvInsertTailList(head,entry) InsertTailList(head,entry)
  179. #define SrvRemoveEntryList(head,entry) RemoveEntryList(entry)
  180. #else // !SRVDBG_LIST
  181. VOID
  182. SrvIsEntryInList (
  183. IN PLIST_ENTRY ListHead,
  184. IN PLIST_ENTRY ListEntry
  185. );
  186. VOID
  187. SrvIsEntryNotInList (
  188. IN PLIST_ENTRY ListHead,
  189. IN PLIST_ENTRY ListEntry
  190. );
  191. #define SrvInsertHeadList(head,entry) \
  192. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  193. SrvIsEntryNotInList(head,entry); \
  194. InsertHeadList(head,entry)
  195. #define SrvInsertTailList(head,entry) \
  196. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  197. SrvIsEntryNotInList(head,entry); \
  198. InsertTailList(head,entry)
  199. #define SrvRemoveEntryList(head,entry) \
  200. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  201. SrvIsEntryInList( head, entry ); \
  202. RemoveEntryList(entry)
  203. #endif // else !SRVDBG_LIST
  204. //
  205. // Macros for statistics arithmetics.
  206. //
  207. #if !SRVDBG_STATS
  208. #define INCREMENT_DEBUG_STAT( _stat_ )
  209. #define DECREMENT_DEBUG_STAT( _stat_ )
  210. #else // !SRVDBG_STATS
  211. #define INCREMENT_DEBUG_STAT( _stat_ ) (_stat_)++
  212. #define DECREMENT_DEBUG_STAT( _stat_ ) (_stat_)--
  213. #endif // else !SRVDBG_STATS
  214. #if !SRVDBG_STATS2
  215. #define INCREMENT_DEBUG_STAT2( _stat_ )
  216. #define DECREMENT_DEBUG_STAT2( _stat_ )
  217. #else // !SRVDBG_STATS2
  218. #define INCREMENT_DEBUG_STAT2( _stat_ ) (_stat_)++
  219. #define DECREMENT_DEBUG_STAT2( _stat_ ) (_stat_)--
  220. #endif // else !SRVDBG_STATS2
  221. //
  222. // Macros for handle tracing.
  223. //
  224. #if !SRVDBG_HANDLES
  225. #define SRVDBG_CLAIM_HANDLE(_a_,_b_,_c_,_d_)
  226. #define SRVDBG_RELEASE_HANDLE(_a_,_b_,_c_,_d_)
  227. #else
  228. VOID
  229. SrvdbgClaimOrReleaseHandle (
  230. IN HANDLE Handle,
  231. IN PSZ HandleType,
  232. IN ULONG Location,
  233. IN BOOLEAN Release,
  234. IN PVOID Data
  235. );
  236. #define SRVDBG_CLAIM_HANDLE(_a_,_b_,_c_,_d_) SrvdbgClaimOrReleaseHandle((_a_),(_b_),(_c_),FALSE,(_d_))
  237. #define SRVDBG_RELEASE_HANDLE(_a_,_b_,_c_,_d_) SrvdbgClaimOrReleaseHandle((_a_),(_b_),(_c_),TRUE,(_d_))
  238. #endif
  239. #if DBG
  240. //
  241. // Routine to write a server buffer to a log file
  242. //
  243. VOID
  244. SrvLogBuffer( PCHAR msg, PVOID buf, ULONG len );
  245. #endif
  246. #endif // ndef _SRVDEBUG_