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.

216 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name :
  4. dbgutil.h
  5. Abstract:
  6. This module declares the macros to wrap around DEBUG_PRINTS class.
  7. This is the exported header file, which the client is allowed to
  8. modify for each application the accompanying pgmutils.dll is used.
  9. Author:
  10. Murali R. Krishnan ( MuraliK ) 22-Sept-1994
  11. Revision History:
  12. --*/
  13. # ifndef _DBGUTIL_H_
  14. # define _DBGUTIL_H_
  15. #ifndef _NO_TRACING_
  16. #include "pudebug.h"
  17. #else // !_NO_TRACING_
  18. // begin_user_modifiable
  19. //
  20. // Modify the following flags if necessary
  21. //
  22. # define DEFAULT_OUTPUT_FLAGS ( DbgOutputStderr | DbgOutputLogFile | \
  23. DbgOutputKdb | DbgOutputTruncate)
  24. // end_user_modifiable
  25. // begin_user_unmodifiable
  26. # if DBG
  27. /************************************************************
  28. * Include Headers
  29. ************************************************************/
  30. # include <pudebug.h>
  31. /***********************************************************
  32. * Macros
  33. ************************************************************/
  34. extern DEBUG_PRINTS * g_pDebug; // define a global debug variable
  35. # define DECLARE_DEBUG_PRINTS_OBJECT() \
  36. DEBUG_PRINTS * g_pDebug = NULL;
  37. //
  38. // Call the following macro as part of your initialization for program
  39. // planning to use the debugging class.
  40. //
  41. # define CREATE_DEBUG_PRINT_OBJECT( pszLabel) \
  42. g_pDebug = PuCreateDebugPrintsObject( pszLabel, DEFAULT_OUTPUT_FLAGS);\
  43. if ( g_pDebug == NULL) { \
  44. OutputDebugString( "Unable to Create Debug Print Object \n"); \
  45. }
  46. //
  47. // Call the following macro once as part of the termination of program
  48. // which uses the debugging class.
  49. //
  50. # define DELETE_DEBUG_PRINT_OBJECT( ) \
  51. g_pDebug = PuDeleteDebugPrintsObject( g_pDebug);
  52. # define VALID_DEBUG_PRINT_OBJECT() \
  53. ( ( g_pDebug != NULL) && g_pDebug->m_fInitialized)
  54. //
  55. // Use the DBG_CONTEXT without any surrounding braces.
  56. // This is used to pass the values for global DebugPrintObject
  57. // and File/Line information
  58. //
  59. # define DBG_CONTEXT g_pDebug, __FILE__, __LINE__
  60. # define DBG_CODE(s) s /* echoes code in debugging mode */
  61. # define DBG_ASSERT( exp) if ( !(exp)) { \
  62. PuDbgAssertFailed( DBG_CONTEXT, #exp, NULL); \
  63. } else {}
  64. # define DBG_ASSERT_MSG( exp, pszMsg) \
  65. if ( !(exp)) { \
  66. PuDbgAssertFailed( DBG_CONTEXT, #exp, pszMsg); \
  67. } else {}
  68. # define DBG_REQUIRE( exp) DBG_ASSERT( exp)
  69. # define DBG_LOG() PuDbgPrint( DBG_CONTEXT, "\n")
  70. # define DBG_OPEN_LOG_FILE( pszFile, pszPath) \
  71. PuOpenDbgPrintFile( g_pDebug, (pszFile), (pszPath))
  72. # define DBG_CLOSE_LOG_FILE( ) \
  73. PuCloseDbgPrintFile( g_pDebug)
  74. # define SET_DEBUG_PRINT_FLAGS( dwFlags) \
  75. PuSetDbgOutputFlags( g_pDebug, (dwFlags))
  76. # define GET_DEBUG_PRINT_FLAGS() \
  77. PuGetDbgOutputFlags( g_pDebug)
  78. //
  79. // DBGPRINTF() is printing function ( much like printf) but always called
  80. // with the DBG_CONTEXT as follows
  81. // DBGPRINTF( ( DBG_CONTEXT, format-string, arguments for format list);
  82. //
  83. # define DBGPRINTF( args) PuDbgPrint args
  84. # else // DBG
  85. # define DECLARE_DEBUG_PRINTS_OBJECT() /* Do Nothing */
  86. # define CREATE_DEBUG_PRINT_OBJECT( pszLabel) /* Do Nothing */
  87. # define DELETE_DEBUG_PRINT_OBJECT( ) /* Do Nothing */
  88. # define VALID_DEBUG_PRINT_OBJECT() ( TRUE)
  89. # define DBG_CODE(s) /* Do Nothing */
  90. # define DBG_ASSERT(exp) /* Do Nothing */
  91. # define DBG_ASSERT_MSG(exp, pszMsg) /* Do Nothing */
  92. # define DBG_REQUIRE( exp) ( (void) (exp))
  93. # define DBGPRINTF( args) /* Do Nothing */
  94. # define SET_DEBUG_PRINT_FLAGS( dwFlags) /* Do Nothing */
  95. # define GET_DEBUG_PRINT_FLAGS( ) ( 0)
  96. # define DBG_LOG() /* Do Nothing */
  97. # define DBG_OPEN_LOG_FILE( pszFile, pszPath) /* Do Nothing */
  98. # define DBG_CLOSE_LOG_FILE() /* Do Nothing */
  99. # endif // DBG
  100. // end_user_modifiable
  101. // begin_user_unmodifiable
  102. #ifdef ASSERT
  103. # undef ASSERT
  104. #endif
  105. # define ASSERT( exp) DBG_ASSERT( exp)
  106. //
  107. // Define the debugging constants
  108. //
  109. # define DEBUG_TEST1 0x00000001
  110. # define DEBUG_TEST2 0x00000002
  111. # if DBG
  112. extern DWORD g_dwDebugFlags; // Debugging Flags
  113. # define DECLARE_DEBUG_VARIABLE() \
  114. DWORD g_dwDebugFlags
  115. # define SET_DEBUG_FLAGS( dwFlags) g_dwDebugFlags = dwFlags
  116. # define GET_DEBUG_FLAGS() ( g_dwDebugFlags)
  117. # define DEBUG_IF( arg, s) if ( DEBUG_ ## arg & GET_DEBUG_FLAGS()) { \
  118. s \
  119. } else {}
  120. # define IF_DEBUG( arg) if ( DEBUG_## arg & GET_DEBUG_FLAGS())
  121. # else // DBG
  122. # define DECLARE_DEBUG_VARIABLE() /* Do Nothing */
  123. # define SET_DEBUG_FLAGS( dwFlags) /* Do Nothing */
  124. # define GET_DEBUG_FLAGS() ( 0)
  125. # define DEBUG_IF( arg, s) /* Do Nothing */
  126. # define IF_DEBUG( arg) if ( 0)
  127. # endif // DBG
  128. #endif // !_NO_TRACING_
  129. # endif /* _DBGUTIL_H_ */
  130. /************************ End of File ***********************/