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.

100 lines
3.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: debug.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef __debug_h
  11. #define __debug_h
  12. /*-----------------------------------------------------------------------------
  13. / Macros to ease the use of the debugging APIS.
  14. /----------------------------------------------------------------------------*/
  15. #if defined(DBG) || defined(DEBUG)
  16. #ifndef DEBUG
  17. #define DEBUG
  18. #endif
  19. extern DWORD g_dwTraceMask;
  20. #else
  21. #undef DEBUG
  22. #endif
  23. #ifdef DEBUG
  24. #define TraceSetMask(dwMask) DoTraceSetMask(dwMask)
  25. #define TraceEnter(dwMask, fn) LPCTSTR _szf = TEXT(fn);BOOL DO_LOG=((dwMask) & g_dwTraceMask);if (DO_LOG) DoTraceEnter(dwMask, TEXT(fn))
  26. #define TraceLeave if (DO_LOG) DoTraceLeave
  27. #define Trace if (DO_LOG) DoTrace
  28. #define TraceMsg(s) if (DO_LOG) DoTrace(TEXT(s))
  29. #define TraceGUID(s, rGUID) if (DO_LOG) DoTraceGUID(TEXT(s), rGUID)
  30. #define TraceViewMsg(m, w, l) if (DO_LOG) DoTraceViewMsg(m, w, l)
  31. #define TraceMenuMsg(m, w, l) if (DO_LOG) DoTraceMenuMsg(m, w, l)
  32. /*-----------------------------------------------------------------------------
  33. / Debugging APIs (use the Macros, they make it easier and cope with correctly
  34. / removing debugging when it is disabled at built time).
  35. /----------------------------------------------------------------------------*/
  36. void DoTraceSetMask(DWORD dwMask);
  37. void DoTraceEnter(DWORD dwMask, LPCTSTR pName);
  38. void DoTraceLeave(void);
  39. void DoTrace(LPCTSTR pFormat, ...);
  40. void DoTraceGUID(LPCTSTR pPrefix, REFGUID rGUID);
  41. void DoTraceViewMsg( UINT uMsg, WPARAM wParam, LPARAM lParam );
  42. void DoTraceMenuMsg( UINT uMsg, WPARAM wParam, LPARAM lParam );
  43. void DoTraceAssert(int iLine, LPTSTR pFilename);
  44. #define TraceAssert(x) \
  45. { if ( !(x) ) DoTraceAssert(__LINE__, TEXT(__FILE__)); }
  46. #define TraceLeaveResult(hr) \
  47. { HRESULT __hr = hr; if (FAILED(__hr)) Trace(TEXT("%s Failed (%08x)"), _szf, hr ); TraceLeave(); return __hr; }
  48. #define TraceLeaveResultNoRet(hr) \
  49. { HRESULT __hr = hr; if (FAILED(__hr)) Trace(TEXT("Failed (%08x)"), hr); TraceLeave(); }
  50. #define TraceLeaveVoid() \
  51. { TraceLeave(); return; }
  52. #define TraceLeaveValue(value) \
  53. { TraceLeave(); return(value); }
  54. #define TraceCheckResult(hr,x) \
  55. { HRESULT __hr = hr; if (FAILED(__hr)) DoTrace( TEXT("%s (hr=%08X)"), TEXT(x), hr ); }
  56. #else
  57. #define TraceSetMask(dwMask)
  58. #define TraceEnter(dwMask, fn)
  59. #define TraceLeave()
  60. #define Trace if (FALSE)
  61. #define TraceMsg(s)
  62. #define TraceGUID(s, rGUID)
  63. #define TraceViewMsg(m, w, l)
  64. #define TraceMenuMsg(m, w, l)
  65. #define TraceCheckResult(hr,x) { ; }
  66. #define TraceAssert(x)
  67. #define TraceLeaveResult(hr) { return hr; }
  68. #define TraceLeaveVoid() { return; }
  69. #define TraceLeaveValue(value) { return(value); }
  70. #define TraceLeaveResultNoRet(hr) { return; }
  71. #endif
  72. #endif