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.

198 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. dbg.h
  5. Abstract:
  6. Debug-related definitions for RM Apis in ATMEPVC
  7. Author:
  8. Revision History:
  9. Who When What
  10. -------- -------- ----
  11. ADube 03-23-00 created, .
  12. --*/
  13. //-----------------------------------------------------------------------------
  14. // Debug constants
  15. //-----------------------------------------------------------------------------
  16. // Memory tags used with NdisAllocateMemoryWithTag to identify allocations
  17. // made by the EPVC driver. Also, several context blocks define a first field
  18. // of 'ulTag' set to these values for ASSERT sanity checking and eased memory
  19. // dump browsing. Such tags are set to MTAG_FREED just before NdisFreeMemory
  20. // is called.
  21. //
  22. // Rm/generic tags
  23. //
  24. #define MTAG_DBGINFO 'd31A'
  25. #define MTAG_TASK 't31A'
  26. #define MTAG_STRING 's31A'
  27. #define MTAG_FREED 'z31A'
  28. #define MTAG_RMINTERNAL 'r31A'
  29. // Trace levels.
  30. //
  31. #define TL_FATAL TL_A // Fatal errors -- always printed in checked build.
  32. #define TL_WARN TL_I // Warnings
  33. #define TL_INFO TL_N // Informational (highest level workable for general use)
  34. #define TL_VERB TL_V // VERBOSE
  35. #if DBG
  36. #define TR_FATAL(Args) \
  37. TRACE(TL_FATAL, TM_RM, Args)
  38. #define TR_INFO(Args) \
  39. TRACE(TL_INFO, TM_RM, Args)
  40. #define TR_WARN(Args) \
  41. TRACE(TL_WARN,TM_RM, Args)
  42. #define TR_VERB(Args) \
  43. TRACE(TL_VERB, TM_RM, Args)
  44. #define ENTER(_Name, _locid) \
  45. char *dbg_func_name = (_Name); \
  46. UINT dbg_func_locid = (_locid);
  47. #define EXIT()
  48. // ASSERT checks caller's assertion expression and if false, prints a kernel
  49. // debugger message and breaks.
  50. //
  51. #undef ASSERT
  52. #define ASSERT(x) \
  53. { \
  54. if (!(x)) \
  55. { \
  56. DbgPrint( "EPVC: !ASSERT( %s ) L:%d,F:%s\n", \
  57. #x, __LINE__, __FILE__ ); \
  58. DbgBreakPoint(); \
  59. } \
  60. }
  61. #define ASSERTEX(x, ctxt) \
  62. { \
  63. if (!(x)) \
  64. { \
  65. DbgPrint( "Epvc: !ASSERT( %s ) C:0x%p L:%d,F:%s\n", \
  66. #x, (ctxt), __LINE__, __FILE__ ); \
  67. DbgBreakPoint(); \
  68. } \
  69. }
  70. //
  71. // DbgMark does nothing useful. But it is convenient to insert DBGMARK in
  72. // places in your code while debugging, and set a breakpoint on DbgMark, so that
  73. // the debugger will stop at the places you inserted DBGMARK. It's a bit more
  74. // flexible than inserting a hardcoded DbgBreakPoint.
  75. //
  76. void DbgMark(UINT Luid);
  77. #define DBGMARK(_Luid) DbgMark(_Luid)
  78. #define DBGSTMT(_stmt) _stmt
  79. #define RETAILASSERTEX ASSERTEX
  80. #define RETAILASSERT ASSERT
  81. // TRACE0 is like TRACE, except that it doesn't print the prefix.
  82. //
  83. #define TRACE0(ulLevel, Args) \
  84. { \
  85. if (ulLevel <= g_ulTraceLevel && (g_ulTraceMask & TM_CURRENT)) \
  86. { \
  87. DbgPrint Args; \
  88. } \
  89. }
  90. #else // !DBG
  91. #define TR_FATAL(Args)
  92. #define TR_INFO(Args)
  93. #define TR_WARN(Args)
  94. #define TR_VERB(Args)
  95. // Debug macros compile out of non-DBG builds.
  96. //
  97. #undef ASSERT
  98. #define ASSERT(x)
  99. #define ASSERTEX(x, ctxt)
  100. #define ENTER(_Name, _locid)
  101. #define EXIT()
  102. #define DBGMARK(_Luid) (0)
  103. #define DBGSTMT(_stmt)
  104. #define RETAILASSERT(x) \
  105. { \
  106. if (!(x)) \
  107. { \
  108. DbgPrint( "EPVC: !RETAILASSERT( %s ) L:%d,F:%s\n", \
  109. #x, __LINE__, __FILE__ ); \
  110. DbgBreakPoint(); \
  111. } \
  112. }
  113. #define RETAILASSERTEX(x, ctxt) \
  114. { \
  115. if (!(x)) \
  116. { \
  117. DbgPrint( "EPVC: !RETAILASSERT( %s ) C:0x%p L:%d,F:%s\n",\
  118. #x, (ctxt), __LINE__, __FILE__ ); \
  119. DbgBreakPoint(); \
  120. } \
  121. }
  122. #endif
  123. #if BINARY_COMPATIBLE
  124. #define ASSERT_PASSIVE() (0)
  125. #else // !BINARY_COMPATIBLE
  126. #define ASSERT_PASSIVE() \
  127. ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL)
  128. #endif // !BINARY_COMPATIBLE
  129. //-----------------------------------------------------------------------------
  130. // Prototypes
  131. //-----------------------------------------------------------------------------
  132. VOID
  133. CheckList(
  134. IN LIST_ENTRY* pList,
  135. IN BOOLEAN fShowLinks );
  136. VOID
  137. Dump(
  138. CHAR* p,
  139. ULONG cb,
  140. BOOLEAN fAddress,
  141. ULONG ulGroup );
  142. VOID
  143. DumpLine(
  144. CHAR* p,
  145. ULONG cb,
  146. BOOLEAN fAddress,
  147. ULONG ulGroup );