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.

167 lines
6.2 KiB

  1. //+---------------------------------------------------------------------------
  2. // Copyright (C) 1996, Microsoft Corporation.
  3. //
  4. // File: AdminDbg.h
  5. //
  6. // Contents: Debugging macros. Stolen from old Cairo debnot.h with the
  7. // following history...
  8. //
  9. // History: 23-Jul-91 KyleP Created.
  10. // 15-Oct-91 KevinRo Major changes and comments added
  11. // 18-Oct-91 vich Consolidated win4p.hxx
  12. // 29-Apr-92 BartoszM Moved from win4p.h
  13. // 18-Jun-94 AlexT Make Assert a better statement
  14. // 7-Oct-94 BruceFo Stole and ripped out everything except
  15. // debug prints and asserts.
  16. // 20-Oct-95 EricB Set component debug level in the
  17. // registry.
  18. // 26-Feb-96 EricB Renamed Win4xxx exported fcns to not
  19. // conflict with ole32.lib.
  20. //
  21. //
  22. // NOTE: you must call the InitializeDebugging() API before calling any other
  23. // APIs!
  24. //
  25. // To set a non-default debug info level outside of the debugger, create the
  26. // below registry key:
  27. //
  28. // "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AdminDebug"
  29. //
  30. // and in it create a value whose name is the component's debugging tag name
  31. // (the "comp" parameter to the DECLARE_INFOLEVEL macro) and whose data is
  32. // the desired infolevel in REG_DWORD format.
  33. // e.g. Sched = REG_DWORD 0x707
  34. //
  35. //----------------------------------------------------------------------------
  36. #ifndef __DEBUG_H__
  37. #define __DEBUG_H__
  38. //+----------------------------------------------------------------------
  39. //
  40. // DECLARE_DEBUG(comp)
  41. // DECLARE_INFOLEVEL(comp)
  42. //
  43. // This macro defines xxDebugOut where xx is the component prefix
  44. // to be defined. This declares a static variable 'xxInfoLevel', which
  45. // can be used to control the type of xxDebugOut messages printed to
  46. // the terminal. For example, xxInfoLevel may be set at the debug terminal.
  47. // This will enable the user to turn debugging messages on or off, based
  48. // on the type desired. The predefined types are defined below. Component
  49. // specific values should use the upper 24 bits
  50. //
  51. // To Use:
  52. //
  53. // 1) In your components main include file, include the line
  54. // DECLARE_DEBUG(comp)
  55. // where comp is your component prefix
  56. //
  57. // 2) In one of your components source files, include the line
  58. // DECLARE_INFOLEVEL(comp)
  59. // where comp is your component prefix. This will define the
  60. // global variable that will control output.
  61. //
  62. // It is suggested that any component define bits be combined with
  63. // existing bits. For example, if you had a specific error path that you
  64. // wanted, you might define DEB_<comp>_ERRORxxx as being
  65. //
  66. // (0x100 | DEB_ERROR)
  67. //
  68. // This way, we can turn on DEB_ERROR and get the error, or just 0x100
  69. // and get only your error.
  70. //
  71. //-----------------------------------------------------------------------
  72. #ifdef DBG
  73. class CDbg
  74. {
  75. public:
  76. CDbg(LPTSTR str);
  77. ~CDbg(void);
  78. void DebugOut(unsigned long fDebugMask, LPWSTR pszfmt, ...);
  79. void DebugOut(unsigned long fDebugMask, LPSTR pszfmt, ...);
  80. void DebugMsg(LPSTR file, unsigned long line, LPWSTR msg);
  81. void DebugMsg(LPSTR file, unsigned long line, LPSTR msg);
  82. void DebugErrorL(LPSTR file, ULONG line, LONG err);
  83. void DebugErrorX(LPSTR file, ULONG line, LONG err);
  84. static void AssertEx(LPSTR pszFile, int iLine, LPTSTR pszMsg);
  85. private:
  86. unsigned long m_InfoLevel; // must be the first data member
  87. LPTSTR m_InfoLevelString;
  88. public:
  89. static long s_cCDbgObjCount; // Number of CDbg instances.
  90. }; // class CDbg
  91. #define DECLARE_DEBUG(comp) extern "C" CDbg comp##InfoLevel;
  92. #define DECLARE_INFOLEVEL(comp) CDbg comp##InfoLevel(_T(#comp));
  93. #define Win4Assert(x) (void)((x) || (CDbg::AssertEx(THIS_FILE,__LINE__, _T(#x)),0))
  94. #else // ! DBG
  95. #define DECLARE_DEBUG(comp)
  96. #define DECLARE_INFOLEVEL(comp)
  97. #define Win4Assert(x) NULL
  98. #endif // ! DBG
  99. ////////////////////////////////////////////////////////////////////////////
  100. ////////////////////////////////////////////////////////////////////////////
  101. //
  102. // Debug info levels
  103. //
  104. ////////////////////////////////////////////////////////////////////////////
  105. ////////////////////////////////////////////////////////////////////////////
  106. #define DEB_ERROR 0x00000001 // exported error paths
  107. #define DEB_WARN 0x00000002 // exported warnings
  108. #define DEB_TRACE 0x00000004 // exported trace messages
  109. #define DEB_DBGOUT 0x00000010 // Output to debugger
  110. #define DEB_STDOUT 0x00000020 // Output to stdout
  111. #define DEB_IERROR 0x00000100 // internal error paths
  112. #define DEB_IWARN 0x00000200 // internal warnings
  113. #define DEB_ITRACE 0x00000400 // internal trace messages
  114. #define DEB_USER1 0x00010000 // User defined
  115. #define DEB_USER2 0x00020000 // User defined
  116. #define DEB_USER3 0x00040000 // User defined
  117. #define DEB_USER4 0x00080000 // User defined
  118. #define DEB_USER5 0x00100000 // User defined
  119. #define DEB_USER6 0x00200000 // User defined
  120. #define DEB_USER7 0x00400000 // User defined
  121. #define DEB_USER8 0x00800000 // User defined
  122. #define DEB_USER9 0x01000000 // User defined
  123. #define DEB_USER10 0x02000000 // User defined
  124. #define DEB_USER11 0x04000000 // User defined
  125. #define DEB_USER12 0x08000000 // User defined
  126. #define DEB_USER13 0x10000000 // User defined
  127. #define DEB_USER14 0x20000000 // User defined
  128. #define DEB_USER15 0x40000000 // User defined
  129. #define DEB_NOCOMPNAME 0x80000000 // suppress component name
  130. #define DEB_FORCE 0x7fffffff // force message
  131. #define ASSRT_MESSAGE 0x00000001 // Output a message
  132. #define ASSRT_BREAK 0x00000002 // Int 3 on assertion
  133. #define ASSRT_POPUP 0x00000004 // And popup message
  134. #ifndef DEF_INFOLEVEL
  135. #define DEF_INFOLEVEL (DEB_ERROR | DEB_WARN)
  136. #endif
  137. #endif // __DEBUG_H__