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.

159 lines
3.3 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. extern BOOLEAN MPInitDone;
  33. extern NDIS_SPIN_LOCK MPMemoryLock;
  34. #define DBGPRINT(Level, Fmt) \
  35. { \
  36. if (Level <= MPDebugLevel) \
  37. { \
  38. DbgPrint(NIC_DBG_STRING); \
  39. DbgPrint Fmt; \
  40. } \
  41. }
  42. #define DBGPRINT_RAW(Level, Fmt) \
  43. { \
  44. if (Level <= MPDebugLevel) \
  45. { \
  46. DbgPrint Fmt; \
  47. } \
  48. }
  49. #define DBGPRINT_S(Status, Fmt) \
  50. { \
  51. ULONG dbglevel; \
  52. if(Status == NDIS_STATUS_SUCCESS || Status == NDIS_STATUS_PENDING) dbglevel = MP_TRACE; \
  53. else dbglevel = MP_ERROR; \
  54. DBGPRINT(dbglevel, Fmt); \
  55. }
  56. #define DBGPRINT_UNICODE(Level, UString) \
  57. { \
  58. if (Level <= MPDebugLevel) \
  59. { \
  60. DbgPrint(NIC_DBG_STRING); \
  61. mpDbgPrintUnicodeString(UString); \
  62. } \
  63. }
  64. #undef ASSERT
  65. #define ASSERT(x) if(!(x)) { \
  66. DBGPRINT(MP_ERROR, ("Assertion failed: %s:%d %s\n", __FILE__, __LINE__, #x)); \
  67. DbgBreakPoint(); }
  68. //
  69. // The MP_ALLOCATION structure stores all info about MPAuditAllocMem
  70. //
  71. typedef struct _MP_ALLOCATION
  72. {
  73. LIST_ENTRY List;
  74. ULONG Signature;
  75. ULONG FileNumber;
  76. ULONG LineNumber;
  77. ULONG Size;
  78. PVOID *Location; // where the returned pointer was put
  79. UINT Flags;
  80. union {
  81. ULONGLONG Alignment;
  82. UCHAR UserData;
  83. };
  84. } MP_ALLOCATION, *PMP_ALLOCATION;
  85. NDIS_STATUS MPAuditAllocMem(
  86. PVOID *pPointer,
  87. UINT Size,
  88. UINT Flags,
  89. NDIS_PHYSICAL_ADDRESS HighestAddr,
  90. ULONG FileNumber,
  91. ULONG LineNumber);
  92. NDIS_STATUS MPAuditAllocMemTag(
  93. PVOID *pPointer,
  94. UINT Size,
  95. ULONG FileNumber,
  96. ULONG LineNumber);
  97. VOID MPAuditFreeMem(
  98. PVOID Pointer,
  99. UINT Size,
  100. UINT Flags);
  101. VOID mpDbgPrintUnicodeString(
  102. IN PUNICODE_STRING UnicodeString);
  103. VOID
  104. Dump(
  105. CHAR* p,
  106. ULONG cb,
  107. BOOLEAN fAddress,
  108. ULONG ulGroup );
  109. #else // !DBG
  110. #define DBGPRINT(Level, Fmt)
  111. #define DBGPRINT_RAW(Level, Fmt)
  112. #define DBGPRINT_S(Status, Fmt)
  113. #define DBGPRINT_UNICODE(Level, UString)
  114. #define Dump(p,cb,fAddress,ulGroup)
  115. #undef ASSERT
  116. #define ASSERT(x)
  117. #endif // DBG
  118. VOID
  119. DumpLine(
  120. CHAR* p,
  121. ULONG cb,
  122. BOOLEAN fAddress,
  123. ULONG ulGroup );
  124. #endif // _MP_DBG_H