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.

184 lines
6.1 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1999 - 1999
  3. Module Name:
  4. debug.h
  5. Abstract:
  6. Prototypes and definitions for debugging.
  7. Author:
  8. Keisuke Tsuchida (KeisukeT)
  9. Environment:
  10. user mode only
  11. Notes:
  12. Revision History:
  13. --*/
  14. #ifndef __MYDEBUG__
  15. #define __MYDEBUG__
  16. //
  17. // Include custom debug header.
  18. //
  19. #include <windows.h>
  20. #include <coredbg.h>
  21. //
  22. // Driver specific definition
  23. //
  24. #define NAME_DRIVER TEXT("STI_CI.DLL: ") // Prefix of output message. (Should be driver name)
  25. #define REGVAL_DEBUGLEVEL TEXT("STICIDebugLevel") // Debug trace level for this binary.
  26. //
  27. // Defines
  28. //
  29. #define MAX_TEMPBUF 256
  30. // Bit mask for trace level and flags
  31. #define BITMASK_TRACE_LEVEL 0x0000000f
  32. #define BITMASK_TRACE_FLAG 0x00000ff0
  33. #define BITMASK_DEBUG_FLAG 0x0000f000
  34. // Basic trace level
  35. #define NO_TRACE 0 // Shows nothing.
  36. #define MIN_TRACE 1 // Shows only error or warning.
  37. #define MAX_TRACE 2 // Shows progress and status.
  38. #define ULTRA_TRACE 3 // Shows progress and status in retail.
  39. #define NEVER_TRACE 4 // Never show this unless specific bit is set.
  40. // Trace flag to enable specific message spew. (1=on)
  41. #define TRACE_FLAG_PROC 0x010 // Show message when entering process.(1=on)
  42. #define TRACE_FLAG_RET 0x020 // Show message when leaving process.(1=on)
  43. #define TRACE_FLAG_DUMP 0x040 // Show transaction data dump.
  44. #define TRACE_IGNORE_TAG 0x080 // Disable tag check (1=disabled).
  45. #define TRACE_MESSAGEBOX 0x100 // Show MessageBox instead of debug spew.
  46. // Conbination of trace level and flag.
  47. #define TRACE_PROC_ENTER ULTRA_TRACE | TRACE_FLAG_PROC // Entering procedure.
  48. #define TRACE_PROC_LEAVE ULTRA_TRACE | TRACE_FLAG_RET // Leaving procedure.
  49. #define TRACE_CRITICAL MIN_TRACE // Critical error. Spew always.
  50. #define TRACE_ERROR MIN_TRACE // Error.
  51. #define TRACE_WARNING MIN_TRACE // Possible wrong behavior.
  52. #define TRACE_DUMP_DATA NEVER_TRACE | TRACE_FLAG_DUMP // Dump transaction data.
  53. #define TRACE_DEVICE_DATA MAX_TRACE // Show device data.
  54. #define TRACE_STATUS MAX_TRACE // Show status.
  55. // Debug flag to enable/disable DEBUG_BREAKPOINT()
  56. #define DEBUG_FLAG_DISABLE 0x1000 // Disable DEBUG_BREAK. (1=disable)
  57. #define DEBUG_PROC_BREAK 0x2000 // Stop at the beginning of each procedure.
  58. //
  59. // Prototypes
  60. //
  61. VOID
  62. MyDebugInit(
  63. VOID
  64. );
  65. void __cdecl
  66. DbgPrint(
  67. LPSTR lpstrMessage,
  68. ...
  69. );
  70. void __cdecl
  71. DbgPrint(
  72. LPWSTR lpstrMessage,
  73. ...
  74. );
  75. //
  76. // Macro
  77. //
  78. #define DebugTrace(_t_, _x_) { \
  79. if((TRACE_ERROR & BITMASK_TRACE_LEVEL) == (_t_ & BITMASK_TRACE_LEVEL )){ \
  80. DBG_ERR(_x_); \
  81. } else if((TRACE_WARNING & BITMASK_TRACE_LEVEL) == (_t_ & BITMASK_TRACE_LEVEL )){ \
  82. DBG_WRN(_x_); \
  83. } else if((TRACE_STATUS & BITMASK_TRACE_LEVEL) == (_t_ & BITMASK_TRACE_LEVEL )){ \
  84. DBG_TRC(_x_); \
  85. } else if( (_t_ & TRACE_FLAG_PROC) || (_t_ & TRACE_FLAG_RET )){ \
  86. DBG_TRC(_x_); \
  87. } \
  88. }
  89. #if DBG
  90. //
  91. // Macro for BreakPoint
  92. //
  93. #define DEBUG_BREAKPOINT() { \
  94. if (DebugTraceLevel & DEBUG_FLAG_DISABLE) { \
  95. DbgPrint(NAME_DRIVER); \
  96. DbgPrint("*** Hit DEBUG_BREAKPOINT ***\r\n"); \
  97. } else { \
  98. DebugBreak(); \
  99. } \
  100. }
  101. #else // DBG
  102. #define DEBUG_BREAKPOINT()
  103. #endif // DBG
  104. //
  105. // Original debug macro.
  106. //
  107. #if ORIGINAL_DEBUG
  108. #if DBG
  109. //
  110. // Macro for debug output
  111. //
  112. // Note: If trace level is higher than DebugTraceLevel or specific bit is set,
  113. // debug message will be shown.
  114. //
  115. #define DebugTrace(_t_, _x_) { \
  116. if ( ((DebugTraceLevel & BITMASK_TRACE_LEVEL) >= (_t_ & BITMASK_TRACE_LEVEL )) || \
  117. (DebugTraceLevel & BITMASK_TRACE_FLAG & (_t_)) ) { \
  118. DbgPrint(NAME_DRIVER); \
  119. DbgPrint _x_ ; \
  120. } \
  121. if( (DebugTraceLevel & DEBUG_PROC_BREAK & (_t_)) && \
  122. (DebugTraceLevel & TRACE_FLAG_PROC) ) { \
  123. DEBUG_BREAKPOINT(); \
  124. } \
  125. }
  126. #else // DBG
  127. #define DebugTrace(_t_, _x_)
  128. #endif // DBG
  129. #endif // ORIGINAL_DEBUG
  130. //
  131. // Obsolete
  132. //
  133. #define Report(_x_)
  134. #endif // __MYDEBUG__