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.

165 lines
4.7 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Module: debug.h
  4. //
  5. // Description:
  6. //
  7. //
  8. //@@BEGIN_MSINTERNAL
  9. // Development Team:
  10. // Mike McLaughlin
  11. //
  12. // History: Date Author Comment
  13. //
  14. //@@END_MSINTERNAL
  15. //---------------------------------------------------------------------------
  16. //
  17. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  18. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  19. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  20. // PURPOSE.
  21. //
  22. // Copyright (c) 1996-1999 Microsoft Corporation. All Rights Reserved.
  23. //
  24. //---------------------------------------------------------------------------
  25. //---------------------------------------------------------------------------
  26. // Constants and Macros
  27. //---------------------------------------------------------------------------
  28. #ifdef DEBUG
  29. #define STR_MODULENAME "sysaudio: "
  30. #endif
  31. #if defined(DEBUG) && defined(_X86_)
  32. #define Trap() {_asm {_emit 0xcc}}
  33. #else
  34. #define Trap()
  35. #endif
  36. #define AssertAligned(p) ASSERT((PtrToUlong(p) & 7) == 0)
  37. #ifdef DEBUG
  38. typedef struct _OBJECT_HEADER {
  39. union {
  40. struct {
  41. LONG PointerCount;
  42. LONG HandleCount;
  43. };
  44. LIST_ENTRY Entry;
  45. };
  46. POBJECT_TYPE Type;
  47. UCHAR NameInfoOffset;
  48. UCHAR HandleInfoOffset;
  49. UCHAR QuotaInfoOffset;
  50. UCHAR Flags;
  51. union {
  52. //POBJECT_CREATE_INFORMATION ObjectCreateInfo;
  53. PVOID QuotaBlockCharged;
  54. };
  55. PSECURITY_DESCRIPTOR SecurityDescriptor;
  56. QUAD Body;
  57. } OBJECT_HEADER, *POBJECT_HEADER;
  58. #define OBJECT_TO_OBJECT_HEADER( o ) \
  59. CONTAINING_RECORD( (o), OBJECT_HEADER, Body )
  60. extern "C" PEPROCESS KernelProcess;
  61. extern "C" int SYSAUDIOTraceLevel;
  62. #define DPF(n,sz) (n == MAXULONG ? dprintf(sz "\n") : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n") : 0))
  63. #define DPF1(n,sz,a) (n == MAXULONG ? dprintf(sz "\n", a) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n", a) : 0))
  64. #define DPF2(n,sz,a,b) (n == MAXULONG ? dprintf(sz "\n", a,b) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n", a,b) : 0))
  65. #define DPF3(n,sz,a,b,c) (n == MAXULONG ? dprintf(sz "\n", a,b,c) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n", a,b,c) : 0))
  66. #define DPF4(n,sz,a,b,c,d) (n == MAXULONG ? dprintf(sz "\n", a,b,c,d) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n",a,b,c,d) : 0))
  67. #define DPF5(n,sz,a,b,c,d,e) (n == MAXULONG ? dprintf(sz "\n", a,b,c,d,e) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n", a,b,c,d,e) : 0))
  68. #define DPF6(n,sz,a,b,c,d,e,f) (n == MAXULONG ? dprintf(sz "\n", a,b,c,d,e,f) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n", a,b,c,d,e,f) : 0))
  69. #define DPF7(n,sz,a,b,c,d,e,f,g) (n == MAXULONG ? dprintf(sz "\n", a,b,c,d,e,f,g) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n", a,b,c,d,e,f,g) : 0))
  70. #define DPF8(n,sz,a,b,c,d,e,f,g,h) (n == MAXULONG ? dprintf(sz "\n", a,b,c,d,e,f,g,h) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n", a,b,c,d,e,f,g,h) : 0))
  71. #define DPF9(n,sz,a,b,c,d,e,f,g,h,i) (n == MAXULONG ? dprintf(sz "\n", a,b,c,d,e,f,g,h,i) : (n <= SYSAUDIOTraceLevel ? DbgPrint(STR_MODULENAME sz "\n",a,b,c,d,e,f,g,h,i) : 0))
  72. #define AssertStatus(f) ASSERT(f == STATUS_SUCCESS)
  73. #define AssertFileObject(pfo) \
  74. ASSERT((pfo)->FsContext != NULL); \
  75. ASSERT(OBJECT_TO_OBJECT_HEADER(pfo)->PointerCount > 0);
  76. // Debug Levels
  77. //
  78. #define DBG_STATE 20
  79. #else
  80. #define DPF(n,sz)
  81. #define DPF1(n,sz,a)
  82. #define DPF2(n,sz,a,b)
  83. #define DPF3(n,sz,a,b,c)
  84. #define DPF4(n,sz,a,b,c,d)
  85. #define DPF5(n,sz,a,b,c,d,e)
  86. #define DPF6(n,sz,a,b,c,d,e,f)
  87. #define DPF7(n,sz,a,b,c,d,e,f,g)
  88. #define DPF8(n,sz,a,b,c,d,e,f,g,h)
  89. #define DPF9(n,sz,a,b,c,d,e,f,g,h,i)
  90. #define AssertKernelProcess
  91. #define AssertStatus(f) f
  92. #define AssertFileObject(pfo)
  93. #endif
  94. #ifdef DEBUG
  95. #define Assert(p) \
  96. (p)->m_Signature.DebugAssert()
  97. #define DefineSignature(s) \
  98. class CSignature \
  99. { \
  100. public: \
  101. CSignature() \
  102. { \
  103. m_dwSignature = s; \
  104. }; \
  105. ~CSignature() \
  106. { \
  107. m_dwSignature = 0x44414544; \
  108. }; \
  109. BOOL IsAssert() \
  110. { \
  111. return(m_dwSignature == s); \
  112. } \
  113. VOID DebugAssert() \
  114. { \
  115. ASSERT(IsAssert()); \
  116. }; \
  117. private: \
  118. ULONG m_dwSignature; \
  119. } m_Signature;
  120. #define DestroySignature() \
  121. m_Signature.~CSignature()
  122. #else
  123. #define Assert(p)
  124. #define DefineSignature(s)
  125. #define DestroySignature()
  126. #endif
  127. #ifdef DEBUG
  128. #ifndef _X86_
  129. #define dprintf DbgPrint
  130. #endif // _X86_
  131. #endif // DEBUG
  132. //---------------------------------------------------------------------------
  133. // End of File: debug.h
  134. //---------------------------------------------------------------------------