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.

168 lines
4.7 KiB

  1. //**************************************************************************
  2. //
  3. // DEBUG.H -- X2 Gaming Project
  4. //
  5. // Version 4.XX
  6. //
  7. // Copyright (c) 1998 Microsoft Corporation. All rights reserved.
  8. //
  9. // @doc
  10. // @topic DEBUG.H | Global definitions for debugging output
  11. //**************************************************************************
  12. #ifndef DEBUG_H
  13. #define DEBUG_H
  14. //---------------------------------------------------------------------------
  15. // Definitions
  16. //---------------------------------------------------------------------------
  17. //
  18. // DEBUG output types (NOT LEVELS)
  19. //
  20. #define DBG_ENTRY 0x00000001 //Traceout on entry to function
  21. #define DBG_EXIT 0x00000002 //Traceout on exit from function
  22. #define DBG_WARN 0x00000004 //Traceout signifying a warning (or informational)
  23. #define DBG_TRACE 0x00000008 //Traceout signifying a warning (or informational)
  24. #define DBG_ERROR 0x00000010 //Traceout signifying an error
  25. #define DBG_CRITICAL 0x00000020 //Traceout signifying a critical error
  26. #define DBG_RT_ENTRY 0x00000040 //Traceout on entry to function (TIME CRITICAL CODE)
  27. #define DBG_RT_EXIT 0x00000080 //Traceout on exit from function (TIME CRITICAL CODE)
  28. #define DBG_RT_WARN 0x00000100 //Traceout signifying a warning (or informational) (TIME CRITICAL CODE)
  29. // Combos of above for setting warning levels easily
  30. #define DBG_NOT_RT 0x0000003F //Traceout all above except RT codes
  31. #define DBG_RT 0x000001C0 //Traceout RT codes
  32. #define DBG_WARN_ERROR 0x00000134 //Traceout warnings and errors including DBG_RT_WARN
  33. #define DBG_ALL 0xFFFFFFFF //Traceout all codes
  34. #if (DBG==1)
  35. //
  36. // Declaration for debug module
  37. //
  38. //
  39. // Must start file with a #define for the DEBUG module
  40. //
  41. //i.e. #define __DEBUG_MODULE_IN_USE__ GCKERNEL_DEBUG_MODULE
  42. #define DECLARE_MODULE_DEBUG_LEVEL(__x__)\
  43. ULONG __DEBUG_MODULE_IN_USE__ = __x__;
  44. #define SET_MODULE_DEBUG_LEVEL(__x__)\
  45. __DEBUG_MODULE_IN_USE__ = __x__;
  46. //
  47. // Conditional debug output procedures
  48. //
  49. #define GCK_DBG_ENTRY_PRINT(__x__)\
  50. if(__DEBUG_MODULE_IN_USE__ & DBG_ENTRY)\
  51. {\
  52. DbgPrint("GcKernel: ");\
  53. DbgPrint __x__;\
  54. }
  55. #define GCK_DBG_EXIT_PRINT(__x__)\
  56. if(__DEBUG_MODULE_IN_USE__ & DBG_EXIT)\
  57. {\
  58. DbgPrint("GcKernel: ");\
  59. DbgPrint __x__;\
  60. }
  61. #define GCK_DBG_WARN_PRINT(__x__)\
  62. if(__DEBUG_MODULE_IN_USE__ & DBG_WARN)\
  63. {\
  64. DbgPrint("GcKernel: ");\
  65. DbgPrint __x__;\
  66. }
  67. #define GCK_DBG_TRACE_PRINT(__x__)\
  68. if(__DEBUG_MODULE_IN_USE__ & DBG_TRACE)\
  69. {\
  70. DbgPrint("GcKernel: ");\
  71. DbgPrint __x__;\
  72. }
  73. #define GCK_DBG_ERROR_PRINT(__x__)\
  74. if(__DEBUG_MODULE_IN_USE__ & DBG_ERROR)\
  75. {\
  76. DbgPrint("GcKernel: ");\
  77. DbgPrint __x__;\
  78. }
  79. #define GCK_DBG_CRITICAL_PRINT(__x__)\
  80. if(__DEBUG_MODULE_IN_USE__ & DBG_CRITICAL)\
  81. {\
  82. DbgPrint("GcKernel: ");\
  83. DbgPrint __x__;\
  84. }
  85. #define GCK_DBG_RT_ENTRY_PRINT(__x__)\
  86. if(__DEBUG_MODULE_IN_USE__ & DBG_RT_ENTRY)\
  87. {\
  88. DbgPrint("GcKernel: ");\
  89. DbgPrint __x__;\
  90. }
  91. #define GCK_DBG_RT_EXIT_PRINT(__x__)\
  92. if(__DEBUG_MODULE_IN_USE__ & DBG_RT_EXIT)\
  93. {\
  94. DbgPrint("GcKernel: ");\
  95. DbgPrint __x__;\
  96. }
  97. #define GCK_DBG_RT_WARN_PRINT(__x__)\
  98. if(__DEBUG_MODULE_IN_USE__ & DBG_RT_WARN)\
  99. {\
  100. DbgPrint("GcKernel: ");\
  101. DbgPrint __x__;\
  102. }
  103. #define GCK_DBG_BREAK() DbgBreakPoint()
  104. #undef PAGED_CODE
  105. #define PAGED_CODE() \
  106. if (KeGetCurrentIrql() > APC_LEVEL) \
  107. {\
  108. GCK_DBG_CRITICAL_PRINT(("GcKernel: Pageable code called at IRQL %ld (file: %s, line:#%ld)\n", KeGetCurrentIrql(),__FILE__,__LINE__))\
  109. ASSERT(FALSE);\
  110. }
  111. //External
  112. void SetDebugLevel(ULONG ulModuleId, ULONG ulDebugLevel);
  113. #define USING_CASE_FALLTHROUGH_TRACE ULONG macro_ulTraceoutSentAlready = FALSE;
  114. #define START_CASE_FALLTHROUGH_TRACE macro_ulTraceoutSentAlready = FALSE;
  115. #define TRACEOUT_THIS_CASE_ONLY if(!macro_ulTraceoutSentAlready && (macro_ulTraceoutSentAlready=TRUE) )
  116. #else // DBG=0
  117. #define GCK_DBG_ENTRY_PRINT(__x__)
  118. #define GCK_DBG_EXIT_PRINT(__x__)
  119. #define GCK_DBG_TRACE_PRINT(__x__)
  120. #define GCK_DBG_WARN_PRINT(__x__)
  121. #define GCK_DBG_ERROR_PRINT(__x__)
  122. #define GCK_DBG_CRITICAL_PRINT(__x__)
  123. #define GCK_DBG_RT_ENTRY_PRINT(__x__)
  124. #define GCK_DBG_RT_EXIT_PRINT(__x__)
  125. #define GCK_DBG_RT_WARN_PRINT(__x__)
  126. #define GCK_DBG_BREAK()
  127. #undef PAGED_CODE
  128. #define PAGED_CODE()
  129. #define DECLARE_MODULE_DEBUG_LEVEL(__x__)
  130. #define SET_MODULE_DEBUG_LEVEL(__x__)
  131. #define USING_CASE_FALLTHROUGH
  132. #define START_CASE_FALLTHROUGH_TRACE
  133. #define TRACEOUT_THIS_CASE_ONLY
  134. #endif // DBG=?
  135. //===========================================================================
  136. // End
  137. //===========================================================================
  138. #endif // DEBUG_H