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.

167 lines
2.6 KiB

  1. #include "precomp.h"
  2. //
  3. // TRC.C
  4. // Debug Tracing
  5. // This emulates the code found in NMUTIL for ring0
  6. //
  7. // Copyright(c) Microsoft 1997-
  8. //
  9. #if defined(DEBUG) || defined(INIT_TRACE)
  10. char s_ASDbgArea[] = "Salem ";
  11. #ifdef _M_ALPHA
  12. va_list g_trcDummyVa = {NULL, 0};
  13. #define DUMMY_VA_LIST g_trcDummyVa
  14. #else
  15. #define DUMMY_VA_LIST NULL
  16. #endif // _M_ALPHA
  17. //
  18. // Debug only
  19. //
  20. #ifdef DEBUG
  21. //
  22. // DbgZPrintFn()
  23. // DbgZPrintFnExitDWORD()
  24. // DbgZPrintFnExitPVOID()
  25. //
  26. // This prints out strings for function tracing
  27. //
  28. void DbgZPrintFn(LPSTR szFn)
  29. {
  30. if (g_trcConfig & ZONE_FUNCTION)
  31. {
  32. sprintf(g_szDbgBuf, "%s\n", szFn);
  33. EngDebugPrint(s_ASDbgArea, g_szDbgBuf, DUMMY_VA_LIST);
  34. }
  35. }
  36. void DbgZPrintFnExitDWORD(LPSTR szFn, DWORD dwResult)
  37. {
  38. if (g_trcConfig & ZONE_FUNCTION)
  39. {
  40. sprintf(g_szDbgBuf, "%s, RETURN %d\n", szFn, dwResult);
  41. EngDebugPrint(s_ASDbgArea, g_szDbgBuf, DUMMY_VA_LIST);
  42. }
  43. }
  44. void DbgZPrintFnExitPVOID(LPSTR szFn, PVOID ptr)
  45. {
  46. if (g_trcConfig & ZONE_FUNCTION)
  47. {
  48. sprintf(g_szDbgBuf, "%s, RETURN 0x%p\n", szFn, ptr);
  49. EngDebugPrint(s_ASDbgArea, g_szDbgBuf, DUMMY_VA_LIST);
  50. }
  51. }
  52. //
  53. // DbgZPrintTrace()
  54. //
  55. // This prints out a trace string
  56. //
  57. void DbgZPrintTrace(LPSTR szFormat, ...)
  58. {
  59. if (g_trcConfig & ZONE_TRACE)
  60. {
  61. va_list varArgs;
  62. va_start(varArgs, szFormat);
  63. sprintf(g_szDbgBuf, "TRACE: %s\n", szFormat);
  64. EngDebugPrint(s_ASDbgArea, g_szDbgBuf, varArgs);
  65. va_end(varArgs);
  66. }
  67. }
  68. //
  69. // DbgZPrintWarning()
  70. //
  71. // This prints out a warning string
  72. //
  73. void DbgZPrintWarning(PSTR szFormat, ...)
  74. {
  75. va_list varArgs;
  76. va_start(varArgs, szFormat);
  77. sprintf(g_szDbgBuf, "WARNING: %s\n", szFormat);
  78. EngDebugPrint(s_ASDbgArea, g_szDbgBuf, varArgs);
  79. va_end(varArgs);
  80. }
  81. #endif // DEBUG
  82. //
  83. // DbgZPrintInit()
  84. //
  85. // This is special case tracing only for the init code, which can be
  86. // built even in retail
  87. //
  88. void DbgZPrintInit(LPSTR szFormat, ...)
  89. {
  90. if (g_trcConfig & ZONE_INIT)
  91. {
  92. va_list varArgs;
  93. va_start(varArgs, szFormat);
  94. sprintf(g_szDbgBuf, "%s\n", szFormat);
  95. EngDebugPrint(s_ASDbgArea, g_szDbgBuf, varArgs);
  96. va_end(varArgs);
  97. }
  98. }
  99. //
  100. // DbgZPrintError()
  101. //
  102. // This prints out an error string then breaks into the kernel debugger.
  103. //
  104. void DbgZPrintError(LPSTR szFormat, ...)
  105. {
  106. va_list varArgs;
  107. va_start(varArgs, szFormat);
  108. sprintf(g_szDbgBuf, "ERROR: %s\n", szFormat);
  109. EngDebugPrint(s_ASDbgArea, g_szDbgBuf, varArgs);
  110. va_end(varArgs);
  111. EngDebugBreak();
  112. }
  113. #endif // DEBUG or INIT_TRACE
  114.