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.

194 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. sldebug.h
  5. Abstract:
  6. Debugging functions exported from the storlib library.
  7. Author:
  8. Matthew D Hendel (math) 24-Apr-2000
  9. Revision History:
  10. --*/
  11. #pragma once
  12. #undef ASSERT
  13. #undef VERIFY
  14. #undef ASSERTMSG
  15. #undef KdBreakPoint
  16. #undef DebugPrint
  17. #if !DBG
  18. #define DebugTrace(arg)
  19. #define DebugPrint(arg)
  20. #define DebugWarn(arg)
  21. #define ASSERT(arg)
  22. #define VERIFY(arg) (arg)
  23. #define ASSERTMSG(arg)
  24. #define KdBreakPoint()
  25. #define StorSetDebugPrefixAndId(Prefix,ComponentId)
  26. #define NYI()
  27. #define REVIEW()
  28. //
  29. // DbgFillMemory does nothing
  30. // in a free build.
  31. //
  32. #define DbgFillMemory(Ptr,Size,Fill)
  33. #else // DBG
  34. VOID
  35. vStorDebugPrintEx(
  36. IN ULONG Level,
  37. IN PCSTR Format,
  38. va_list arglist
  39. );
  40. VOID
  41. StorDebugTrace(
  42. IN PCSTR Format,
  43. ...
  44. );
  45. VOID
  46. StorDebugWarn(
  47. IN PCSTR Format,
  48. ...
  49. );
  50. VOID
  51. StorDebugPrint(
  52. IN PCSTR Format,
  53. ...
  54. );
  55. VOID
  56. StorSetDebugPrefixAndId(
  57. IN PCSTR Prefix,
  58. IN ULONG DebugId
  59. );
  60. #define DebugTrace(arg) StorDebugTrace arg
  61. #define DebugWarn(arg) StorDebugWarn arg
  62. #define DebugPrint(arg) StorDebugPrint arg
  63. //
  64. // On X86 use _asm int 3 instead of DbgBreakPoint because
  65. // it leaves us in same context frame as the break,
  66. // instead of a frame up that we have to step out of.
  67. //
  68. #if defined (_X86_)
  69. #define KdBreakPoint() _asm { int 3 }
  70. #else
  71. #define KdBreakPoint() DbgBreakPoint()
  72. #endif
  73. //++
  74. //
  75. // VOID
  76. // DbgFillMemory(
  77. // PVOID Destination,
  78. // SIZE_T Length,
  79. // UCHAR Fill
  80. // );
  81. //
  82. // Routine Description:
  83. //
  84. // In a checked build, DbgFillMemory expands to RtlFillMemory. In a free
  85. // build, it expands to nothing. Use DbgFillMemory to initialize structures
  86. // to invalid bit patterns before deallocating them.
  87. //
  88. // Return Value:
  89. //
  90. // None.
  91. //
  92. //--
  93. VOID
  94. INLINE
  95. DbgFillMemory(
  96. PVOID Destination,
  97. SIZE_T Length,
  98. UCHAR Fill
  99. )
  100. {
  101. RtlFillMemory (Destination, Length, Fill);
  102. }
  103. //
  104. // Use a different ASSERT macro than the vanilla DDK ASSERT.
  105. //
  106. BOOLEAN
  107. StorAssertHelper(
  108. PCHAR Expression,
  109. PCHAR File,
  110. ULONG Line,
  111. PBOOLEAN Ignore
  112. );
  113. //++
  114. //
  115. // VOID
  116. // ASSERT(
  117. // LOGICAL Expression
  118. // );
  119. //
  120. // Routine Description:
  121. //
  122. // The ASSERT improves upon the DDK's ASSERT macro in several ways.
  123. // In source mode, it breaks directly on the line where the assert
  124. // failed, instead of several frames up. Additionally, there is a
  125. // way to repeatedly ignore the assert.
  126. //
  127. // Return Value:
  128. //
  129. // None.
  130. //
  131. //--
  132. #define ASSERT(exp)\
  133. do { \
  134. static BOOLEAN Ignore = FALSE; \
  135. \
  136. if (!(exp)) { \
  137. BOOLEAN Break; \
  138. Break = StorAssertHelper (#exp, __FILE__, __LINE__, &Ignore); \
  139. if (!Ignore && Break) { \
  140. KdBreakPoint(); \
  141. } \
  142. } \
  143. } while (0)
  144. #define VERIFY(_x) ASSERT(_x)
  145. #define NYI() ASSERT (!"NYI")
  146. #define REVIEW()\
  147. {\
  148. DebugPrint (("***** REVIEW: This code needs to be reviewed." \
  149. " Source File %s, line %ld\n", \
  150. __FILE__, __LINE__)); \
  151. KdBreakPoint(); \
  152. }
  153. #define DBG_DEALLOCATED_FILL (0xDE)
  154. #define DBG_UNINITIALIZED_FILL (0xCE)
  155. #endif // DBG