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.

125 lines
5.4 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: StandardDebug.h
  3. //
  4. // Copyright (c) 1999-2000, Microsoft Corporation
  5. //
  6. // This file defines standard debug macros for the consumer Windows additions
  7. // to Windows 2000 msgina.
  8. //
  9. // History: 1999-08-18 vtan created
  10. // 1999-09-10 vtan reworked macros
  11. // 2000-01-31 vtan moved from Neptune to Whistler
  12. // --------------------------------------------------------------------------
  13. #ifndef _StandardDebug_
  14. #define _StandardDebug_
  15. #ifdef DBG
  16. typedef enum
  17. {
  18. TRACE_ERROR_TYPE_WIN32 = 1,
  19. TRACE_ERROR_TYPE_BOOL,
  20. TRACE_ERROR_TYPE_HRESULT,
  21. TRACE_ERROR_TYPE_NTSTATUS
  22. } TRACE_ERROR_TYPE;
  23. static const int FLAG_BREAK_ON_ERROR = 0x00000001;
  24. extern LONG gLastResult;
  25. class CDebug
  26. {
  27. public:
  28. static void AttachUserModeDebugger (void);
  29. static void Break (void);
  30. static void BreakIfRequested (void);
  31. static void DisplayStandardPrefix (void);
  32. static void DisplayError (TRACE_ERROR_TYPE eType, LONG code, const char *pszFunction, const char *pszSource, int iLine);
  33. static void DisplayMessage (const char *pszMessage);
  34. static void DisplayAssert (const char *pszMessage, bool fForceBreak = false);
  35. static void DisplayWarning (const char *pszMessage);
  36. static void DisplayDACL (HANDLE hObject, SE_OBJECT_TYPE seObjectType);
  37. static NTSTATUS StaticInitialize (void);
  38. static NTSTATUS StaticTerminate (void);
  39. private:
  40. static void DisplaySID (PSID pSID);
  41. private:
  42. static bool s_fHasUserModeDebugger,
  43. s_fHasKernelModeDebugger;
  44. };
  45. #undef ASSERTMSG
  46. #define ASSERTMSG(condition, message) \
  47. if (!(condition)) \
  48. { \
  49. CDebug::DisplayAssert(message); \
  50. }
  51. #define ASSERTBREAKMSG(condition, message) \
  52. if (!(condition)) \
  53. { \
  54. CDebug::DisplayAssert(message, true); \
  55. }
  56. #define DISPLAYMSG(message) \
  57. { \
  58. CDebug::DisplayAssert(message); \
  59. }
  60. #define WARNINGMSG(message) \
  61. { \
  62. CDebug::DisplayWarning(message); \
  63. }
  64. #define INFORMATIONMSG(message) \
  65. { \
  66. CDebug::DisplayMessage(message); \
  67. }
  68. #define TW32(result) \
  69. if (ERROR_SUCCESS != (gLastResult = result)) \
  70. { \
  71. CDebug::DisplayError(TRACE_ERROR_TYPE_WIN32, gLastResult, #result, __FILE__, __LINE__); \
  72. }
  73. #define TBOOL(result) \
  74. if (result == FALSE) \
  75. { \
  76. CDebug::DisplayError(TRACE_ERROR_TYPE_BOOL, 0, #result, __FILE__, __LINE__); \
  77. }
  78. #define THR(result) \
  79. if (FAILED(gLastResult = result)) \
  80. { \
  81. CDebug::DisplayError(TRACE_ERROR_TYPE_HRESULT, gLastResult, #result, __FILE__, __LINE__); \
  82. }
  83. #define TSTATUS(result) \
  84. if (!NT_SUCCESS(gLastResult = result)) \
  85. { \
  86. CDebug::DisplayError(TRACE_ERROR_TYPE_NTSTATUS, gLastResult, #result, __FILE__, __LINE__); \
  87. }
  88. #define COMPILETIME_ASSERT(condition) \
  89. switch (0) case 0: case condition:
  90. #define DEBUGFILLMEMORY(address,size) \
  91. FillMemory(address, size, 0xA7)
  92. #else /* DBG */
  93. #undef ASSERTMSG
  94. #define ASSERTMSG(condition, message)
  95. #define DISPLAYMSG(message)
  96. #define WARNINGMSG(message)
  97. #define TW32(result) (LONG)result
  98. #define TBOOL(result) (BOOL)result
  99. #define THR(result) (HRESULT)result
  100. #define TSTATUS(result) (NTSTATUS)result
  101. #define DEBUGFILLMEMORY(address,size)
  102. #endif /* DBG */
  103. #endif /* _StandardDebug_ */