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.

187 lines
5.6 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: newdpf.h
  6. * Content: new debug printf
  7. *@@BEGIN_MSINTERNAL
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 10-oct-95 jeffno initial implementation
  12. *@@END_MSINTERNAL
  13. *
  14. ***************************************************************************/
  15. #ifndef __DEBUGPF_H
  16. #define __DEBUGPF_H
  17. #include <stdarg.h>
  18. #include <windows.h>
  19. #include <memlog.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #ifndef DPF_MODNAME
  24. extern char * DPF_MODNAME;
  25. #endif
  26. #if defined(DEBUG) || defined(DBG)
  27. #undef DEBUG_TOPIC
  28. #define DEBUG_TOPIC(flag,name) flag,
  29. typedef enum DEBUG_TOPICS {
  30. A=1, /* For API Usage */
  31. #include "DBGTOPIC.H"
  32. LAST_TOPIC
  33. };
  34. #line 21
  35. /*
  36. #undef DBG
  37. #define DBG 1
  38. */
  39. #undef DEBUG
  40. #define DEBUG
  41. #if defined( _WIN32 ) && !defined(WINNT)
  42. #define DEBUG_BREAK() _try { _asm { int 3 } } _except (EXCEPTION_EXECUTE_HANDLER) {;}
  43. #else
  44. #define DEBUG_BREAK() DebugBreak()
  45. #endif
  46. /*
  47. * DEBUG_TOPIC
  48. * This structure describes a debugging topic and associates a single-letter key to it.
  49. */
  50. #define DEBUG_TOPIC_NAME_LENGTH 59
  51. typedef struct
  52. {
  53. DWORD dwSize; //for versioning
  54. char cKey;
  55. char cName[DEBUG_TOPIC_NAME_LENGTH];
  56. } DPF_DEBUG_TOPIC;
  57. /*
  58. * PROC_STATS
  59. * This struct saves statistics about each proc as maintained by DebugEnterProc
  60. */
  61. typedef struct
  62. {
  63. char cName[DEBUG_TOPIC_NAME_LENGTH];
  64. DWORD dwCalls;
  65. #ifdef WIN32
  66. LARGE_INTEGER liTotalTime;
  67. LARGE_INTEGER liLastEnteredAt;
  68. #else
  69. DWORD dwFiller[8];
  70. #endif
  71. } DPF_PROC_STATS;
  72. #define MAX_PROC_ORDINAL 100
  73. /*
  74. * Debugging output/flow-control calls
  75. */
  76. typedef struct {
  77. UINT stat_ThrottleRate;
  78. UINT stat_BytesSent;
  79. UINT stat_BackLog;
  80. UINT stat_BytesLost;
  81. UINT stat_RemBytesReceived;
  82. UINT stat_Latency;
  83. UINT stat_MinLatency;
  84. UINT stat_AvgLatency;
  85. UINT stat_AvgDevLatency;
  86. UINT stat_USER1;
  87. UINT stat_USER2;
  88. UINT stat_USER3;
  89. UINT stat_USER4;
  90. UINT stat_USER5; // remote tDelta
  91. UINT stat_USER6; // Remote tDelta sign (0=+ve, 1=-ve)
  92. } IN_WRITESTATS, *PIN_WRITESTATS;
  93. typedef struct {
  94. UINT hr;
  95. } OUT_WRITESTATS, *POUT_WRITESTATS;
  96. extern void DbgWriteStats(PIN_WRITESTATS pIn);
  97. extern void DebugSetTopicsAndLevels(char * pcTopicsAndLevelsToDisplay);
  98. extern void DebugHalt(void); //Break if control level allows
  99. extern int DebugSetFileLineEtc(LPSTR szFile, DWORD dwLineNumber,LPSTR szFnName);
  100. extern int DebugPrintf(volatile DWORD dwDetail, ...);
  101. extern void DebugSetMute(BOOL bMuteFlag);
  102. extern void DebugPrintfInit(void);
  103. extern void DebugEnterAPI(char *,LPDWORD);
  104. extern void _DDAssert(LPCSTR szFile, int nLine, LPCSTR szCondition);
  105. #define dprintf(a,b) DebugPrintf(a,b);
  106. #define DPFINIT() DebugPrintfInit();
  107. #define DPF DebugSetFileLineEtc(__FILE__,__LINE__,DPF_MODNAME),DebugPrintf
  108. #define DPF_ERR(a) DebugSetFileLineEtc(__FILE__,__LINE__,DPF_MODNAME),DebugPrintf( 0, a )
  109. #define DPF_ENTERAPI(pIface) DebugEnterAPI(DPF_MODNAME,(LPDWORD)pIface)
  110. #define DPF_APIRETURNS(hr) DPF(3," %s returns %08x (%d)",DPF_MODNAME,hr,hr&0xfff)
  111. #define DDASSERT(condition) if (!(condition)) _DDAssert(__FILE__, __LINE__, #condition)
  112. #define DPF_MUTEWHEN(c) {DebugSetMute((BOOL) (c) );}
  113. #define DPF_SPEWWHEN(c) {DebugSetMute((BOOL) (!(c)) );}
  114. #define DPF_SETTOPICS(t)
  115. #define DPF_STRUCT(level,topic,struct_identifier,struct_ptr) {extern void DUMP_##struct_identifier(DWORD,DWORD,LP##struct_identifier);\
  116. DUMP_##struct_identifier(level,topic,struct_ptr);}
  117. #else
  118. #pragma warning(disable:4002)
  119. #define DbgWriteStats()
  120. #define dprintf()
  121. #define DPFINIT()
  122. #define DPFFINI()
  123. #define DPF()
  124. #define DPF_ENTERAPI()
  125. #define DPF_APIRETURNS()
  126. #define DPF_DUMP()
  127. #define DPF_DUMPHEX()
  128. #define DPF_DUMPGUID()
  129. #define DDASSERT()
  130. #define DPF_ERR()
  131. #define DEBUG_BREAK()
  132. #define DPF_MUTEWHEN()
  133. #define DPF_SPEWWHEN()
  134. #define DPF_SETTOPICS()
  135. #define DPF_DUMPGUID()
  136. #define DPF_STRUCT()
  137. #endif
  138. #ifdef _WIN32
  139. #ifdef DEBUG
  140. __inline DWORD myclockrate() {LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.LowPart;}
  141. __inline DWORD myclock() {LARGE_INTEGER li; QueryPerformanceCounter(&li); return li.LowPart;}
  142. #define TIMEVAR(t) DWORD t ## T; DWORD t ## N
  143. #define TIMEZERO(t) t ## T = 0, t ## N = 0
  144. #define TIMESTART(t) t ## T -= myclock(), t ## N ++
  145. #define TIMESTOP(t) t ## T += myclock()
  146. #define TIMEFMT(t) ((DWORD)(t) / myclockrate()), (((DWORD)(t) * 1000 / myclockrate())%1000)
  147. #define TIMEOUT(t) if (t ## N) DPF(1, #t ": %ld calls, %ld.%03ld sec (%ld.%03ld)", t ## N, TIMEFMT(t ## T), TIMEFMT(t ## T / t ## N))
  148. #else
  149. #define TIMEVAR(t)
  150. #define TIMEZERO(t)
  151. #define TIMESTART(t)
  152. #define TIMESTOP(t)
  153. #define TIMEFMT(t)
  154. #define TIMEOUT(t)
  155. #endif
  156. #endif
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif //__DEBUG_PF