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.

125 lines
2.2 KiB

  1. /*
  2. * Debugging utilities
  3. */
  4. #if DBG
  5. #include <winfile.h>
  6. char szAsrtFmt[] = "Assertion Failure in %s at %d";
  7. unsigned long TraceFlags = 0
  8. // | BF_START
  9. // | BF_PROCTRACE
  10. // | BF_PARMTRACE
  11. // | BF_MSGTRACE
  12. // | BF_DEFMSGTRACE
  13. ; // set these to print on TRACEs
  14. unsigned long BreakFlags = 0
  15. // | BF_START
  16. ; // set these to break on TRACEs
  17. VOID
  18. DbgAssert(
  19. LPSTR file,
  20. int line
  21. )
  22. {
  23. DbgPrint(szAsrtFmt, file, line);
  24. DebugBreak();
  25. }
  26. VOID
  27. DbgTrace(
  28. DWORD tf,
  29. LPSTR lpstr
  30. )
  31. {
  32. if (tf & TraceFlags) {
  33. DbgPrint("%s\n", lpstr);
  34. if (tf & BreakFlags) {
  35. DebugBreak();
  36. }
  37. }
  38. }
  39. VOID
  40. DbgBreak(
  41. DWORD bf,
  42. LPSTR file,
  43. int line
  44. )
  45. {
  46. if (bf & BreakFlags) {
  47. DbgPrint("BREAK at %s:%d\n", file, line);
  48. DebugBreak();
  49. }
  50. }
  51. VOID
  52. DbgPrint1(
  53. DWORD tf,
  54. LPSTR fmt,
  55. LPSTR p1
  56. )
  57. {
  58. if (tf & TraceFlags) {
  59. DbgPrint(fmt, p1);
  60. DbgPrint("\n");
  61. }
  62. if (tf & BreakFlags) {
  63. DebugBreak();
  64. }
  65. }
  66. VOID
  67. DbgEnter(
  68. LPSTR funName
  69. )
  70. {
  71. DbgPrint1(BF_PROCTRACE, "> %s", funName);
  72. }
  73. VOID
  74. DbgLeave(
  75. LPSTR funName
  76. )
  77. {
  78. DbgPrint1(BF_PROCTRACE, " <%s", funName);
  79. }
  80. VOID
  81. DbgTraceMessage(
  82. LPSTR funName,
  83. LPSTR msgName
  84. )
  85. {
  86. if (BF_MSGTRACE & TraceFlags) {
  87. DbgPrint("MSG: %s - %s\n", funName, msgName);
  88. }
  89. if (BF_MSGTRACE & BreakFlags) {
  90. DebugBreak();
  91. }
  92. }
  93. VOID
  94. DbgTraceDefMessage(
  95. LPSTR funName,
  96. WORD msgId
  97. )
  98. {
  99. if (BF_DEFMSGTRACE & TraceFlags) {
  100. DbgPrint("MSG: %s - default(0x%x)\n", funName, msgId);
  101. }
  102. if (BF_DEFMSGTRACE & BreakFlags) {
  103. DebugBreak();
  104. }
  105. }
  106. #endif // DBG