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.

157 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. mp_dbg.h
  5. Abstract:
  6. Debug definitions and macros
  7. Revision History:
  8. Who When What
  9. -------- -------- ----------------------------------------------
  10. DChen 11-01-99 created
  11. Notes:
  12. --*/
  13. #ifndef _MP_DBG_H
  14. #define _MP_DBG_H
  15. //
  16. // Message verbosity: lower values indicate higher urgency
  17. //
  18. #define MP_OFF 0
  19. #define MP_ERROR 1
  20. #define MP_WARN 2
  21. #define MP_TRACE 3
  22. #define MP_INFO 4
  23. #define MP_LOUD 5
  24. // Define a macro so DbgPrint can work on win9x, 32-bit/64-bit NT's
  25. #ifdef _WIN64
  26. #define PTR_FORMAT "%p"
  27. #else
  28. #define PTR_FORMAT "%x"
  29. #endif
  30. #if DBG
  31. extern ULONG MPDebugLevel;
  32. #define DBGPRINT(Level, Fmt) \
  33. { \
  34. if (Level <= MPDebugLevel) \
  35. { \
  36. DbgPrint(NIC_DBG_STRING); \
  37. DbgPrint Fmt; \
  38. } \
  39. }
  40. #define DBGPRINT_RAW(Level, Fmt) \
  41. { \
  42. if (Level <= MPDebugLevel) \
  43. { \
  44. DbgPrint Fmt; \
  45. } \
  46. }
  47. #define DBGPRINT_S(Status, Fmt) \
  48. { \
  49. ULONG dbglevel; \
  50. if(Status == NDIS_STATUS_SUCCESS || Status == NDIS_STATUS_PENDING) dbglevel = MP_TRACE; \
  51. else dbglevel = MP_ERROR; \
  52. DBGPRINT(dbglevel, Fmt); \
  53. }
  54. #define DBGPRINT_UNICODE(Level, UString) \
  55. { \
  56. if (Level <= MPDebugLevel) \
  57. { \
  58. DbgPrint(NIC_DBG_STRING); \
  59. mpDbgPrintUnicodeString(UString); \
  60. } \
  61. }
  62. #undef ASSERT
  63. #define ASSERT(x) if(!(x)) { \
  64. DBGPRINT(MP_ERROR, ("Assertion failed: %s:%d %s\n", __FILE__, __LINE__, #x)); \
  65. DbgBreakPoint(); }
  66. //
  67. // The MP_ALLOCATION structure stores all info about MPAuditAllocMem
  68. //
  69. typedef struct _MP_ALLOCATION
  70. {
  71. LIST_ENTRY List;
  72. ULONG Signature;
  73. ULONG FileNumber;
  74. ULONG LineNumber;
  75. ULONG Size;
  76. PVOID *Location; // where the returned pointer was put
  77. UINT Flags;
  78. union {
  79. ULONGLONG Alignment;
  80. UCHAR UserData;
  81. };
  82. } MP_ALLOCATION, *PMP_ALLOCATION;
  83. NDIS_STATUS MPAuditAllocMem(
  84. PVOID *pPointer,
  85. UINT Size,
  86. UINT Flags,
  87. NDIS_PHYSICAL_ADDRESS HighestAddr,
  88. ULONG FileNumber,
  89. ULONG LineNumber);
  90. NDIS_STATUS MPAuditAllocMemTag(
  91. PVOID *pPointer,
  92. UINT Size,
  93. ULONG FileNumber,
  94. ULONG LineNumber);
  95. VOID MPAuditFreeMem(
  96. PVOID Pointer,
  97. UINT Size,
  98. UINT Flags);
  99. VOID mpDbgPrintUnicodeString(
  100. IN PUNICODE_STRING UnicodeString);
  101. VOID
  102. Dump(
  103. CHAR* p,
  104. ULONG cb,
  105. BOOLEAN fAddress,
  106. ULONG ulGroup );
  107. #else // !DBG
  108. #define DBGPRINT(Level, Fmt)
  109. #define DBGPRINT_RAW(Level, Fmt)
  110. #define DBGPRINT_S(Status, Fmt)
  111. #define DBGPRINT_UNICODE(Level, UString)
  112. #define Dump(p,cb,fAddress,ulGroup)
  113. #undef ASSERT
  114. #define ASSERT(x)
  115. #endif // DBG
  116. VOID
  117. DumpLine(
  118. CHAR* p,
  119. ULONG cb,
  120. BOOLEAN fAddress,
  121. ULONG ulGroup );
  122. #endif // _MP_DBG_H