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.

205 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1995-1998 Microsoft Corporation
  3. Module Name:
  4. RcaDebug.h
  5. Abstract:
  6. Debug macros for RCA
  7. Revision History:
  8. Who When What
  9. -------- -------- ----------------------------------------------
  10. rmachin 2-18-97 created -- after ArvindM's cmadebug.h
  11. JameelH 4-18-98 Cleanup
  12. Notes:
  13. --*/
  14. #ifndef _RCADebug__H
  15. #define _RCADebug__H
  16. //
  17. // Message verbosity: lower values indicate higher urgency
  18. //
  19. #define RCA_VERY_LOUD 10
  20. #define RCA_LOUD 8
  21. #define RCA_INFO 6
  22. #define RCA_WARNING 4
  23. #define RCA_ERROR 2
  24. #define RCA_LOCKS 1
  25. #define RCA_FATAL 0
  26. #ifdef PERF
  27. extern LARGE_INTEGER PerfTimeConnRequest;
  28. extern LARGE_INTEGER PerfTimeSetupSent;
  29. extern LARGE_INTEGER PerfTimeConnectReceived;
  30. extern LARGE_INTEGER PerfTimeConnConfirm;
  31. extern LARGE_INTEGER PerfTimeSetupReceived;
  32. extern LARGE_INTEGER PerfTimeConnIndication;
  33. extern LARGE_INTEGER PerfTimeConnResponse;
  34. extern LARGE_INTEGER PerfTimeConnectSent;
  35. extern LARGE_INTEGER PerfTimeFrequency;
  36. #endif // PERF
  37. extern ULONG g_ulHardcodeDataFormat;
  38. extern ULONG g_ulBufferSize;
  39. #if DBG
  40. #define CHECK_LOCK_COUNT(Count) \
  41. { \
  42. if ((INT)(Count) < 0) \
  43. { \
  44. DbgPrint("Lock Count %d is < 0! File %s, Line %d\n",\
  45. Count, __FILE__, __LINE__); \
  46. DbgBreakPoint(); \
  47. } \
  48. }
  49. #else
  50. #define CHECK_LOCK_COUNT(Count)
  51. #endif
  52. #if DBG
  53. extern INT RCADebugLevel; // the value here defines what the user wants to see
  54. // all messages with this urgency and lower are enabled
  55. #define RCADEBUGP(Level, Fmt) \
  56. { \
  57. if (Level <= RCADebugLevel) \
  58. { \
  59. DbgPrint("***RCA*** (%x, %d) ", \
  60. MODULE_NUMBER >> 16, __LINE__); \
  61. DbgPrint Fmt; \
  62. } \
  63. }
  64. #define RCADEBUGPSTOP(Level, Fmt) \
  65. { \
  66. RCADEBUGP(Level, Fmt); \
  67. DbgBreakPoint(); \
  68. }
  69. #define ACQUIRE_SPIN_LOCK(lock) \
  70. { \
  71. NdisAcquireSpinLock(lock); \
  72. if (RCADebugLevel == RCA_LOCKS) {\
  73. DbgPrint("LOCK %s (0x%x) ACQUIRED, OldIrql set to %d at module %x, line %d\n", #lock, lock, (lock)->OldIrql, MODULE_NUMBER >> 16, __LINE__); \
  74. }\
  75. }
  76. #define RELEASE_SPIN_LOCK(lock) \
  77. { \
  78. if (RCADebugLevel == RCA_LOCKS) {\
  79. DbgPrint("About to RELEASE LOCK %s (0x%x) and restore old IRQL %d\n", #lock, lock, (lock)->OldIrql);\
  80. } \
  81. NdisReleaseSpinLock(lock); \
  82. if (RCADebugLevel == RCA_LOCKS) {\
  83. DbgPrint("LOCK %s (0x%x) RELEASED at module %x, line %d\n", #lock, lock, MODULE_NUMBER >> 16, __LINE__);\
  84. } \
  85. }
  86. #define DPR_ACQUIRE_SPIN_LOCK(lock) \
  87. { \
  88. NdisDprAcquireSpinLock(lock); \
  89. if (RCADebugLevel == RCA_LOCKS) { \
  90. DbgPrint("LOCK %s (0x%x) ACQUIRED (DPC) at module %x, line %d\n", \
  91. #lock, lock, MODULE_NUMBER >> 16, __LINE__); \
  92. } \
  93. }
  94. #define DPR_RELEASE_SPIN_LOCK(lock) \
  95. { \
  96. NdisDprReleaseSpinLock(lock); \
  97. if (RCADebugLevel == RCA_LOCKS) {\
  98. DbgPrint("LOCK %s (0x%x) RELEASED (DPC) at module %x, line %d\n", \
  99. #lock, lock, MODULE_NUMBER >> 16, __LINE__); \
  100. } \
  101. }
  102. #ifdef PERF
  103. #define RCAAssert(exp)
  104. #else
  105. //#define RCAAssert(exp) PxAssert(exp)
  106. // For now, just defin this to nothing.
  107. #define RCAAssert(exp)
  108. #endif // PERF
  109. //#define RCAStructAssert(s, t) PxStructAssert(s, t)
  110. // For now, just define this to nothing.
  111. #define RCAStructAssert(s, t)
  112. #else
  113. //
  114. // No debug
  115. //
  116. #define RCADEBUGP(lev, stmt)
  117. #define RCAAssert(exp)
  118. #define RCAStructAssert(s, t)
  119. #define ACQUIRE_SPIN_LOCK(lock) NdisAcquireSpinLock(lock);
  120. #define RELEASE_SPIN_LOCK(lock) NdisReleaseSpinLock(lock);
  121. #define DPR_ACQUIRE_SPIN_LOCK(lock) NdisDprAcquireSpinLock(lock);
  122. #define DPR_RELEASE_SPIN_LOCK(lock) NdisDprReleaseSpinLock(lock);
  123. #endif // DBG
  124. #if DBG
  125. #undef AUDIT_MEM
  126. #define AUDIT_MEM 1
  127. #endif
  128. #if AUDIT_MEM
  129. //
  130. // Memory Allocation/Freeing Auditing:
  131. //
  132. //
  133. // The RCA_ALLOCATION structure stores all info about one CmaMemAlloc.
  134. //
  135. typedef struct _RCA_ALLOCATION
  136. {
  137. ULONG Signature;
  138. struct _RCA_ALLOCATION* Next;
  139. struct _RCA_ALLOCATION* Prev;
  140. ULONG FileNumber;
  141. ULONG LineNumber;
  142. ULONG Size;
  143. ULONG_PTR Location; // where the returned pointer was put
  144. UCHAR UserData;
  145. } RCA_ALLOCATION, *PRCA_ALLOCATION;
  146. #define RCA_MEMORY_SIGNATURE (ULONG)'FACR'
  147. extern
  148. PVOID
  149. RCAAuditAllocMem (
  150. IN PVOID pPointer,
  151. IN ULONG Size,
  152. IN ULONG FileNumber,
  153. IN ULONG LineNumber
  154. );
  155. extern
  156. VOID
  157. RCAAuditFreeMem(
  158. IN PVOID Pointer
  159. );
  160. #endif // AUDIT_MEM
  161. #endif // _RCADebug__H