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.

207 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. debug.h
  5. Abstract:
  6. Debug macros for NDISUIO
  7. Revision History:
  8. arvindm 04/11/2000 created based on rawwan.
  9. Notes:
  10. --*/
  11. #ifndef _NUIODEBUG__H
  12. #define _NUIODEBUG__H
  13. //
  14. // Message verbosity: lower values indicate higher urgency
  15. //
  16. #define DL_EXTRA_LOUD 20
  17. #define DL_VERY_LOUD 10
  18. #define DL_LOUD 8
  19. #define DL_INFO 6
  20. #define DL_WARN 4
  21. #define DL_ERROR 2
  22. #define DL_FATAL 0
  23. #if DBG_SPIN_LOCK
  24. typedef struct _NUIO_LOCK
  25. {
  26. ULONG Signature;
  27. ULONG IsAcquired;
  28. PKTHREAD OwnerThread;
  29. ULONG TouchedByFileNumber;
  30. ULONG TouchedInLineNumber;
  31. NDIS_SPIN_LOCK NdisLock;
  32. } NUIO_LOCK, *PNUIO_LOCK;
  33. #define NUIOL_SIG 'KCOL'
  34. extern NDIS_SPIN_LOCK ndisuioDbgLogLock;
  35. extern
  36. VOID
  37. ndisuioAllocateSpinLock(
  38. IN PNUIO_LOCK pLock,
  39. IN ULONG FileNumber,
  40. IN ULONG LineNumber
  41. );
  42. extern
  43. VOID
  44. ndisuioAcquireSpinLock(
  45. IN PNUIO_LOCK pLock,
  46. IN ULONG FileNumber,
  47. IN ULONG LineNumber
  48. );
  49. extern
  50. VOID
  51. ndisuioReleaseSpinLock(
  52. IN PNUIO_LOCK pLock,
  53. IN ULONG FileNumber,
  54. IN ULONG LineNumber
  55. );
  56. #define CHECK_LOCK_COUNT(Count) \
  57. { \
  58. if ((INT)(Count) < 0) \
  59. { \
  60. DbgPrint("Lock Count %d is < 0! File %s, Line %d\n",\
  61. Count, __FILE__, __LINE__); \
  62. DbgBreakPoint(); \
  63. } \
  64. }
  65. #else
  66. #define CHECK_LOCK_COUNT(Count)
  67. typedef NDIS_SPIN_LOCK NUIO_LOCK;
  68. typedef PNDIS_SPIN_LOCK PNUIO_LOCK;
  69. #endif // DBG_SPIN_LOCK
  70. #if DBG
  71. extern INT ndisuioDebugLevel;
  72. #define DEBUGP(lev, stmt) \
  73. { \
  74. if ((lev) <= ndisuioDebugLevel) \
  75. { \
  76. DbgPrint("Ndisuio: "); DbgPrint stmt; \
  77. } \
  78. }
  79. #define DEBUGPDUMP(lev, pBuf, Len) \
  80. { \
  81. if ((lev) <= ndisuioDebugLevel) \
  82. { \
  83. DbgPrintHexDump((PUCHAR)(pBuf), (ULONG)(Len)); \
  84. } \
  85. }
  86. #define NUIO_ASSERT(exp) \
  87. { \
  88. if (!(exp)) \
  89. { \
  90. DbgPrint("Ndisuio: assert " #exp " failed in" \
  91. " file %s, line %d\n", __FILE__, __LINE__); \
  92. DbgBreakPoint(); \
  93. } \
  94. }
  95. #define NUIO_SET_SIGNATURE(s, t)\
  96. (s)->t##_sig = t##_signature;
  97. #define NUIO_STRUCT_ASSERT(s, t) \
  98. if ((s)->t##_sig != t##_signature) \
  99. { \
  100. DbgPrint("ndisuio: assertion failure" \
  101. " for type " #t " at 0x%x in file %s, line %d\n", \
  102. (PUCHAR)s, __FILE__, __LINE__); \
  103. DbgBreakPoint(); \
  104. }
  105. //
  106. // Memory Allocation/Freeing Audit:
  107. //
  108. //
  109. // The NUIOD_ALLOCATION structure stores all info about one allocation
  110. //
  111. typedef struct _NUIOD_ALLOCATION {
  112. ULONG Signature;
  113. struct _NUIOD_ALLOCATION *Next;
  114. struct _NUIOD_ALLOCATION *Prev;
  115. ULONG FileNumber;
  116. ULONG LineNumber;
  117. ULONG Size;
  118. ULONG_PTR Location; // where the returned ptr was stored
  119. union
  120. {
  121. ULONGLONG Alignment;
  122. UCHAR UserData;
  123. };
  124. } NUIOD_ALLOCATION, *PNUIOD_ALLOCATION;
  125. #define NUIOD_MEMORY_SIGNATURE (ULONG)'CSII'
  126. extern
  127. PVOID
  128. ndisuioAuditAllocMem (
  129. PVOID pPointer,
  130. ULONG Size,
  131. ULONG FileNumber,
  132. ULONG LineNumber
  133. );
  134. extern
  135. VOID
  136. ndisuioAuditFreeMem(
  137. PVOID Pointer
  138. );
  139. extern
  140. VOID
  141. ndisuioAuditShutdown(
  142. VOID
  143. );
  144. extern
  145. VOID
  146. DbgPrintHexDump(
  147. PUCHAR pBuffer,
  148. ULONG Length
  149. );
  150. #else
  151. //
  152. // No debug
  153. //
  154. #define DEBUGP(lev, stmt)
  155. #define DEBUGPDUMP(lev, pBuf, Len)
  156. #define NUIO_ASSERT(exp)
  157. #define NUIO_SET_SIGNATURE(s, t)
  158. #define NUIO_STRUCT_ASSERT(s, t)
  159. #endif // DBG
  160. #endif // _NUIODEBUG__H