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.

190 lines
5.5 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1999 - 1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dndbg.h
  6. * Content: debug support functions for DirectNet
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 05-20-99 aarono Created
  12. * 07-16-99 johnkan Added DEBUG_ONLY, DBG_CASSERT, fixed DPFERR to take an argument
  13. * 08/31/99 rodtoll Added DVF_ defines for error levels
  14. * 09/01/99 rodtoll Added functions to check valid read/write pointers
  15. * 11/12/99 pnewson Added DVF_TRACELEVEL, DPF_ENTER(), DPF_EXIT(), DPFI()
  16. ***************************************************************************/
  17. #ifndef _DNDBG_H_
  18. #define DVF_ERRORLEVEL 0
  19. #define DVF_WARNINGLEVEL 1
  20. #define DVF_ENTRYLEVEL 2
  21. #define DVF_APIPARAM 3
  22. #define DVF_LOCKS 4
  23. #define DVF_INFOLEVEL 5
  24. #define DVF_STRUCTUREDUMP 6
  25. #define DVF_TRACELEVEL 9
  26. // The Windows NT build process currently defines DBG when it is
  27. // performing a debug build. Key off this to define DEBUG
  28. #if defined(DBG) && !defined(DEBUG)
  29. #define DEBUG 1
  30. #endif
  31. // each component should have a private dbginfo.h in its source directory
  32. // and should ensure that its source directory is first on the include
  33. // path.
  34. #include "dbginfo.h"
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. // DEBUG_BREAK()
  39. #if defined(DEBUG) || defined(DBG)
  40. #if defined( _WIN32 ) && !defined(WINNT)
  41. #define DEBUG_BREAK() _try { _asm { int 3 } } _except (EXCEPTION_EXECUTE_HANDLER) {;}
  42. #else
  43. #define DEBUG_BREAK() DebugBreak()
  44. #endif
  45. #endif
  46. //
  47. // macros used generate compile time messages
  48. //
  49. // you need to use these with #pragma, example
  50. //
  51. // #pragma TODO(ToddLa, "Fix this later!")
  52. //
  53. // to turn this off, set cl = /DTODO_OFF in your environment variables
  54. #define __TODO(e,m,n) message(__FILE__ "(" #n ") : TODO: " #e ": " m)
  55. #define _TODO(e,m,n) __TODO(e,m,n)
  56. #ifdef TODO_OFF
  57. #define TODO(e,m)
  58. #else
  59. #define TODO(e,m) _TODO(e,m,__LINE__)
  60. #endif
  61. //========================
  62. // Debug Logging support
  63. //========================
  64. /*=============================================================================
  65. Usage:
  66. In code, you can use DPF to print to the log or the debug windows of the
  67. running application. The format of DPF (debug printf) is as follows:
  68. DPF(level, string *fmt, arg1, arg2, ...);
  69. level specifies how important this debug printf is. The standard convention
  70. for debug levels is as follows. This is no way strictly enforced for
  71. personal use, but by the time the code is checked in, it should be as close
  72. to this as possible...
  73. 0: Error useful for application developers.
  74. 1: Warning useful for application developers.
  75. 2: API Entered
  76. 3: API parameters, API return values
  77. 4: Driver conversation
  78. 5: Deeper program flow notifications
  79. 6: Dump structures
  80. 9: Detailed program trace
  81. Note: please use the DVF_... macros defined above instead of raw numbers!
  82. When printing a critical error, you can use
  83. DPERR( "String" );
  84. which will print a string at debug level zero.
  85. In order to cause the code to stop and break in. You can use ASSERT() or
  86. DEBUG_BREAK(). In order for ASSERT to break in, you must have
  87. BreakOnAssert set in the win.ini file section (see osindep.cpp).
  88. =============================================================================*/
  89. #ifdef DEBUG
  90. extern BOOL IsValidWritePtr( LPVOID lpBuffer, DWORD dwSize );
  91. extern BOOL IsValidReadPtr( LPVOID lpBuffer, DWORD dwSize );
  92. extern void DebugSetLineInfo(LPSTR szFile, DWORD dwLineNumber,LPSTR szFnName);
  93. extern void DebugPrintf(volatile DWORD dwDetail, ...);
  94. extern void DebugPrintfNoLock(volatile DWORD dwDetail, ...);
  95. extern void DebugPrintfInit(void);
  96. extern void DebugPrintfFini(void);
  97. extern void _DNAssert(LPCSTR szFile, int nLine, LPCSTR szCondition);
  98. extern void LogPrintf(volatile DWORD dwDetail, ...);
  99. #define DNVALID_WRITEPTR(a,b) IsValidWritePtr(a,b)
  100. #define DNVALID_READPTR(a,b) IsValidReadPtr(a,b)
  101. #define DPF DebugSetLineInfo(__FILE__,__LINE__,DPF_MODNAME),DebugPrintf
  102. #define DPFERR( a ) DebugSetLineInfo(__FILE__,__LINE__,DPF_MODNAME),DebugPrintf( 0, a )
  103. #define DPFINIT() DebugPrintfInit();
  104. #define DPFFINI() DebugPrintfFini();
  105. #define DNASSERT(condition) if (!(condition)) _DNAssert(__FILE__, __LINE__, #condition)
  106. #if !defined DEBUG_ONLY
  107. #define DEBUG_ONLY( arg ) arg
  108. #endif
  109. #define DBG_CASSERT( exp ) switch (0) case 0: case exp:
  110. #if defined(INTERNAL_DPF_ENABLED)
  111. #define DPFI DPF
  112. #define DPF_ENTER() DPF(DVF_TRACELEVEL, "Enter");
  113. #define DPF_EXIT() DPF(DVF_TRACELEVEL, "Exit");
  114. #else
  115. #define DPFI()
  116. #define DPF_ENTER()
  117. #define DPF_EXIT()
  118. #endif
  119. #define dprintf(a,b) DebugPrintfNoLock(a,b);
  120. #ifdef DPF_SUBCOMP_MASK
  121. #define DPFSC if(DPF_SUBCOMP_MASK & DPF_SUBCOMP_BIT)DebugSetLineInfo(__FILE__,__LINE__,DPF_MODNAME),if(DPF_SUBCOMP_MASK & DPF_SUBCOMP_BIT)DebugPrintf
  122. #else
  123. #define DPFSC DPF
  124. #endif
  125. #define LOGPF LogPrintf
  126. #else /* NOT DEBUG */
  127. #pragma warning(disable:4002)
  128. #define DPF()
  129. #define DPFERR()
  130. #define DPFINIT()
  131. #define DPFFINI()
  132. #define DPFSC()
  133. #define DNASSERT()
  134. #if !defined DEBUG_ONLY
  135. #define DEBUG_ONLY()
  136. #endif
  137. #define DBG_CASSERT()
  138. #define dprintf()
  139. #define LOGPF()
  140. #define DNVALID_WRITEPTR(a,b) TRUE
  141. #define DNVALID_READPTR(a,b) TRUE
  142. #define DPF_ENTER()
  143. #define DPF_EXIT()
  144. #define DPFI()
  145. #endif /* DEBUG */
  146. #define WVSPRINTF wvsprintfA
  147. #define STRLEN lstrlenA
  148. #define PROF_SECT "DirectPlayVoice"
  149. //========================================
  150. // Memory Allocation Support and Tracking
  151. //========================================
  152. #ifdef __cplusplus
  153. } //extern "C"
  154. #endif
  155. #endif /* _DNDBG_H_ */