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.

154 lines
4.9 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. kernel mode only
  11. Notes:
  12. Revision History:
  13. --*/
  14. #ifndef __MYDEBUG__
  15. #define __MYDEBUG__
  16. //
  17. // Driver specific difinition
  18. //
  19. #define NAME_DRIVER "USBscan.SYs: " // Prefix of output message. (Should be driver name)
  20. #define NAME_POOLTAG 'UITS' // Pool tag for this driver.
  21. #define MAXNUM_POOL 100 // Maximum number of pool. (# of alloc - # of free)
  22. #define MAX_DUMPSIZE 1024 // Maximum bytes to dump.
  23. //
  24. // Defines
  25. //
  26. #define REG_DEBUGLEVEL L"DebugTraceLevel"
  27. #define MAX_TEMPBUF 256
  28. // Bit mask for trace level and flags
  29. #define BITMASK_TRACE_LEVEL 0x0000000f
  30. #define BITMASK_TRACE_FLAG 0x00000ff0
  31. #define BITMASK_DEBUG_FLAG 0x0000f000
  32. // Basic trace level
  33. #define NO_TRACE 0 // Shows nothing.
  34. #define MIN_TRACE 1 // Shows only error or warning.
  35. #define MAX_TRACE 2 // Shows progress and status.
  36. #define ULTRA_TRACE 3 // Shows progress and status in retail.
  37. #define NEVER_TRACE 4 // Never show this unless specific bit is set.
  38. // Trace flag to enable specific message spew. (1=on)
  39. #define TRACE_FLAG_PROC 0x10 // Show message when entering process.(1=on)
  40. #define TRACE_FLAG_RET 0x20 // Show message when leaving process.(1=on)
  41. #define TRACE_FLAG_DUMP_READ 0x40 // Show user buffer when read.
  42. #define TRACE_FLAG_DUMP_WRITE 0x80 // Show user buffer when write.
  43. // Conbination of trace level and flag.
  44. #define TRACE_PROC_ENTER ULTRA_TRACE | TRACE_FLAG_PROC // Entering procedure.
  45. #define TRACE_PROC_LEAVE ULTRA_TRACE | TRACE_FLAG_RET // Leaving procedure.
  46. #define TRACE_CRITICAL MIN_TRACE // Critical error. Spew always.
  47. #define TRACE_ERROR MIN_TRACE // Error.
  48. #define TRACE_WARNING MIN_TRACE // Possible wrong behavior.
  49. //#define TRACE_DUMP_DATA NEVER_TRACE | TRACE_FLAG_DUMP // Dump transaction data.
  50. #define TRACE_DEVICE_DATA MAX_TRACE // Show device data.
  51. #define TRACE_STATUS MAX_TRACE // Show status.
  52. // Debug flag to enable/disable DEBUG_BREAKPOINT()
  53. #define DEBUG_FLAG_DISABLE 0x1000 // Disable DEBUG_BREAK. (1=disable)
  54. #define DEBUG_PROC_BREAK 0x2000 // Stop at the beginning of each procedure.
  55. //
  56. // Macro
  57. //
  58. #if DBG
  59. //
  60. // Macro for debug output
  61. //
  62. // Note: If trace level is higher than DebugTraceLevel or specific bit is set,
  63. // debug message will be shown.
  64. //
  65. extern ULONG DebugTraceLevel;
  66. #define DebugTrace(_t_, _x_) { \
  67. if ( ((DebugTraceLevel & BITMASK_TRACE_LEVEL) >= (_t_ & BITMASK_TRACE_LEVEL )) || \
  68. (DebugTraceLevel & BITMASK_TRACE_FLAG & (_t_)) ) { \
  69. DbgPrint(NAME_DRIVER); \
  70. DbgPrint _x_ ; \
  71. } \
  72. if( (DebugTraceLevel & DEBUG_PROC_BREAK & (_t_)) && \
  73. (DebugTraceLevel & TRACE_FLAG_PROC) ) { \
  74. DEBUG_BREAKPOINT(); \
  75. } \
  76. }
  77. //
  78. // Macro for BreakPoint
  79. //
  80. #define DEBUG_BREAKPOINT() { \
  81. if (DebugTraceLevel & DEBUG_FLAG_DISABLE) { \
  82. DbgPrint(NAME_DRIVER); \
  83. DbgPrint("*** Hit DEBUG_BREAKPOINT ***\n"); \
  84. } else { \
  85. DbgBreakPoint(); \
  86. } \
  87. }
  88. #else // DBG
  89. #define DEBUG_BREAKPOINT()
  90. #define DebugTrace(_t_, _x_)
  91. #endif // DBG
  92. //
  93. // Prototypes
  94. //
  95. PVOID
  96. MyAllocatePool(
  97. IN POOL_TYPE PoolType,
  98. IN ULONG ulNumberOfBytes
  99. );
  100. VOID
  101. MyFreePool(
  102. IN PVOID pvAddress
  103. );
  104. VOID
  105. MyDebugInit(
  106. IN PUNICODE_STRING pRegistryPath
  107. );
  108. VOID
  109. MyDumpMemory(
  110. PUCHAR pDumpBuffer,
  111. ULONG dwSize,
  112. BOOLEAN bRead
  113. );
  114. #endif // __MYDEBUG__