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.

109 lines
2.7 KiB

  1. #include "precomp.h"
  2. #if defined(_DEBUG) && ! defined(_UNICODE)
  3. #define MULTI_LEVEL_ZONES
  4. #include <mlzdbg.h>
  5. HDBGZONE g_hDbgZones;
  6. void WINAPI MLZ_DbgInit(PSTR *apszZones, UINT cZones)
  7. {
  8. // if registry is empty, set warning flag as default
  9. DbgInitEx(&g_hDbgZones, apszZones, cZones, ZONE_WARNING_FLAG);
  10. // if the warning flag is not set, then set it as default
  11. if (g_hDbgZones != NULL)
  12. {
  13. ((PZONEINFO) g_hDbgZones)->ulZoneMask |= ZONE_WARNING_FLAG;
  14. }
  15. }
  16. void WINAPI MLZ_DbgDeInit(void)
  17. {
  18. DbgDeInit(&g_hDbgZones);
  19. }
  20. void WINAPIV MLZ_WarningOut(PSTR pszFormat, ...)
  21. {
  22. if (g_hDbgZones != NULL &&
  23. IS_ZONE_ENABLED(g_hDbgZones, ZONE_WARNING_FLAG))
  24. {
  25. va_list args;
  26. va_start(args, pszFormat);
  27. DbgPrintf(NULL, pszFormat, args);
  28. va_end(args);
  29. }
  30. }
  31. BOOL WINAPI MLZ_TraceZoneEnabled(int iZone)
  32. {
  33. return (g_hDbgZones != NULL &&
  34. IS_ZONE_ENABLED(g_hDbgZones, ZONE_TRACE_FLAG) &&
  35. IS_ZONE_ENABLED(g_hDbgZones, ZONE_FLAG(iZone)));
  36. }
  37. void WINAPIV MLZ_TraceOut(PSTR pszFormat, ...)
  38. {
  39. va_list args;
  40. va_start(args, pszFormat);
  41. DbgPrintf(NULL, pszFormat, args);
  42. va_end(args);
  43. }
  44. void WINAPI MLZ_EntryOut(int iZone, PSTR pszFunName)
  45. {
  46. if (g_hDbgZones != NULL &&
  47. IS_ZONE_ENABLED(g_hDbgZones, ZONE_FUNCTION_FLAG) &&
  48. IS_ZONE_ENABLED(g_hDbgZones, ZONE_FLAG(iZone)))
  49. {
  50. MLZ_TraceOut("%s() entered.", pszFunName);
  51. }
  52. }
  53. void WINAPI MLZ_ExitOut(int iZone, PSTR pszFunName, RCTYPE eRetCodeType, DWORD_PTR dwRetCode)
  54. {
  55. if (g_hDbgZones != NULL &&
  56. IS_ZONE_ENABLED(g_hDbgZones, ZONE_FUNCTION_FLAG) &&
  57. IS_ZONE_ENABLED(g_hDbgZones, ZONE_FLAG(iZone)))
  58. {
  59. PSTR pszRetCode;
  60. char szFormat[64];
  61. lstrcpyA(&szFormat[0], "%s() exiting...");
  62. pszRetCode = &szFormat[0] + lstrlenA(&szFormat[0]);
  63. if (eRetCodeType != RCTYPE_VOID)
  64. {
  65. lstrcpyA(pszRetCode, " rc=");
  66. pszRetCode += lstrlenA(pszRetCode);
  67. switch (eRetCodeType)
  68. {
  69. case RCTYPE_BOOL:
  70. lstrcpyA(pszRetCode, dwRetCode ? "TRUE" : "FALSE");
  71. break;
  72. case RCTYPE_DWORD:
  73. case RCTYPE_HRESULT:
  74. wsprintf(pszRetCode, "0x%lx", (DWORD)dwRetCode);
  75. break;
  76. case RCTYPE_INT:
  77. wsprintf(pszRetCode, "%ld", (LONG) dwRetCode);
  78. break;
  79. case RCTYPE_ULONG:
  80. wsprintf(pszRetCode, "%lu", (ULONG) dwRetCode);
  81. break;
  82. case RCTYPE_PTR:
  83. wsprintf(pszRetCode, "%p", dwRetCode);
  84. break;
  85. default:
  86. ASSERT(0);
  87. break;
  88. }
  89. }
  90. MLZ_TraceOut(&szFormat[0], pszFunName);
  91. }
  92. }
  93. #endif // _DEBUG && ! _UNICODE
  94.