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.

181 lines
6.1 KiB

  1. // Debugging macros
  2. //
  3. #define DEBUG_CASE_STRING(x) case x: return #x
  4. // Dump flags used in g_uDumpFlags
  5. //
  6. #define DF_RECLIST 0x0001
  7. #define DF_RECITEM 0x0002
  8. #define DF_RECNODE 0x0004
  9. #define DF_CREATETWIN 0x0008
  10. #define DF_ATOMS 0x0010
  11. #define DF_CRL 0x0020
  12. #define DF_CBS 0x0040
  13. #define DF_CPATH 0x0080
  14. #define DF_PATHS 0x0100
  15. #define DF_UPDATECOUNT 0x0200
  16. #define DF_TWINPAIR 0x0400
  17. #define DF_FOLDERTWIN 0x0800
  18. #define DF_CHOOSESIDE 0x1000
  19. // Break flags used in g_uBreakFlags
  20. //
  21. #define BF_ONOPEN 0x0001
  22. #define BF_ONCLOSE 0x0002
  23. #define BF_ONRUNONCE 0x0004
  24. #define BF_ONVALIDATE 0x0010
  25. #define BF_ONTHREADATT 0x0100
  26. #define BF_ONTHREADDET 0x0200
  27. #define BF_ONPROCESSATT 0x0400
  28. #define BF_ONPROCESSDET 0x0800
  29. // Trace flags used in g_uTraceFlags (defined in retail on purpose)
  30. //
  31. #define TF_ALWAYS 0x0000
  32. #define TF_WARNING 0x0001
  33. #define TF_ERROR 0x0002
  34. #define TF_GENERAL 0x0004 // Standard briefcase trace messages
  35. #define TF_FUNC 0x0008 // Trace function calls
  36. #define TF_CACHE 0x0010 // Cache-specific trace messages
  37. #define TF_ATOM 0x0020 // Atom-specific trace messages
  38. LPCSTR PUBLIC Dbg_SafeStr(LPCSTR psz);
  39. #ifdef DEBUG
  40. #define DEBUG_CASE_STRING(x) case x: return #x
  41. #define ASSERTSEG
  42. // Use this macro to declare message text that will be placed
  43. // in the CODE segment (useful if DS is getting full)
  44. //
  45. // Ex: DEBUGTEXT(szMsg, "Invalid whatever: %d");
  46. //
  47. #define DEBUGTEXT(sz, msg) /* ;Internal */ \
  48. static const char ASSERTSEG sz[] = msg;
  49. void PUBLIC BrfAssertFailed(LPCSTR szFile, int line);
  50. void CPUBLIC BrfAssertMsg(BOOL f, LPCSTR pszMsg, ...);
  51. void CPUBLIC BrfDebugMsg(UINT mask, LPCSTR pszMsg, ...);
  52. // ASSERT(f) -- Generate "assertion failed in line x of file.c"
  53. // message if f is NOT true.
  54. //
  55. #define ASSERT(f) \
  56. { \
  57. DEBUGTEXT(szFile, __FILE__); \
  58. if (!(f)) \
  59. BrfAssertFailed(szFile, __LINE__); \
  60. }
  61. #define ASSERT_E(f) ASSERT(f)
  62. // ASSERT_MSG(f, msg, args...) -- Generate wsprintf-formatted msg w/params
  63. // if f is NOT true.
  64. //
  65. #define ASSERT_MSG BrfAssertMsg
  66. // DEBUG_MSG(mask, msg, args...) - Generate wsprintf-formatted msg using
  67. // specified debug mask. System debug mask
  68. // governs whether message is output.
  69. //
  70. #define DEBUG_MSG BrfDebugMsg
  71. #define TRACE_MSG DEBUG_MSG
  72. // VERIFYSZ(f, msg, arg) -- Generate wsprintf-formatted msg w/ 1 param
  73. // if f is NOT true
  74. //
  75. #define VERIFYSZ(f, szFmt, x) ASSERT_MSG(f, szFmt, x)
  76. // VERIFYSZ2(f, msg, arg1, arg2) -- Generate wsprintf-formatted msg w/ 2
  77. // param if f is NOT true
  78. //
  79. #define VERIFYSZ2(f, szFmt, x1, x2) ASSERT_MSG(f, szFmt, x1, x2)
  80. // DBG_ENTER(szFn) -- Generates a function entry debug spew for
  81. // a function
  82. //
  83. #define DBG_ENTER(szFn) \
  84. TRACE_MSG(TF_FUNC, " > " szFn "()")
  85. // DBG_ENTER_SZ(szFn, sz) -- Generates a function entry debug spew for
  86. // a function that accepts a string as one of its
  87. // parameters.
  88. //
  89. #define DBG_ENTER_SZ(szFn, sz) \
  90. TRACE_MSG(TF_FUNC, " > " szFn "(..., \"%s\",...)", Dbg_SafeStr(sz))
  91. // DBG_ENTER_DTOBJ(szFn, pdtobj, szBuf) -- Generates a function entry
  92. // debug spew for a function that accepts a
  93. // string as one of its parameters.
  94. //
  95. #define DBG_ENTER_DTOBJ(szFn, pdtobj, szBuf) \
  96. TRACE_MSG(TF_FUNC, " > " szFn "(..., %s,...)", Dbg_DataObjStr(pdtobj, szBuf))
  97. // DBG_ENTER_RIID(szFn, riid) -- Generates a function entry debug spew for
  98. // a function that accepts an riid as one of its
  99. // parameters.
  100. //
  101. #define DBG_ENTER_RIID(szFn, riid) \
  102. TRACE_MSG(TF_FUNC, " > " szFn "(..., %s,...)", Dbg_GetRiidName(riid))
  103. // DBG_EXIT(szFn) -- Generates a function exit debug spew
  104. //
  105. #define DBG_EXIT(szFn) \
  106. TRACE_MSG(TF_FUNC, " < " szFn "()")
  107. // DBG_EXIT_US(szFn, us) -- Generates a function exit debug spew for
  108. // functions that return a USHORT.
  109. //
  110. #define DBG_EXIT_US(szFn, us) \
  111. TRACE_MSG(TF_FUNC, " < " szFn "() with %#x", (USHORT)us)
  112. // DBG_EXIT_UL(szFn, ul) -- Generates a function exit debug spew for
  113. // functions that return a ULONG.
  114. //
  115. #define DBG_EXIT_UL(szFn, ul) \
  116. TRACE_MSG(TF_FUNC, " < " szFn "() with %#lx", (ULONG)ul)
  117. // DBG_EXIT_PTR(szFn, pv) -- Generates a function exit debug spew for
  118. // functions that return a pointer.
  119. //
  120. #define DBG_EXIT_PTR(szFn, pv) \
  121. TRACE_MSG(TF_FUNC, " < " szFn "() with %#lx", (LPVOID)pv)
  122. // DBG_EXIT_HRES(szFn, hres) -- Generates a function exit debug spew for
  123. // functions that return an HRESULT.
  124. //
  125. #define DBG_EXIT_HRES(szFn, hres) \
  126. TRACE_MSG(TF_FUNC, " < " szFn "() with %s", Dbg_GetScode(hres))
  127. #else
  128. #define ASSERT(f)
  129. #define ASSERT_E(f) (f)
  130. #define ASSERT_MSG 1 ? (void)0 : (void)
  131. #define DEBUG_MSG 1 ? (void)0 : (void)
  132. #define TRACE_MSG 1 ? (void)0 : (void)
  133. #define VERIFYSZ(f, szFmt, x) (f)
  134. #define DBG_ENTER(szFn)
  135. #define DBG_ENTER_SZ(szFn, sz)
  136. #define DBG_ENTER_DTOBJ(szFn, pdtobj, sz)
  137. #define DBG_ENTER_RIID(szFn, riid)
  138. #define DBG_EXIT(szFn)
  139. #define DBG_EXIT_US(szFn, us)
  140. #define DBG_EXIT_UL(szFn, ul)
  141. #define DBG_EXIT_PTR(szFn, ptr)
  142. #define DBG_EXIT_HRES(szFn, hres)
  143. #endif