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.

294 lines
7.7 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. rxtrace.h
  5. Abstract:
  6. This module defines the macros which provide debugging support ( tracing ).
  7. Author:
  8. Joe Linn [JoeLinn] 1-aug-1994
  9. Revision History:
  10. --*/
  11. #ifndef _RDBSSTRACE_INCLUDED_
  12. #define _RDBSSTRACE_INCLUDED_
  13. #if !DBG
  14. #undef RDBSSTRACE
  15. #endif // !DBG
  16. typedef struct _DEBUG_TRACE_CONTROLPOINT{
  17. ULONG ControlPointNumber;
  18. PSZ Name;
  19. } DEBUG_TRACE_CONTROLPOINT, *PDEBUG_TRACE_CONTROLPOINT;
  20. typedef struct {
  21. LONG PrintLevel;
  22. ULONG BreakMask;
  23. PSZ Name;
  24. } RX_DEBUG_TRACE_CONTROL, *PRX_DEBUG_TRACE_CONTROL;
  25. #ifdef RDBSSTRACE
  26. //define so that &RX_DEBUG_TRACE_CONTROL is NULL
  27. typedef struct {
  28. RX_DEBUG_TRACE_CONTROL Junk;
  29. } rxrxrx_AlwaysHelper;
  30. #define RX_DEBUG_TRACE_ALWAYS (((rxrxrx_AlwaysHelper*)0)->Junk)
  31. // The following macros provide fine grained control for selectively enabling
  32. // and disabling tracing.
  33. #define RXDT_Extern(__x) extern DEBUG_TRACE_CONTROLPOINT RX_DEBUG_TRACE_##__x
  34. #define RXDT_DeclareCategory(__x) extern DEBUG_TRACE_CONTROLPOINT RX_DEBUG_TRACE_##__x
  35. #define RXDT_DefineCategory(__x) DEBUG_TRACE_CONTROLPOINT RX_DEBUG_TRACE_##__x = {0,#__x}
  36. RXDT_Extern(ERROR);
  37. RXDT_Extern(HOOKS);
  38. RXDT_Extern(CATCH_EXCEPTIONS);
  39. RXDT_Extern(UNWIND);
  40. RXDT_Extern(CLEANUP);
  41. RXDT_Extern(CLOSE);
  42. RXDT_Extern(CREATE);
  43. RXDT_Extern(DIRCTRL);
  44. RXDT_Extern(EA);
  45. RXDT_Extern(FILEINFO);
  46. RXDT_Extern(FSCTRL);
  47. RXDT_Extern(LOCKCTRL);
  48. RXDT_Extern(READ);
  49. RXDT_Extern(VOLINFO);
  50. RXDT_Extern(WRITE);
  51. RXDT_Extern(FLUSH);
  52. RXDT_Extern(DEVCTRL);
  53. RXDT_Extern(SHUTDOWN);
  54. RXDT_Extern(PREFIX);
  55. RXDT_Extern(DEVFCB);
  56. RXDT_Extern(ACCHKSUP);
  57. RXDT_Extern(ALLOCSUP);
  58. RXDT_Extern(DIRSUP);
  59. RXDT_Extern(FILOBSUP);
  60. RXDT_Extern(NAMESUP);
  61. RXDT_Extern(VERFYSUP);
  62. RXDT_Extern(CACHESUP);
  63. RXDT_Extern(SPLAYSUP);
  64. RXDT_Extern(DEVIOSUP);
  65. RXDT_Extern(FCBSTRUCTS);
  66. RXDT_Extern(STRUCSUP);
  67. RXDT_Extern(FSP_DISPATCHER);
  68. RXDT_Extern(FSP_DUMP);
  69. RXDT_Extern(RXCONTX);
  70. RXDT_Extern(DISPATCH);
  71. RXDT_Extern(NTFASTIO);
  72. RXDT_Extern(LOWIO);
  73. RXDT_Extern(MINIRDR);
  74. RXDT_Extern(DISCCODE); //for the browser interface stuff
  75. RXDT_Extern(BROWSER);
  76. RXDT_Extern(CONNECT);
  77. RXDT_Extern(NTTIMER);
  78. RXDT_Extern(SCAVTHRD);
  79. RXDT_Extern(SCAVENGER);
  80. RXDT_Extern(SHAREACCESS);
  81. RXDT_Extern(NAMECACHE);
  82. //connection engines categories
  83. RXDT_Extern(RXCEBINDING);
  84. RXDT_Extern(RXCEDBIMPLEMENTATION);
  85. RXDT_Extern(RXCEMANAGEMENT);
  86. RXDT_Extern(RXCEXMIT);
  87. RXDT_Extern(RXCEPOOL);
  88. RXDT_Extern(RXCETDI);
  89. #else //RDBSSTRACE
  90. #define RXDT_Extern(__x)
  91. #define RXDT_DeclareCategory(__x)
  92. #define RXDT_DefineCategory(__x)
  93. #endif //RDBSSTRACE
  94. #ifdef RDBSSTRACE
  95. extern BOOLEAN RxGlobalTraceSuppress, RxNextGlobalTraceSuppress;
  96. extern ULONG RxGlobalTraceIrpCount;
  97. VOID RxInitializeDebugTrace(void);
  98. #define RxDbgTraceDoit(___x) ___x
  99. #ifndef MINIRDR__NAME
  100. extern LONG RxDebugTraceIndent;
  101. #else
  102. #define RxDebugTraceIndent (*(*___MINIRDR_IMPORTS_NAME).pRxDebugTraceIndent)
  103. #endif
  104. #else
  105. #define RxInitializeDebugTrace()
  106. #define RxDbgTraceDoit(___x)
  107. #endif //RDBSSTRACE
  108. #if DBG
  109. #define RxDT_INDENT_EXCESS 16 //this is the offset for excess-n for the indent
  110. #define RxDT_INDENT_SHIFT 20
  111. #define RxDT_INDENT_MASK 0x3f
  112. #define RxDT_LEVEL_MASK ((1<<RxDT_INDENT_SHIFT)-1)
  113. #define RxDT_SUPPRESS_PRINT 0x80000000
  114. #define RxDT_OVERRIDE_RETURN 0x40000000
  115. // The implementation details of the tracing feature.
  116. VOID
  117. RxDebugTraceActual (
  118. IN ULONG NewMask,
  119. IN PCH Format,
  120. ...
  121. );
  122. BOOLEAN
  123. RxDbgTraceActualNew (
  124. IN ULONG NewMask,
  125. IN OUT PDEBUG_TRACE_CONTROLPOINT ControlPoint
  126. );
  127. PRX_DEBUG_TRACE_CONTROL
  128. RxDbgTraceFindControlPointActual(
  129. IN OUT PDEBUG_TRACE_CONTROLPOINT ControlPoint
  130. );
  131. VOID
  132. RxInitializeDebugTraceControlPoint(
  133. PSZ Name,
  134. PDEBUG_TRACE_CONTROLPOINT ControlPoint
  135. );
  136. extern PCHAR RxIrpCodeToName[];
  137. #endif //DBG
  138. #ifdef RDBSSTRACE
  139. BOOLEAN
  140. RxDbgTraceDisableGlobally(void);
  141. VOID
  142. RxDbgTraceEnableGlobally(BOOLEAN flag);
  143. VOID
  144. RxDebugTraceDebugCommand(
  145. PSZ name,
  146. ULONG level,
  147. ULONG pointcount
  148. );
  149. VOID
  150. RxDebugTraceZeroAllPrintLevels(
  151. void
  152. );
  153. extern ULONG rdbsstracemarker;
  154. #define RxDTMASK(INDENT,WRITELEVEL) \
  155. ( (((INDENT)+RxDT_INDENT_EXCESS)<<RxDT_INDENT_SHIFT) + ((WRITELEVEL)&RxDT_LEVEL_MASK))
  156. #define RxDTPrefixRx(___x) RX_##___x
  157. #define RxDbgTraceLV__norx_reverseaction(INDENT,CONTROLPOINT,LEVEL,Z) \
  158. {BOOLEAN PrintIt = RxDbgTraceActualNew((RxDT_SUPPRESS_PRINT | RxDT_OVERRIDE_RETURN | RxDTMASK((INDENT),(LEVEL))),\
  159. (CONTROLPOINT)); \
  160. if (!PrintIt) Z; \
  161. }
  162. #define RxDbgTraceLV__norx(INDENT,CONTROLPOINT,LEVEL,Z) \
  163. {BOOLEAN PrintIt = RxDbgTraceActualNew( RxDTMASK((INDENT),(LEVEL)),(CONTROLPOINT)); \
  164. if (PrintIt) DbgPrint Z; \
  165. }
  166. #define RxDbgTraceLVUnIndent__norx(INDENT,CONTROLPOINT,LEVEL) \
  167. {BOOLEAN PrintIt = RxDbgTraceActualNew((RxDT_SUPPRESS_PRINT | RxDTMASK((INDENT),(LEVEL))),(CONTROLPOINT)); \
  168. }
  169. #define RxDbgTraceLV__(INDENT,CONTROLPOINT,LEVEL,Z) \
  170. RxDbgTraceLV__norx(INDENT,(&RxDTPrefixRx##CONTROLPOINT),LEVEL,Z)
  171. #define RxDbgTraceLVUnIndent__(INDENT,CONTROLPOINT,LEVEL) \
  172. RxDbgTraceLVUnIndent__norx(INDENT,(&RxDTPrefixRx##CONTROLPOINT),LEVEL)
  173. #define RxDbgTrace(INDENT,CONTROLPOINT,Z) \
  174. RxDbgTraceLV__(INDENT,CONTROLPOINT,1,Z) \
  175. #define RxDbgTraceLV(INDENT,CONTROLPOINT,LEVEL,Z) \
  176. RxDbgTraceLV__(INDENT,CONTROLPOINT,LEVEL,Z) \
  177. #define RxDbgTraceUnIndent(INDENT,CONTROLPOINT) \
  178. RxDbgTraceLVUnIndent__(INDENT,CONTROLPOINT,1)
  179. // do not define this for nonrdbsstrace; so to catch references not ifdef'd
  180. #define RxDbgTraceFindControlPoint(CONTROLPOINT) (RxDbgTraceFindControlPointActual(&RxDTPrefixRx##CONTROLPOINT))
  181. #define DebugBreakPoint(CONTROLPOINT,MASKBIT) { \
  182. if (((MASKBIT) == 0) \
  183. || (RxDbgTraceFindControlPoint(CONTROLPOINT)->BreakMask & (1<<((MASKBIT)-1)) )) { \
  184. DbgBreakPoint(); \
  185. } \
  186. }
  187. #define DebugUnwind(X) { \
  188. if (AbnormalTermination()) { \
  189. RxDbgTrace(0, (DEBUG_TRACE_UNWIND), ( #X ", Abnormal termination.\n", 0)); \
  190. } \
  191. }
  192. #ifdef RX_PERFPORMANCE_TIMER
  193. extern LONG RxPerformanceTimerLevel;
  194. #define TimerStart(LEVEL) { \
  195. LARGE_INTEGER TStart, TEnd; \
  196. LARGE_INTEGER TElapsed; \
  197. TStart = KeQueryPerformanceCounter( NULL ); \
  198. #define TimerStop(LEVEL,s) \
  199. TEnd = KeQueryPerformanceCounter( NULL ); \
  200. TElapsed.QuadPart = TEnd.QuadPart - TStart.QuadPart; \
  201. RxTotalTicks[RxLogOf(LEVEL)] += TElapsed.LowPart; \
  202. if (FlagOn( RxPerformanceTimerLevel, (LEVEL))) { \
  203. DbgPrint("Time of %s %ld\n", (s), TElapsed.LowPart ); \
  204. } \
  205. }
  206. #endif //RX_PERFPORMANCE_TIMER
  207. #else // RDBSSTRACE
  208. #define RxDbgTraceLV__norx_reverseaction(INDENT,CONTROLPOINT,LEVEL,Z) {NOTHING;}
  209. #define RxDbgTraceLV(INDENT,CONTROLPOINTNUM,LEVEL,Z) {NOTHING;}
  210. #define RxDbgTraceLVUnIndent(INDENT,CONTROLPOINTNUM,LEVEL) {NOTHING;}
  211. #define RxDbgTrace(INDENT,CONTROLPOINTNUM,Z) {NOTHING;}
  212. #define RxDbgTraceUnIndent(INDENT,CONTROLPOINTNUM) {NOTHING;}
  213. #define DebugBreakPoint(CONTROLPOINTNUM,MASKBIT) {NOTHING;}
  214. #define DebugUnwind(X) {NOTHING;}
  215. #define RxDbgTraceDisableGlobally() FALSE
  216. #define RxDbgTraceEnableGlobally(f) {NOTHING;}
  217. #ifdef RX_PERFPORMANCE_TIMER
  218. #define TimerStart(LEVEL)
  219. #define TimerStop(LEVEL,s)
  220. #endif
  221. #endif // RDBSSTRACE
  222. #endif // _RDBSSTRACE_INCLUDED_
  223.