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.

140 lines
2.9 KiB

  1. /******************************************************************************\
  2. *
  3. * $Workfile: debug.c $
  4. *
  5. * Debug helpers routine.
  6. *
  7. * Copyright (c) 1992-1995 Microsoft Corporation
  8. * Copyright (c) 1996 Cirrus Logic, Inc.
  9. *
  10. * $Log: S:/projects/drivers/ntsrc/display/debug.c_v $
  11. *
  12. * Rev 1.2 Nov 26 1996 14:30:30 unknown
  13. * change to debug level 0
  14. *
  15. * Rev 1.1 Oct 10 1996 15:36:30 unknown
  16. *
  17. *
  18. * Rev 1.1 12 Aug 1996 16:51:20 frido
  19. * Added NT 3.5x/4.0 auto detection.
  20. *
  21. \******************************************************************************/
  22. #include "precomp.h"
  23. //#if DBG
  24. #if (DBG_STRESS_FAILURE || DBG)
  25. ULONG DebugLevel = 0;
  26. ULONG PerfLevel = 0;
  27. ULONG gulLastBltLine = 0;
  28. CHAR* glpszLastBltFile = "Uninitialized";
  29. BOOL gbResetOnTimeout = TRUE;
  30. /*****************************************************************************
  31. *
  32. * Routine Description:
  33. *
  34. * This function is variable-argument, level-sensitive debug print
  35. * routine.
  36. * If the specified debug level for the print statement is lower or equal
  37. * to the current debug level, the message will be printed.
  38. *
  39. * Arguments:
  40. *
  41. * DebugPrintLevel - Specifies at which debugging level the string should
  42. * be printed
  43. *
  44. * DebugMessage - Variable argument ascii c string
  45. *
  46. * Return Value:
  47. *
  48. * None.
  49. *
  50. ***************************************************************************/
  51. VOID
  52. DebugPrint(
  53. ULONG DebugPrintLevel,
  54. PCHAR DebugMessage,
  55. ...
  56. )
  57. {
  58. va_list ap;
  59. va_start(ap, DebugMessage);
  60. if (DebugPrintLevel <= DebugLevel)
  61. {
  62. #if (NT_VERSION < 0x0400)
  63. char szBuffer[256];
  64. vsprintf(szBuffer, DebugMessage, ap);
  65. OutputDebugString(szBuffer);
  66. #else
  67. EngDebugPrint(STANDARD_DEBUG_PREFIX, DebugMessage, ap);
  68. EngDebugPrint("", "\n", ap);
  69. #endif
  70. }
  71. va_end(ap);
  72. }
  73. /*****************************************************************************
  74. *
  75. * Routine Description:
  76. *
  77. * This function is variable-argument, level-sensitive Perf print
  78. * routine.
  79. * If the specified Perf level for the print statement is lower or equal
  80. * to the current Perf level, the message will be printed.
  81. *
  82. * Arguments:
  83. *
  84. * PerfPrintLevel - Specifies at which perf level the string should
  85. * be printed
  86. *
  87. * PerfMessage - Variable argument ascii c string
  88. *
  89. * Return Value:
  90. *
  91. * None.
  92. *
  93. ***************************************************************************/
  94. VOID
  95. PerfPrint(
  96. ULONG PerfPrintLevel,
  97. PCHAR PerfMessage,
  98. ...
  99. )
  100. {
  101. va_list ap;
  102. va_start(ap, PerfMessage);
  103. if (PerfPrintLevel <= PerfLevel)
  104. {
  105. #if (NT_VERSION < 0x0400)
  106. char szBuffer[256];
  107. vsprintf(szBuffer, PerfMessage, ap);
  108. OutputDebugString(szBuffer);
  109. #else
  110. EngDebugPrint(STANDARD_PERF_PREFIX, PerfMessage, ap);
  111. EngDebugPrint("", "\n", ap);
  112. #endif
  113. }
  114. va_end(ap);
  115. }
  116. #endif