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.

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