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.

269 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1990-1991 Microsoft Corporation
  3. Module Name:
  4. htdebug.h
  5. Abstract:
  6. This module contains all the debug definitions
  7. Author:
  8. 23-Apr-1992 Thu 20:01:55 updated -by- Daniel Chou (danielc)
  9. changed DBG_TIMEx structure fields' 'CHAR' type to 'BYTE' type, this
  10. will make sure if compiled under MIPS the default 'unsigned char' will
  11. not affect the signed operation on the single 8 bits
  12. 28-Mar-1992 Sat 20:54:09 updated -by- Daniel Chou (danielc)
  13. change DEF_DBGPVAR() marco so MIPS build does not complaint
  14. 20-Feb-1991 Wed 23:06:36 created -by- Daniel Chou (danielc)
  15. [Environment:]
  16. Printer Driver.
  17. [Notes:]
  18. Revision History:
  19. --*/
  20. #ifndef _HTDEBUG_
  21. #define _HTDEBUG_
  22. #if DBG
  23. #define TIMER_TOT 0
  24. #define TIMER_SETUP 1
  25. #define TIMER_INPUT 2
  26. #define TIMER_OUTPUT 3
  27. #define TIMER_MASK 4
  28. #define TIMER_LAST 5
  29. #define TIMER_MAX_IDX TIMER_LAST
  30. typedef struct _DBGTIMER {
  31. DWORD Last;
  32. DWORD Tot;
  33. } DBGTIMER, *PDBGTIMER;
  34. LPBYTE
  35. HTENTRY
  36. HT_LOADDS
  37. FD6ToString(
  38. LONG Num,
  39. SHORT IntDigits,
  40. WORD FracDigits
  41. );
  42. VOID
  43. cdecl
  44. HTENTRY
  45. HT_LOADDS
  46. DbgPrintf(
  47. LPSTR pStr,
  48. ...
  49. );
  50. VOID
  51. HTENTRY
  52. HT_LOADDS
  53. _MyAssert(
  54. LPSTR pMsg,
  55. LPSTR pFalseExp,
  56. LPSTR pFilename,
  57. WORD LineNo
  58. );
  59. LPSTR
  60. HTENTRY
  61. HT_LOADDS
  62. DbgTimeString(
  63. UINT Idx
  64. );
  65. #if defined(_OS2_) || defined(_OS_20_) || defined(_DOS_)
  66. #ifdef _DOS_ // if Dos Win3
  67. VOID
  68. FAR PASCAL
  69. DebugBreak(
  70. VOID
  71. );
  72. #define DEBUGOUTPUTFUNC(x) OutputDebugString(x)
  73. #else // if OS2
  74. VOID
  75. HTENTRY
  76. DebugBreak(
  77. VOID
  78. );
  79. VOID
  80. FAR PASCAL
  81. DebugOutput(
  82. LPSTR pStr
  83. );
  84. #define DEBUGOUTPUTFUNC(x) DebugOutput(x)
  85. #endif
  86. #define DBG_INSERT_CR_TO_LF
  87. #else // OS2/DOS
  88. #undef ASSERTMSG
  89. #undef ASSERT
  90. #ifdef UMODE
  91. #define DEBUGOUTPUTFUNC(x) OutputDebugString(x)
  92. #else
  93. void DrvDbgPrint(
  94. char * pch,
  95. ...);
  96. #define DEBUGOUTPUTFUNC(x) DrvDbgPrint(x)
  97. #endif
  98. #define DBG_INSERT_CR_TO_LF
  99. #endif // OS2/DOS
  100. #define ASSERTMSG(msg, exp) \
  101. if (!(exp)) { _MyAssert(msg, #exp, __FILE__, __LINE__); }
  102. #define ASSERT(exp) ASSERTMSG("-ERROR-",(exp))
  103. #ifdef UMODE
  104. #define DBGSTOP() DebugBreak()
  105. #else
  106. #define DBGSTOP() EngDebugBreak()
  107. #endif
  108. #define ARG(x) ,(x)
  109. #define ARGB(x) ,(BYTE)(x)
  110. #define ARGC(x) ,(CHAR)(x)
  111. #define ARGW(x) ,(WORD)(x)
  112. #define ARGS(x) ,(SHORT)(x)
  113. #define ARGU(x) ,(UINT)(x)
  114. #define ARGI(x) ,(INT)(x)
  115. #define ARGDW(x) ,(DWORD)(x)
  116. #define ARGL(x) ,(LONG)(x)
  117. #define ARGPTR(x) ,(LPVOID)(x)
  118. #define ARGFD6(x, i, f) ,FD6ToString((FD6)(x),(SHORT)(i),(WORD)(f))
  119. #define ARGFD6s(x) ARGFD6(x,0,0)
  120. #define ARGFD6l(x) ARGFD6(x,5,6)
  121. #define ARGTIME(i) ,DbgTimeString(i)
  122. #define DBGP(y) DbgPrintf(y)
  123. #define DBGMSG(y) DbgPrintf(y); DbgPrintf("\n");
  124. #define DEFDBGVAR(type, val) type val;
  125. #define SETDBGVAR(name, val) name=val
  126. extern UINT DbgTimerIdx;
  127. extern DBGTIMER DbgTimer[TIMER_MAX_IDX + 1];
  128. #ifdef UMODE
  129. #define GET_TICK (DWORD)GetTickCount()
  130. #else
  131. #define GET_TICK (DWORD)0
  132. #endif
  133. #define DBG_TIMER_BEG(i) DbgTimer[DbgTimerIdx=i].Last=GET_TICK
  134. #define DBG_TIMER_END(i) DbgTimer[i].Tot+=GET_TICK-DbgTimer[i].Last; \
  135. DbgTimerIdx = TIMER_LAST
  136. #define DBG_TIMER_RESET ZeroMemory(DbgTimer, sizeof(DbgTimer)); \
  137. DbgTimerIdx=TIMER_LAST; \
  138. DbgTimer[TIMER_TOT].Last=GET_TICK
  139. //
  140. // The following macros used for the DBGP_IF()
  141. //
  142. #ifdef DBGP_VARNAME
  143. #define DEF_DBGPVAR(x) DWORD DBGP_VARNAME = (x);
  144. #define DBGP_IF(v,y) if ((v) && ((v) & DBGP_VARNAME)) { y; }
  145. #else
  146. #define DEF_DBGPVAR(x)
  147. #define DBGP_IF(v,y)
  148. #endif
  149. #ifdef NODBGMSG
  150. #undef DBGP
  151. #undef DBGMSG
  152. #define DBGMSG(x)
  153. #define DBGP(y)
  154. #endif // NODBGMSG
  155. #else // DBG != 0
  156. #define ARG(x)
  157. #define ARGB(x)
  158. #define ARGC(x)
  159. #define ARGW(x)
  160. #define ARGS(x)
  161. #define ARGU(x)
  162. #define ARGI(x)
  163. #define ARGDW(x)
  164. #define ARGL(x)
  165. #define ARGFD6(x, i, f)
  166. #define ARGFD6s(x)
  167. #define ARGFD6l(x)
  168. #define ARGTIME(i)
  169. #define DBGSTOP()
  170. #define DBGMSG(x)
  171. #define DBGP(y)
  172. #define DEFDBGVAR(type, val)
  173. #define SETDBGVAR(name, val)
  174. #define DBG_TIMER_BEG(i)
  175. #define DBG_TIMER_END(i)
  176. #define DBG_TIMER_RESET
  177. #define DEF_DBGPVAR(x)
  178. #define DBGP_IF(v,y)
  179. #define ASSERT(exp)
  180. #define ASSERTMSG(msg,exp)
  181. #endif // DBG != 0
  182. #endif // _HTDEBUG_