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.

226 lines
4.7 KiB

  1. /****************************************************************************
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. DEBUGWDM.H
  5. Abstract:
  6. This header file is for debug and diagnostics for a WDM driver
  7. Environment:
  8. Kernel mode and user mode
  9. Notes:
  10. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  11. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  12. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  13. PURPOSE.
  14. Copyright (c) 1998 Microsoft Corporation. All Rights Reserved.
  15. Revision History:
  16. 12/23/97 : created
  17. Author:
  18. Tom Green
  19. ****************************************************************************/
  20. #ifndef __DEBUGWDM_H__
  21. #define __DEBUGWDM_H__
  22. // this makes it easy to hide static vars, make visible for debug
  23. #if DBG
  24. #define LOCAL
  25. #define GLOBAL
  26. #else
  27. #define LOCAL static
  28. #define GLOBAL
  29. #endif
  30. #ifdef POOL_TAGGING
  31. #undef ExAllocatePool
  32. #define ExAllocatePool(type, size) ExAllocatePoolWithTag(type, size, 'CBSU')
  33. #endif
  34. #if DBG
  35. #define DEBUG_TRACE1(_x_) { \
  36. if(Usbser_Debug_Trace_Level >= 1) \
  37. { \
  38. DbgPrint _x_ ; \
  39. } \
  40. }
  41. #define DEBUG_TRACE2(_x_) { \
  42. if(Usbser_Debug_Trace_Level >= 2) \
  43. { \
  44. DbgPrint("%s: ",DriverName); \
  45. DbgPrint _x_ ; \
  46. } \
  47. }
  48. #define DEBUG_TRACE3(_x_) { \
  49. if(Usbser_Debug_Trace_Level >= 3) \
  50. { \
  51. DbgPrint("%s: ",DriverName); \
  52. DbgPrint _x_ ; \
  53. } \
  54. }
  55. #define DEBUG_TRAP() DbgBreakPoint()
  56. #else
  57. #define DEBUG_TRACE1(_x_)
  58. #define DEBUG_TRACE2(_x_)
  59. #define DEBUG_TRACE3(_x_)
  60. #define DEBUG_TRAP() DbgBreakPoint()
  61. #endif // DBG
  62. // these macros are for logging things, avoid subroutine call
  63. // if they are disabled (number of entries = 0)
  64. #ifdef PROFILING_ENABLED
  65. // need these for creating macros for speed in logging and history
  66. extern GLOBAL ULONG IRPHistorySize;
  67. extern GLOBAL ULONG DebugPathSize;
  68. extern GLOBAL ULONG ErrorLogSize;
  69. #define DEBUG_LOG_IRP_HIST(dobj, pirp, majfunc, buff, bufflen) { \
  70. if(IRPHistorySize) \
  71. Debug_LogIrpHist(dobj, pirp, majfunc, buff, bufflen); \
  72. }
  73. #define DEBUG_LOG_PATH(path) { \
  74. if(DebugPathSize) \
  75. Debug_LogPath(path); \
  76. }
  77. #define DEBUG_LOG_ERROR(status) { \
  78. if(ErrorLogSize) \
  79. Debug_LogError(status); \
  80. }
  81. #define DEBUG_ASSERT(msg, exp) { \
  82. if(!(exp)) \
  83. Debug_Assert(#exp, __FILE__, __LINE__, msg); \
  84. }
  85. #define DEBUG_OPEN Debug_OpenWDMDebug
  86. #define DEBUG_CLOSE Debug_CloseWDMDebug
  87. #define DEBUG_MEMALLOC Debug_MemAlloc
  88. #define DEBUG_MEMFREE Debug_MemFree
  89. #define DEBUG_CHECKMEM Debug_CheckAllocations
  90. // prototypes
  91. NTSTATUS
  92. Debug_OpenWDMDebug(VOID);
  93. VOID
  94. Debug_CloseWDMDebug(VOID);
  95. NTSTATUS
  96. Debug_SizeIRPHistoryTable(IN ULONG Size);
  97. NTSTATUS
  98. Debug_SizeDebugPathHist(IN ULONG Size);
  99. NTSTATUS
  100. Debug_SizeErrorLog(ULONG Size);
  101. VOID
  102. Debug_LogIrpHist(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp,
  103. IN ULONG MajorFunction, IN PVOID IoBuffer, IN ULONG BufferLen);
  104. VOID
  105. Debug_LogPath(IN PCHAR Path);
  106. VOID
  107. Debug_LogError(IN NTSTATUS NtStatus);
  108. VOID
  109. Debug_Trap(IN PCHAR TrapCause);
  110. VOID
  111. Debug_Assert(IN PVOID FailedAssertion, IN PVOID FileName, IN ULONG LineNumber,
  112. IN PCHAR Message);
  113. ULONG
  114. Debug_ExtractAttachedDevices(IN PDRIVER_OBJECT DriverObject, OUT PCHAR Buffer, IN ULONG BuffSize);
  115. ULONG
  116. Debug_GetDriverInfo(OUT PCHAR Buffer, IN ULONG BuffSize);
  117. ULONG
  118. Debug_ExtractIRPHist(OUT PCHAR Buffer, IN ULONG BuffSize);
  119. ULONG
  120. Debug_ExtractPathHist(OUT PCHAR Buffer, IN ULONG BuffSize);
  121. ULONG
  122. Debug_ExtractErrorLog(OUT PCHAR Buffer, IN ULONG BuffSize);
  123. ULONG
  124. Debug_DumpDriverLog(IN PDEVICE_OBJECT DeviceObject, OUT PCHAR Buffer, IN ULONG BuffSize);
  125. PCHAR
  126. Debug_TranslateStatus(IN NTSTATUS NtStatus);
  127. PCHAR
  128. Debug_TranslateIoctl(IN LONG Ioctl);
  129. #else
  130. VOID
  131. Debug_CheckAllocations(VOID);
  132. PVOID
  133. Debug_MemAlloc(IN POOL_TYPE PoolType, IN ULONG NumberOfBytes);
  134. VOID
  135. Debug_MemFree(IN PVOID pMem);
  136. #define DEBUG_LOG_IRP_HIST(dobj, pirp, majfunc, buff, bufflen)
  137. #define DEBUG_LOG_PATH(path)
  138. #define DEBUG_LOG_ERROR(status)
  139. #define DEBUG_ASSERT(msg, exp)
  140. #define DEBUG_OPEN() STATUS_SUCCESS
  141. #define DEBUG_CLOSE()
  142. #define DEBUG_MEMALLOC Debug_MemAlloc
  143. #define DEBUG_MEMFREE Debug_MemFree
  144. #define DEBUG_CHECKMEM Debug_CheckAllocations
  145. #endif // PROFILING_ENABLED
  146. #endif // __DEBUGWDM_H__
  147.