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.

74 lines
2.1 KiB

  1. #ifndef __debug_h
  2. #define __debug_h
  3. /*-----------------------------------------------------------------------------
  4. / Debugging APIs (use the Macros, they make it easier and cope with correctly
  5. / removing debugging when it is disabled at built time).
  6. /----------------------------------------------------------------------------*/
  7. /*
  8. void DoTraceSetMask(DWORD dwMask);
  9. void DoTraceEnter(DWORD dwMask, LPCTSTR pName);
  10. void DoTraceLeave(void);
  11. void DoTrace(LPCTSTR pFormat, ...);
  12. void DoTraceGUID(LPCTSTR pPrefix, REFGUID rGUID);
  13. void DoTraceAssert(int iLine, LPTSTR pFilename);
  14. */
  15. /*-----------------------------------------------------------------------------
  16. / Macros to ease the use of the debugging APIS.
  17. /----------------------------------------------------------------------------*/
  18. #pragma warning(disable:4127) // conditional expression is constant
  19. #if DBG
  20. #ifndef DEBUG
  21. #define DEBUG
  22. #endif
  23. #define debug if ( TRUE )
  24. #else
  25. #undef DEBUG
  26. #define debug if ( FALSE )
  27. #endif
  28. #ifdef NEVER //DEBUG
  29. #define TraceSetMask(dwMask) debug DoTraceSetMask(dwMask)
  30. #define TraceEnter(dwMask, fn) debug DoTraceEnter(dwMask, TEXT(fn))
  31. #define TraceLeave debug DoTraceLeave
  32. #define Trace debug DoTrace
  33. #define TraceMsg(s) debug DoTrace(TEXT(s))
  34. #define TraceGUID(s, rGUID) debug DoTraceGUID(TEXT(s), rGUID)
  35. #define TraceAssert(x) \
  36. { if ( !(x) ) DoTraceAssert(__LINE__, TEXT(__FILE__)); }
  37. #define TraceLeaveResult(hr) \
  38. { HRESULT __hr = hr; if (FAILED(__hr)) Trace(TEXT("Failed (%08x)"), hr); TraceLeave(); return __hr; }
  39. #define TraceLeaveVoid() \
  40. { TraceLeave(); return; }
  41. #define TraceLeaveValue(value) \
  42. { TraceLeave(); return(value); }
  43. #else
  44. #define TraceAssert(x)
  45. #define TraceLeaveResult(hr) { return hr; }
  46. #define TraceLeaveVoid() { return; }
  47. #define TraceLeaveValue(value) { return(value); }
  48. #define TraceSetMask(dwMask)
  49. #define TraceEnter(dwMask, fn)
  50. #define TraceLeave
  51. #define Trace
  52. #define TraceMsg(s)
  53. #define TraceGUID(s, rGUID)
  54. #endif
  55. #endif