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.

196 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. Various helpful debugging functions
  7. Author:
  8. Based on code by Mike Tsang (MikeTs)
  9. Stephane Plante (Splante)
  10. Environment:
  11. User mode only
  12. Revision History:
  13. --*/
  14. #include "pch.h"
  15. ULONG globalDebugIndentLevel = 0;
  16. ULONG globalVerbosityLevel = 0;
  17. UCHAR DebugMessageBuffer[2048];
  18. VOID
  19. IndentProcedure(
  20. VOID
  21. )
  22. {
  23. ULONG i;
  24. for (i = 0; i < globalDebugIndentLevel; i++) {
  25. if (GlobalPrintFnc != NULL) {
  26. GlobalPrintFnc("| ");
  27. } else {
  28. fprintf( stderr, "| ");
  29. }
  30. }
  31. }
  32. VOID
  33. DebugEnterProcedure(
  34. ULONG VerbosityLevel,
  35. PCCHAR Format,
  36. ...
  37. )
  38. /*++
  39. Routine Description:
  40. This routine handles displaying of information when a procedure is
  41. entered
  42. Arguments:
  43. Verbosity - We have to be at this verbosity level to display a string
  44. Format - String to print
  45. ... - Arguments
  46. Return Value:
  47. None
  48. --*/
  49. {
  50. va_list marker;
  51. if (VerbosityLevel <= globalVerbosityLevel) {
  52. IndentProcedure();
  53. va_start( marker, Format );
  54. if (GlobalPrintFnc != NULL) {
  55. vsprintf( DebugMessageBuffer, Format, marker );
  56. GlobalPrintFnc( DebugMessageBuffer );
  57. } else {
  58. vfprintf( stderr, Format, marker );
  59. fflush( stderr );
  60. }
  61. va_end ( marker );
  62. }
  63. globalDebugIndentLevel++;
  64. }
  65. VOID
  66. DebugExitProcedure(
  67. ULONG VerbosityLevel,
  68. PCCHAR Format,
  69. ...
  70. )
  71. /*++
  72. Routine Description:
  73. This routine handles displaying of information when a procedure is
  74. exited
  75. Arguments:
  76. Verbosity - We have to be at this verbosity level to display a string
  77. Format - String to print
  78. ... - Arguments
  79. Return Value:
  80. None
  81. --*/
  82. {
  83. va_list marker;
  84. globalDebugIndentLevel--;
  85. if (VerbosityLevel <= globalVerbosityLevel) {
  86. IndentProcedure();
  87. va_start( marker, Format );
  88. if (GlobalPrintFnc != NULL) {
  89. vsprintf( DebugMessageBuffer, Format, marker );
  90. GlobalPrintFnc( DebugMessageBuffer );
  91. } else {
  92. vfprintf( stderr, Format, marker );
  93. fflush( stderr );
  94. }
  95. va_end ( marker );
  96. }
  97. }
  98. VOID
  99. DebugPrintProcedure(
  100. ULONG VerbosityLevel,
  101. PCCHAR Format,
  102. ...
  103. )
  104. /*++
  105. Routine Description:
  106. This routine handles displaying of information when a procedure is
  107. exited
  108. Arguments:
  109. Verbosity - We have to be at this verbosity level to display a string
  110. Format - String to print
  111. ... - Arguments
  112. Return Value:
  113. None
  114. --*/
  115. {
  116. va_list marker;
  117. if (VerbosityLevel <= globalVerbosityLevel) {
  118. IndentProcedure();
  119. va_start( marker, Format );
  120. if (GlobalPrintFnc != NULL) {
  121. vsprintf( DebugMessageBuffer, Format, marker );
  122. GlobalPrintFnc( DebugMessageBuffer );
  123. } else {
  124. vfprintf( stderr, Format, marker );
  125. fflush( stderr );
  126. }
  127. va_end ( marker );
  128. }
  129. }