ksdebug.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * ksdebug.h
  3. *
  4. * This file is part of the ReactOS PSDK package.
  5. *
  6. * Contributors:
  7. * Created by Magnus Olsen.
  8. *
  9. * THIS SOFTWARE IS NOT COPYRIGHTED
  10. *
  11. * This source code is offered for use in the public domain. You may
  12. * use, modify or distribute it freely.
  13. *
  14. * This code is distributed in the hope that it will be useful but
  15. * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  16. * DISCLAIMED. This includes but is not limited to warranties of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. *
  19. */
  20. #include <evntrace.h>
  21. #if !defined(_KSDEBUG_)
  22. #define _KSDEBUG_
  23. #if !defined(REMIND)
  24. #define QUOTE(x) #x
  25. #define QQUOTE(y) QUOTE(y)
  26. #define REMIND(str) __FILE__ "(" QQUOTE(__LINE__) ") : " str
  27. #endif
  28. #if defined(__cplusplus)
  29. extern "C" {
  30. #endif
  31. #if (DBG)
  32. #if defined(IRPMJFUNCDESC)
  33. static const PCHAR IrpMjFuncDesc[] = {
  34. "IRP_MJ_CREATE",
  35. "IRP_MJ_CREATE_NAMED_PIPE",
  36. "IRP_MJ_CLOSE",
  37. "IRP_MJ_READ",
  38. "IRP_MJ_WRITE",
  39. "IRP_MJ_QUERY_INFORMATION",
  40. "IRP_MJ_SET_INFORMATION",
  41. "IRP_MJ_QUERY_EA",
  42. "IRP_MJ_SET_EA",
  43. "IRP_MJ_FLUSH_BUFFERS",
  44. "IRP_MJ_QUERY_VOLUME_INFORMATION",
  45. "IRP_MJ_SET_VOLUME_INFORMATION",
  46. "IRP_MJ_DIRECTORY_CONTROL",
  47. "IRP_MJ_FILE_SYSTEM_CONTROL",
  48. "IRP_MJ_DEVICE_CONTROL",
  49. "IRP_MJ_INTERNAL_DEVICE_CONTROL",
  50. "IRP_MJ_SHUTDOWN",
  51. "IRP_MJ_LOCK_CONTROL",
  52. "IRP_MJ_CLEANUP",
  53. "IRP_MJ_CREATE_MAILSLOT",
  54. "IRP_MJ_QUERY_SECURITY",
  55. "IRP_MJ_SET_SECURITY",
  56. "IRP_MJ_SET_POWER",
  57. "IRP_MJ_QUERY_POWER"
  58. };
  59. #endif /* defined(IRPMJFUNCDESC) */
  60. #endif /* DBG */
  61. #if defined(_NTDDK_)
  62. #define DEBUGLVL_BLAB TRACE_LEVEL_VERBOSE
  63. #define DEBUGLVL_VERBOSE TRACE_LEVEL_VERBOSE
  64. #define DEBUGLVL_TERSE TRACE_LEVEL_INFORMATION
  65. #define DEBUGLVL_ERROR TRACE_LEVEL_ERROR
  66. #define DEBUGLVL_WARNING TRACE_LEVEL_WARNING
  67. #define DEBUGLVL_INFO TRACE_LEVEL_INFORMATION
  68. #if (DBG)
  69. # if !defined( DEBUG_LEVEL )
  70. # if defined( DEBUG_VARIABLE )
  71. # if defined( KSDEBUG_INIT )
  72. ULONG DEBUG_VARIABLE = DEBUGLVL_TERSE;
  73. # else
  74. extern ULONG DEBUG_VARIABLE;
  75. # endif
  76. # else
  77. # define DEBUG_VARIABLE DEBUGLVL_TERSE
  78. # endif
  79. # else
  80. # if defined( DEBUG_VARIABLE )
  81. # if defined( KSDEBUG_INIT )
  82. ULONG DEBUG_VARIABLE = DEBUG_LEVEL;
  83. # else
  84. extern ULONG DEBUG_VARIABLE;
  85. # endif
  86. # else
  87. # define DEBUG_VARIABLE DEBUG_LEVEL
  88. # endif
  89. # endif
  90. #if (NTDDI_VERSION >= NTDDI_WINXP)
  91. # define _DbgPrintFEx(component, lvl, strings) { \
  92. if ((lvl) <= DEBUG_VARIABLE) { \
  93. DbgPrintEx(component, lvl, STR_MODULENAME); \
  94. DbgPrintEx(component, lvl, strings); \
  95. DbgPrintEx(component, lvl, "\n"); \
  96. if ((lvl) == DEBUGLVL_ERROR) { \
  97. DbgBreakPoint(); \
  98. } \
  99. } \
  100. }
  101. #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
  102. # define _DbgPrintF(lvl, strings) { \
  103. if (((lvl)==DEBUG_VARIABLE) || (lvl < DEBUG_VARIABLE)) { \
  104. DbgPrint(STR_MODULENAME); \
  105. DbgPrint##strings; \
  106. DbgPrint("\n"); \
  107. if ((lvl) == DEBUGLVL_ERROR) { \
  108. DbgBreakPoint(); \
  109. } \
  110. } \
  111. }
  112. #else /* ! DBG */
  113. #define _DbgPrintF(lvl, strings)
  114. #if (NTDDI_VERSION >= NTDDI_WINXP)
  115. #define _DbgPrintFEx(component, lvl, strings)
  116. #endif
  117. #endif /* DBG */
  118. #endif /* defined(_NTDDK_) */
  119. #if defined(__cplusplus)
  120. }
  121. #endif
  122. #endif /* _KSDEBUG_ */