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.

213 lines
6.9 KiB

  1. /*++
  2. Copyright (c) 1995-1998 Microsoft Corporation
  3. Module Name:
  4. qosmdbg.h
  5. Abstract:
  6. Debugging in QOS Mgr Protocol DLL
  7. Revision History:
  8. --*/
  9. #ifndef __QOSMDBG_H__
  10. #define __QOSMDBG_H__
  11. //
  12. // Bypass the system assert
  13. //
  14. #ifdef ASSERT
  15. #undef ASSERT
  16. #endif
  17. #define ASSERT(a) { if ((a) == FALSE) DbgBreakPoint(); }
  18. //
  19. // Constants used for tracing
  20. //
  21. #define QOSM_TRACE_ANY ((DWORD)0xFFFF0000 | TRACE_USE_MASK)
  22. #define QOSM_TRACE_ERR ((DWORD)0x00010000 | TRACE_USE_MASK)
  23. #define QOSM_TRACE_ENTER ((DWORD)0x00020000 | TRACE_USE_MASK)
  24. #define QOSM_TRACE_LEAVE ((DWORD)0x00040000 | TRACE_USE_MASK)
  25. #define QOSM_TRACE_LOCK ((DWORD)0x00080000 | TRACE_USE_MASK)
  26. #define QOSM_TRACE_REFS ((DWORD)0x00100000 | TRACE_USE_MASK)
  27. #define QOSM_TRACE_HANDLE ((DWORD)0x00200000 | TRACE_USE_MASK)
  28. #define QOSM_TRACE_MEMORY ((DWORD)0x00400000 | TRACE_USE_MASK)
  29. #define QOSM_TRACE_START ((DWORD)0x00800000 | TRACE_USE_MASK)
  30. #define QOSM_TRACE_STOP ((DWORD)0x01000000 | TRACE_USE_MASK)
  31. #define QOSM_TRACE_CONFIG ((DWORD)0x02000000 | TRACE_USE_MASK)
  32. #define QOSM_TRACE_FLOW ((DWORD)0x04000000 | TRACE_USE_MASK)
  33. #define QOSM_TRACE_QUERY ((DWORD)0x08000000 | TRACE_USE_MASK)
  34. #define QOSM_TRACE_ENUM ((DWORD)0x10000000 | TRACE_USE_MASK)
  35. #define QOSM_TRACE_NOTIFY ((DWORD)0x20000000 | TRACE_USE_MASK)
  36. #define QOSM_TRACE_TIMER ((DWORD)0x40080000 | TRACE_USE_MASK)
  37. #define QOSM_TRACE_CALLBACK ((DWORD)0x80000000 | TRACE_USE_MASK)
  38. //
  39. // Macros used for tracing
  40. //
  41. #define TRACEHANDLE Globals.TracingHandle
  42. #define START_TRACING() TRACEHANDLE = TraceRegister("QOSM")
  43. #define STOP_TRACING() TraceDeregister(TRACEHANDLE)
  44. #define Trace0(l,a) \
  45. TracePrintfEx(TRACEHANDLE, QOSM_TRACE_ ## l, a)
  46. #define Trace1(l,a,b) \
  47. TracePrintfEx(TRACEHANDLE, QOSM_TRACE_ ## l, a, b)
  48. #define Trace2(l,a,b,c) \
  49. TracePrintfEx(TRACEHANDLE, QOSM_TRACE_ ## l, a, b, c)
  50. #define Trace3(l,a,b,c,d) \
  51. TracePrintfEx(TRACEHANDLE, QOSM_TRACE_ ## l, a, b, c, d)
  52. #define Trace4(l,a,b,c,d,e) \
  53. TracePrintfEx(TRACEHANDLE, QOSM_TRACE_ ## l, a, b, c, d, e)
  54. #define Trace5(l,a,b,c,d,e,f) \
  55. TracePrintfEx(TRACEHANDLE, QOSM_TRACE_ ## l, a, b, c, d, e, f)
  56. #define Trace6(l,a,b,c,d,e,f,g) \
  57. TracePrintfEx(TRACEHANDLE, QOSM_TRACE_ ## l, a, b, c, d, e, f, g)
  58. #define Tracedump(l,a,b,c) \
  59. TraceDumpEx(TRACEHANDLE,l,a,b,c,TRUE)
  60. #if DBG_CAL
  61. #define TraceEnter(X) Trace0(ENTER, "Entered: "X)
  62. #define TraceLeave(X) Trace0(LEAVE, "Leaving: "X"\n")
  63. #else
  64. #define TraceEnter(X)
  65. #define TraceLeave(X)
  66. #endif
  67. //
  68. // Constants used in logging
  69. //
  70. #define QOSM_LOGGING_NONE 0
  71. #define QOSM_LOGGING_ERROR 1
  72. #define QOSM_LOGGING_WARN 2
  73. #define QOSM_LOGGING_INFO 3
  74. //
  75. // Event logging macros
  76. //
  77. #define LOGHANDLE Globals.LoggingHandle
  78. #define LOGLEVEL Globals.LoggingLevel
  79. #define LOGERR RouterLogError
  80. #define LOGWARN RouterLogWarning
  81. #define LOGINFO RouterLogInformation
  82. #define LOGWARNDATA RouterLogWarningData
  83. //
  84. // Error logging
  85. //
  86. #define START_LOGGING() LOGHANDLE = RouterLogRegister("QOSM")
  87. #define STOP_LOGGING() RouterLogDeregister(LOGHANDLE)
  88. #define LOGERR0(msg,err) \
  89. if (LOGLEVEL >= QOSM_LOGGING_ERROR) \
  90. LOGERR(LOGHANDLE,QOSMLOG_ ## msg,0,NULL,(err))
  91. #define LOGERR1(msg,a,err) \
  92. if (LOGLEVEL >= QOSM_LOGGING_ERROR) \
  93. LOGERR(LOGHANDLE,QOSMLOG_ ## msg,1,&(a),(err))
  94. #define LOGERR2(msg,a,b,err) \
  95. if (LOGLEVEL >= QOSM_LOGGING_ERROR) { \
  96. LPSTR _asz[2] = { (a), (b) }; \
  97. LOGERR(LOGHANDLE,QOSMLOG_ ## msg,2,_asz,(err)); \
  98. }
  99. #define LOGERR3(msg,a,b,c,err) \
  100. if (LOGLEVEL >= QOSM_LOGGING_ERROR) { \
  101. LPSTR _asz[3] = { (a), (b), (c) }; \
  102. LOGERR(LOGHANDLE,QOSMLOG_ ## msg,3,_asz,(err)); \
  103. }
  104. #define LOGERR4(msg,a,b,c,d,err) \
  105. if (LOGLEVEL >= QOSM_LOGGING_ERROR) { \
  106. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  107. LOGERR(LOGHANDLE,QOSMLOG_ ## msg,4,_asz,(err)); \
  108. }
  109. //
  110. // Warning logging
  111. //
  112. #define LOGWARN0(msg,err) \
  113. if (LOGLEVEL >= QOSM_LOGGING_WARN) \
  114. LOGWARN(LOGHANDLE,QOSMLOG_ ## msg,0,NULL,(err))
  115. #define LOGWARN1(msg,a,err) \
  116. if (LOGLEVEL >= QOSM_LOGGING_WARN) \
  117. LOGWARN(LOGHANDLE,QOSMLOG_ ## msg,1,&(a),(err))
  118. #define LOGWARN2(msg,a,b,err) \
  119. if (LOGLEVEL >= QOSM_LOGGING_WARN) { \
  120. LPSTR _asz[2] = { (a), (b) }; \
  121. LOGWARN(LOGHANDLE,QOSMLOG_ ## msg,2,_asz,(err)); \
  122. }
  123. #define LOGWARN3(msg,a,b,c,err) \
  124. if (LOGLEVEL >= QOSM_LOGGING_WARN) { \
  125. LPSTR _asz[3] = { (a), (b), (c) }; \
  126. LOGWARN(LOGHANDLE,QOSMLOG_ ## msg,3,_asz,(err)); \
  127. }
  128. #define LOGWARN4(msg,a,b,c,d,err) \
  129. if (LOGLEVEL >= QOSM_LOGGING_WARN) { \
  130. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  131. LOGWARN(LOGHANDLE,QOSMLOG_ ## msg,4,_asz,(err)); \
  132. }
  133. #define LOGWARNDATA2(msg,a,b,dw,buf) \
  134. if (LOGLEVEL >= QOSM_LOGGING_WARN) { \
  135. LPSTR _asz[2] = { (a), (b) }; \
  136. LOGWARNDATA(LOGHANDLE,QOSMLOG_ ## msg,2,_asz,(dw),(buf)); \
  137. }
  138. //
  139. // Information logging
  140. //
  141. #define LOGINFO0(msg,err) \
  142. if (LOGLEVEL >= QOSM_LOGGING_INFO) \
  143. LOGINFO(LOGHANDLE,QOSMLOG_ ## msg,0,NULL,(err))
  144. #define LOGINFO1(msg,a,err) \
  145. if (LOGLEVEL >= QOSM_LOGGING_INFO) \
  146. LOGINFO(LOGHANDLE,QOSMLOG_ ## msg,1,&(a),(err))
  147. #define LOGINFO2(msg,a,b,err) \
  148. if (LOGLEVEL >= QOSM_LOGGING_INFO) { \
  149. LPSTR _asz[2] = { (a), (b) }; \
  150. LOGINFO(LOGHANDLE,QOSMLOG_ ## msg,2,_asz,(err)); \
  151. }
  152. #define LOGINFO3(msg,a,b,c,err) \
  153. if (LOGLEVEL >= QOSM_LOGGING_INFO) { \
  154. LPSTR _asz[3] = { (a), (b), (c) }; \
  155. LOGINFO(LOGHANDLE,QOSMLOG_ ## msg,3,_asz,(err)); \
  156. }
  157. #define LOGINFO4(msg,a,b,c,d,err) \
  158. if (LOGLEVEL >= QOSM_LOGGING_INFO) { \
  159. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  160. LOGINFO(LOGHANDLE,QOSMLOG_ ## msg,4,_asz,(err)); \
  161. }
  162. //
  163. // Misc Debugging Macros
  164. //
  165. #define IPADDR_FORMAT(x) \
  166. ((x)&0x000000ff),(((x)&0x0000ff00)>>8),(((x)&0x00ff0000)>>16),(((x)&0xff000000)>>24)
  167. #define TracePrintAddress(ID, Dest, Mask) \
  168. { \
  169. Trace2(ID, "Dest: %d.%d.%d.%d Mask: %d.%d.%d.%d", \
  170. IPADDR_FORMAT(Dest), \
  171. IPADDR_FORMAT(Mask)); \
  172. }
  173. #endif // __QOSMDBG_H__