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.

245 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1997 FORE Systems, Inc.
  3. Copyright (c) 1997 Microsoft Corporation
  4. Module Name:
  5. debug.h
  6. Abstract:
  7. This file contains debugging support declarations.
  8. Author:
  9. Larry Cleeton, FORE Systems (v-lcleet@microsoft.com, lrc@fore.com)
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #ifndef __ATMLANE_DEBUG_H
  15. #define __ATMLANE_DEBUG_H
  16. #if DBG
  17. #define DBG_OUTBUF_SIZE 128
  18. extern ULONG DbgVerbosity;
  19. extern ULONG DbgLogSize;
  20. #if DBG_TRACE
  21. extern TRACELOG TraceLog;
  22. extern PUCHAR pTraceLogSpace;
  23. #endif
  24. struct _string_table {
  25. PUCHAR string;
  26. ULONG value;
  27. };
  28. extern struct _string_table oid_string_table[];
  29. extern struct _string_table irp_string_table[];
  30. #define DBGP(x) DbgOut x
  31. extern
  32. VOID
  33. DbgOut(ULONG Level, PUCHAR Message, ...);
  34. extern
  35. PUCHAR
  36. UnicodeToString(PUNICODE_STRING unicodeString);
  37. extern
  38. PUCHAR
  39. MacAddrToString(PVOID In);
  40. extern
  41. PUCHAR
  42. AtmAddrToString(PVOID In);
  43. extern
  44. PUCHAR
  45. OidToString(ULONG Oid);
  46. extern
  47. PUCHAR
  48. IrpToString(ULONG Irp);
  49. VOID
  50. DbgPrintHexDump(
  51. IN ULONG Level,
  52. IN PUCHAR pBuffer,
  53. IN ULONG Length
  54. );
  55. #define STRUCT_ASSERT(s, t) \
  56. if ((s)->t##_sig != t##_signature) \
  57. { \
  58. DbgPrint("Structure assertion failure at %p for type " #t \
  59. " in file %s, line %d\n", s, __FILE__, __LINE__);\
  60. DbgBreakPoint(); \
  61. }
  62. #if DBG_TRACE
  63. #define TRACELOGWRITE(x) TraceLogWrite x
  64. #define TRACELOGWRITEPKT(x) TraceLogWritePkt x
  65. extern
  66. VOID
  67. TraceLogWritePkt(
  68. IN PTRACELOG pTraceLog,
  69. IN PNDIS_PACKET pNdisPacket
  70. );
  71. #else
  72. #define TRACELOGWRITE(x)
  73. #define TRACELOGWRITEPKT(x)
  74. #endif
  75. #if MYASSERT
  76. #undef ASSERT
  77. #define ASSERT( exp ) \
  78. if (!(exp)) \
  79. { \
  80. DbgPrint("Assertion Failed ("#exp") in file %s line %d\n", __FILE__, __LINE__); \
  81. DbgBreakPoint(); \
  82. }
  83. #endif
  84. #else
  85. #define DBGP(x)
  86. #define MacAddrToString(x)
  87. #define AtmAddrToString(x)
  88. #define OidToString(x)
  89. #define DbgPrintHexDump(x)
  90. #define STRUCT_ASSERT(s, t)
  91. #define TRACELOGWRITE(x)
  92. #define TRACELOGWRITEPKT(x)
  93. #endif
  94. #ifdef TRACE
  95. #define TRACEIN(x) DBGP((5, "--> "#x"\n"))
  96. #define TRACEOUT(x) DBGP((5, "<-- "#x"\n"))
  97. #else
  98. #define TRACEIN(x) {}
  99. #define TRACEOUT(x) {}
  100. #endif
  101. #if DEBUG_IRQL
  102. #define GET_ENTRY_IRQL(_Irql) \
  103. _Irql = KeGetCurrentIrql()
  104. #define CHECK_EXIT_IRQL(_EntryIrql) \
  105. { \
  106. KIRQL _ExitIrql; \
  107. _ExitIrql = KeGetCurrentIrql(); \
  108. if (_ExitIrql != _EntryIrql) \
  109. { \
  110. DbgPrint("File %s, Line %d, Exit IRQ %d != Entry IRQ %d\n", \
  111. __FILE__, __LINE__, _ExitIrql, _EntryIrql); \
  112. DbgBreakPoint(); \
  113. } \
  114. }
  115. #else
  116. #define GET_ENTRY_IRQL(x)
  117. #define CHECK_EXIT_IRQL(x)
  118. #endif // DEBUG_IRQL
  119. #if DEBUG_SPIN_LOCK
  120. #define LOCK_FILE_NAME_LEN 48
  121. typedef struct _ATMLANE_LOCK
  122. {
  123. ULONG Signature;
  124. ULONG IsAcquired;
  125. PKTHREAD OwnerThread;
  126. UCHAR TouchedByFileName[LOCK_FILE_NAME_LEN];
  127. ULONG TouchedInLineNumber;
  128. NDIS_SPIN_LOCK NdisLock;
  129. } ATMLANE_LOCK, *PATMLANE_LOCK;
  130. #define ATMLANE_LOCK_SIG 'KCOL'
  131. extern ULONG SpinLockInitDone;
  132. extern NDIS_SPIN_LOCK LockLock;
  133. extern
  134. VOID
  135. AtmLaneAllocateSpinLock(
  136. IN PATMLANE_LOCK pLock,
  137. IN PUCHAR String,
  138. IN PUCHAR FileName,
  139. IN ULONG LineNumber
  140. );
  141. extern
  142. VOID
  143. AtmLaneAcquireSpinLock(
  144. IN PATMLANE_LOCK pLock,
  145. IN PUCHAR String,
  146. IN PUCHAR FileName,
  147. IN ULONG LineNumber
  148. );
  149. extern
  150. VOID
  151. AtmLaneReleaseSpinLock(
  152. IN PATMLANE_LOCK pLock,
  153. IN PUCHAR String,
  154. IN PUCHAR FileName,
  155. IN ULONG LineNumber
  156. );
  157. extern
  158. VOID
  159. AtmLaneFreeSpinLock(
  160. IN PATMLANE_LOCK pLock,
  161. IN PUCHAR String,
  162. IN PUCHAR FileName,
  163. IN ULONG LineNumber
  164. );
  165. #else
  166. #define ATMLANE_LOCK NDIS_SPIN_LOCK
  167. #define PATMLANE_LOCK PNDIS_SPIN_LOCK
  168. #endif // DEBUG_SPIN_LOCK
  169. #endif // __ATMLANE_DEBUG_H