Windows NT 4.0 source code leak
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.

306 lines
9.1 KiB

4 years ago
  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. #if !SRVDBG
  50. #define DEBUG if (FALSE)
  51. #define IF_DEBUG(flag) if (FALSE)
  52. #define IF_SMB_DEBUG(flag) if (FALSE)
  53. #define SrvPrint0(fmt)
  54. #define SrvPrint1(fmt,v0)
  55. #define SrvPrint2(fmt,v0,v1)
  56. #define SrvPrint3(fmt,v0,v1,v2)
  57. #define SrvPrint4(fmt,v0,v1,v2,v3)
  58. #else
  59. #define DEBUG if (TRUE)
  60. //
  61. // We shouldn't have to futz around with LowPart and HighPart, but the x86 compiler
  62. // is generating incorrect code for bit testing 64 bit quantities (12/16/94)
  63. //
  64. #define IF_DEBUG(flag) if( (SrvDebug.u.LowPart & (ULONG)(DEBUG_ ## flag)) || \
  65. (SrvDebug.u.HighPart & (ULONG)(DEBUG_ ## flag >> 32)) )
  66. extern ULARGE_INTEGER SrvDebug;
  67. #define IF_SMB_DEBUG(flag) if( (SmbDebug.u.LowPart & (ULONG)(DEBUG_SMB_ ## flag)) || \
  68. (SmbDebug.u.HighPart & (ULONG)(DEBUG_SMB_ ## flag >> 32)) )
  69. extern ULARGE_INTEGER SmbDebug;
  70. #define SrvPrint0(fmt) DbgPrint((fmt))
  71. #define SrvPrint1(fmt,v0) DbgPrint((fmt),(v0))
  72. #define SrvPrint2(fmt,v0,v1) DbgPrint((fmt),(v0),(v1))
  73. #define SrvPrint3(fmt,v0,v1,v2) DbgPrint((fmt),(v0),(v1),(v2))
  74. #define SrvPrint4(fmt,v0,v1,v2,v3) DbgPrint((fmt),(v0),(v1),(v2),(v3))
  75. #define PRINT_LITERAL(literal) DbgPrint( #literal" = %lx\n", (literal) )
  76. #define DEBUG_TRACE1 (ULONGLONG)0x0000000000000001
  77. #define DEBUG_TRACE2 (ULONGLONG)0x0000000000000002
  78. #define DEBUG_REFCNT (ULONGLONG)0x0000000000000004
  79. #define DEBUG_HEAP (ULONGLONG)0x0000000000000008
  80. #define DEBUG_WORKER1 (ULONGLONG)0x0000000000000010
  81. #define DEBUG_WORKER2 (ULONGLONG)0x0000000000000020
  82. #define DEBUG_NET1 (ULONGLONG)0x0000000000000040
  83. #define DEBUG_NET2 (ULONGLONG)0x0000000000000080
  84. #define DEBUG_FSP1 (ULONGLONG)0x0000000000000100
  85. #define DEBUG_FSP2 (ULONGLONG)0x0000000000000200
  86. #define DEBUG_FSD1 (ULONGLONG)0x0000000000000400
  87. #define DEBUG_FSD2 (ULONGLONG)0x0000000000000800
  88. #define DEBUG_SCAV1 (ULONGLONG)0x0000000000001000
  89. #define DEBUG_SCAV2 (ULONGLONG)0x0000000000002000
  90. #define DEBUG_BLOCK1 (ULONGLONG)0x0000000000004000
  91. #define DEBUG_IPX_PIPES (ULONGLONG)0x0000000000008000
  92. #define DEBUG_HANDLES (ULONGLONG)0x0000000000010000
  93. #define DEBUG_IPX (ULONGLONG)0x0000000000020000
  94. #define DEBUG_TDI (ULONGLONG)0x0000000000040000
  95. #define DEBUG_OPLOCK (ULONGLONG)0x0000000000080000
  96. #define DEBUG_NETWORK_ERRORS (ULONGLONG)0x0000000000100000
  97. #define DEBUG_FILE_CACHE (ULONGLONG)0x0000000000200000
  98. #define DEBUG_IPX2 (ULONGLONG)0x0000000000400000
  99. #define DEBUG_LOCKS (ULONGLONG)0x0000000000800000
  100. #define DEBUG_SEARCH (ULONGLONG)0x0000000001000000
  101. #define DEBUG_BRUTE_FORCE_REWIND (ULONGLONG)0x0000000002000000
  102. #define DEBUG_COMM (ULONGLONG)0x0000000004000000
  103. #define DEBUG_XACTSRV (ULONGLONG)0x0000000008000000
  104. #define DEBUG_API_ERRORS (ULONGLONG)0x0000000010000000
  105. #define DEBUG_STOP_ON_ERRORS (ULONGLONG)0x0000000020000000 // If set, stop on internal errs
  106. #define DEBUG_SMB_ERRORS (ULONGLONG)0x0000000040000000
  107. #define DEBUG_ERRORS (ULONGLONG)0x0000000080000000
  108. #define DEBUG_LICENSE (ULONGLONG)0x0000000100000000
  109. #define DEBUG_WORKITEMS (ULONGLONG)0x0000000200000000
  110. #define DEBUG_IPXNAMECLAIM (ULONGLONG)0x0000000400000000
  111. #define DEBUG_SENDS2OTHERCPU (ULONGLONG)0x0000001000000000
  112. #define DEBUG_REBALANCE (ULONGLONG)0x0000002000000000
  113. #define DEBUG_PNP (ULONGLONG)0x0000004000000000
  114. #define DEBUG_DFS (ULONGLONG)0x0000010000000000
  115. #define DEBUG_SIPX (ULONGLONG)0x0000020000000000
  116. //
  117. // SMB debug flags.
  118. //
  119. #define DEBUG_SMB_ADMIN1 (ULONGLONG)0x0000000000000001
  120. #define DEBUG_SMB_ADMIN2 (ULONGLONG)0x0000000000000002
  121. #define DEBUG_SMB_TREE1 (ULONGLONG)0x0000000000000004
  122. #define DEBUG_SMB_TREE2 (ULONGLONG)0x0000000000000008
  123. #define DEBUG_SMB_DIRECTORY1 (ULONGLONG)0x0000000000000010
  124. #define DEBUG_SMB_DIRECTORY2 (ULONGLONG)0x0000000000000020
  125. #define DEBUG_SMB_OPEN_CLOSE1 (ULONGLONG)0x0000000000000040
  126. #define DEBUG_SMB_OPEN_CLOSE2 (ULONGLONG)0x0000000000000080
  127. #define DEBUG_SMB_FILE_CONTROL1 (ULONGLONG)0x0000000000000100
  128. #define DEBUG_SMB_FILE_CONTROL2 (ULONGLONG)0x0000000000000200
  129. #define DEBUG_SMB_READ_WRITE1 (ULONGLONG)0x0000000000000400
  130. #define DEBUG_SMB_READ_WRITE2 (ULONGLONG)0x0000000000000800
  131. #define DEBUG_SMB_LOCK1 (ULONGLONG)0x0000000000001000
  132. #define DEBUG_SMB_LOCK2 (ULONGLONG)0x0000000000002000
  133. #define DEBUG_SMB_RAW1 (ULONGLONG)0x0000000000004000
  134. #define DEBUG_SMB_RAW2 (ULONGLONG)0x0000000000008000
  135. #define DEBUG_SMB_MPX1 (ULONGLONG)0x0000000000010000
  136. #define DEBUG_SMB_MPX2 (ULONGLONG)0x0000000000020000
  137. #define DEBUG_SMB_SEARCH1 (ULONGLONG)0x0000000000040000
  138. #define DEBUG_SMB_SEARCH2 (ULONGLONG)0x0000000000080000
  139. #define DEBUG_SMB_TRANSACTION1 (ULONGLONG)0x0000000000100000
  140. #define DEBUG_SMB_TRANSACTION2 (ULONGLONG)0x0000000000200000
  141. #define DEBUG_SMB_PRINT1 (ULONGLONG)0x0000000000400000
  142. #define DEBUG_SMB_PRINT2 (ULONGLONG)0x0000000000800000
  143. #define DEBUG_SMB_MESSAGE1 (ULONGLONG)0x0000000001000000
  144. #define DEBUG_SMB_MESSAGE2 (ULONGLONG)0x0000000002000000
  145. #define DEBUG_SMB_MISC1 (ULONGLONG)0x0000000004000000
  146. #define DEBUG_SMB_MISC2 (ULONGLONG)0x0000000008000000
  147. #define DEBUG_SMB_QUERY_SET1 (ULONGLONG)0x0000000010000000
  148. #define DEBUG_SMB_QUERY_SET2 (ULONGLONG)0x0000000020000000
  149. #define DEBUG_SMB_BULK1 (ULONGLONG)0x0000000040000000
  150. #define DEBUG_SMB_BULK2 (ULONGLONG)0x0000000080000000
  151. #define DEBUG_SMB_TRACE (ULONGLONG)0x0000000100000000
  152. #endif // else !SRVDBG
  153. //
  154. // Macros for list debugging. These verify that lists are good whenever
  155. // a list operation is made.
  156. //
  157. #if SRVDBG_LIST || SRVDBG_LOCK
  158. ULONG
  159. SrvCheckListIntegrity (
  160. IN PLIST_ENTRY ListHead,
  161. IN ULONG MaxEntries
  162. );
  163. #endif
  164. #if !SRVDBG_LIST
  165. #define SrvInsertHeadList(head,entry) InsertHeadList(head,entry)
  166. #define SrvInsertTailList(head,entry) InsertTailList(head,entry)
  167. #define SrvRemoveEntryList(head,entry) RemoveEntryList(entry)
  168. #else // !SRVDBG_LIST
  169. VOID
  170. SrvIsEntryInList (
  171. IN PLIST_ENTRY ListHead,
  172. IN PLIST_ENTRY ListEntry
  173. );
  174. VOID
  175. SrvIsEntryNotInList (
  176. IN PLIST_ENTRY ListHead,
  177. IN PLIST_ENTRY ListEntry
  178. );
  179. #define SrvInsertHeadList(head,entry) \
  180. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  181. SrvIsEntryNotInList(head,entry); \
  182. InsertHeadList(head,entry)
  183. #define SrvInsertTailList(head,entry) \
  184. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  185. SrvIsEntryNotInList(head,entry); \
  186. InsertTailList(head,entry)
  187. #define SrvRemoveEntryList(head,entry) \
  188. (VOID)SrvCheckListIntegrity( head, 0xFFFFFFFF ); \
  189. SrvIsEntryInList( head, entry ); \
  190. RemoveEntryList(entry)
  191. #endif // else !SRVDBG_LIST
  192. //
  193. // Macros for statistics arithmetics.
  194. //
  195. #if !SRVDBG_STATS
  196. #define INCREMENT_DEBUG_STAT( _stat_ )
  197. #define DECREMENT_DEBUG_STAT( _stat_ )
  198. #else // !SRVDBG_STATS
  199. #define INCREMENT_DEBUG_STAT( _stat_ ) (_stat_)++
  200. #define DECREMENT_DEBUG_STAT( _stat_ ) (_stat_)--
  201. #endif // else !SRVDBG_STATS
  202. #if !SRVDBG_STATS2
  203. #define INCREMENT_DEBUG_STAT2( _stat_ )
  204. #define DECREMENT_DEBUG_STAT2( _stat_ )
  205. #else // !SRVDBG_STATS2
  206. #define INCREMENT_DEBUG_STAT2( _stat_ ) (_stat_)++
  207. #define DECREMENT_DEBUG_STAT2( _stat_ ) (_stat_)--
  208. #endif // else !SRVDBG_STATS2
  209. //
  210. // Macros for handle tracing.
  211. //
  212. #if !SRVDBG_HANDLES
  213. #define SRVDBG_CLAIM_HANDLE(_a_,_b_,_c_,_d_)
  214. #define SRVDBG_RELEASE_HANDLE(_a_,_b_,_c_,_d_)
  215. #else
  216. VOID
  217. SrvdbgClaimOrReleaseHandle (
  218. IN HANDLE Handle,
  219. IN PSZ HandleType,
  220. IN ULONG Location,
  221. IN BOOLEAN Release,
  222. IN PVOID Data
  223. );
  224. #define SRVDBG_CLAIM_HANDLE(_a_,_b_,_c_,_d_) SrvdbgClaimOrReleaseHandle((_a_),(_b_),(_c_),FALSE,(_d_))
  225. #define SRVDBG_RELEASE_HANDLE(_a_,_b_,_c_,_d_) SrvdbgClaimOrReleaseHandle((_a_),(_b_),(_c_),TRUE,(_d_))
  226. #endif
  227. #if DBG
  228. //
  229. // Routine to write a server buffer to a log file
  230. //
  231. VOID
  232. SrvLogBuffer( PCHAR msg, PVOID buf, ULONG len );
  233. #endif
  234. #endif // ndef _SRVDEBUG_