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.

91 lines
2.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: debug.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef __debug_h
  11. #define __debug_h
  12. #if DBG
  13. #define DEBUG
  14. #else
  15. #undef DEBUG
  16. #endif
  17. /*-----------------------------------------------------------------------------
  18. / Debugging APIs (use the Macros, they make it easier and cope with correctly
  19. / removing debugging when it is disabled at build time).
  20. /----------------------------------------------------------------------------*/
  21. void DoTraceSetMask(DWORD dwMask);
  22. void DoTraceSetMaskFromRegKey(HKEY hkRoot, LPCTSTR pszSubKey);
  23. void DoTraceSetMaskFromCLSID(REFCLSID rCLSID);
  24. void DoTraceEnter(DWORD dwMask, LPCTSTR pName);
  25. void DoTraceLeave(void);
  26. void DoTrace(LPCTSTR pFormat, ...);
  27. void DoTraceGUID(LPCTSTR pPrefix, REFGUID rGUID);
  28. void DoTraceAssert(int iLine, LPTSTR pFilename);
  29. /*-----------------------------------------------------------------------------
  30. / Macros to ease the use of the debugging APIS.
  31. /----------------------------------------------------------------------------*/
  32. #ifdef DEBUG
  33. void DebugThreadDetach(void); // optional
  34. void DebugProcessAttach(void); // required
  35. void DebugProcessDetach(void); // required
  36. #define TraceSetMask(dwMask) DoTraceSetMask(dwMask)
  37. #define TraceSetMaskFromRegKey(hk, psz) DoTraceSetMaskFromRegKey(hk, psz)
  38. #define TraceSetMaskFromCLSID(rCLSID) DoTraceSetMaskFromCLSID(rCLSID)
  39. #define TraceEnter(dwMask, fn) DoTraceEnter(dwMask, TEXT(fn))
  40. #define TraceLeave() DoTraceLeave()
  41. #define Trace(x) DoTrace x
  42. #define TraceMsg(s) DoTrace(TEXT(s))
  43. #define TraceGUID(s, rGUID) DoTraceGUID(TEXT(s), rGUID)
  44. #define TraceAssert(x) \
  45. { if ( !(x) ) DoTraceAssert(__LINE__, TEXT(__FILE__)); }
  46. #define TraceLeaveResult(hr) \
  47. { HRESULT __hr = (hr); if (FAILED(__hr)) Trace((TEXT("Failed (%08x)"), __hr)); TraceLeave(); return __hr; }
  48. #define TraceLeaveVoid() \
  49. { TraceLeave(); return; }
  50. #define TraceLeaveValue(value) \
  51. { TraceLeave(); return (value); }
  52. #else // !DEBUG
  53. #define DebugThreadDetach()
  54. #define DebugProcessAttach()
  55. #define DebugProcessDetach()
  56. #define TraceSetMask(dwMask)
  57. #define TraceSetMaskFromRegKey(hk, psz)
  58. #define TraceSetMaskFromCLSID(rCLSID)
  59. #define TraceEnter(dwMask, fn)
  60. #define TraceLeave()
  61. #define Trace(x)
  62. #define TraceMsg(s)
  63. #define TraceGUID(s, rGUID)
  64. #define TraceAssert(x)
  65. #define TraceLeaveResult(hr) { return (hr); }
  66. #define TraceLeaveVoid() { return; }
  67. #define TraceLeaveValue(value) { return (value); }
  68. #endif // DEBUG
  69. #endif // __debug_h