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.

175 lines
5.5 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. * 15-jun-98 linstev added DPF2
  13. *@@END_MSINTERNAL
  14. *
  15. ***************************************************************************/
  16. #ifndef __DEBUGPF_H
  17. #define __DEBUGPF_H
  18. #include <stdarg.h>
  19. #include <windows.h>
  20. #ifndef DPF_MODNAME
  21. extern char * DPF_MODNAME;
  22. #endif
  23. #if defined(DEBUG) || defined(DBG)
  24. #undef DEBUG_TOPIC
  25. #define DEBUG_TOPIC(flag,name) flag,
  26. typedef enum DEBUG_TOPICS {
  27. A=1, /* For API Usage */
  28. #include "DBGTOPIC.H"
  29. LAST_TOPIC
  30. };
  31. #line 21
  32. /*
  33. #undef DBG
  34. #define DBG 1
  35. */
  36. #undef DEBUG
  37. #define DEBUG
  38. #if defined( _WIN32 ) && defined(WIN95)
  39. #define DEBUG_BREAK() _try { _asm { int 3 } } _except (EXCEPTION_EXECUTE_HANDLER) {;}
  40. #else
  41. #define DEBUG_BREAK() DebugBreak()
  42. #endif
  43. /*
  44. * DEBUG_TOPIC
  45. * This structure describes a debugging topic and associates a single-letter key to it.
  46. */
  47. #define DEBUG_TOPIC_NAME_LENGTH 59
  48. typedef struct
  49. {
  50. DWORD dwSize; //for versioning
  51. char cKey;
  52. char cName[DEBUG_TOPIC_NAME_LENGTH];
  53. } DPF_DEBUG_TOPIC;
  54. /*
  55. * PROC_STATS
  56. * This struct saves statistics about each proc as maintained by DebugEnterProc
  57. */
  58. typedef struct
  59. {
  60. char cName[DEBUG_TOPIC_NAME_LENGTH];
  61. DWORD dwCalls;
  62. #ifdef WIN32
  63. LARGE_INTEGER liTotalTime;
  64. LARGE_INTEGER liLastEnteredAt;
  65. #else
  66. DWORD dwFiller[8];
  67. #endif
  68. } DPF_PROC_STATS;
  69. #define MAX_PROC_ORDINAL 100
  70. #ifdef __cplusplus
  71. extern "C" {
  72. #endif
  73. /*
  74. * Debugging output/flow-control calls
  75. */
  76. extern void DebugSetTopicsAndLevels(char * pcTopicsAndLevelsToDisplay);
  77. extern void DebugHalt(void); //Break if control level allows
  78. extern int DebugSetFileLineEtc(LPSTR szFile, DWORD dwLineNumber,LPSTR szFnName);
  79. extern int DebugPrintf(DWORD dwDetail, ...);
  80. extern void DebugSetMute(BOOL bMuteFlag);
  81. extern void DebugPrintfInit(void);
  82. extern void DebugEnterAPI(char *,LPDWORD);
  83. extern void _DDAssert(LPCSTR szFile, int nLine, LPCSTR szCondition);
  84. extern int DebugPrintf2(LPSTR cFilter, ...);
  85. extern void cdecl D3DInfoPrintf( UINT lvl, LPSTR szFormat, ...);
  86. extern void cdecl D3DWarnPrintf( UINT lvl, LPSTR szFormat, ...);
  87. extern void cdecl D3DErrorPrintf( LPSTR szFormat, ...);
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #define dprintf(a,b) DebugPrintf(a,b);
  92. #define DPFINIT() DebugPrintfInit();
  93. #define DPF DebugSetFileLineEtc(__FILE__,__LINE__,DPF_MODNAME),DebugPrintf
  94. #define DPF_ERR(a) DebugSetFileLineEtc(__FILE__,__LINE__,DPF_MODNAME),DebugPrintf( 0, a )
  95. #define DPF_ENTERAPI(pIface) DebugEnterAPI(DPF_MODNAME,(LPDWORD)pIface)
  96. #define DPF_APIRETURNS(hr) DPF(3," %s returns %08x (%d)",DPF_MODNAME,hr,hr&0xfff)
  97. #define DDASSERT(condition) if (!(condition)) _DDAssert(__FILE__, __LINE__, #condition)
  98. #define DPF_MUTEWHEN(c) {DebugSetMute((BOOL) (c) );}
  99. #define DPF_SPEWWHEN(c) {DebugSetMute((BOOL) (!(c)) );}
  100. #define DPF_MUTE() DPF_MUTEWHEN(TRUE)
  101. #define DPF_UNMUTE() DPF_MUTEWHEN(FALSE)
  102. #define DPF_SETTOPICS(t)
  103. #define DPF_STRUCT(level,topic,struct_identifier,struct_ptr) {extern void DUMP_##struct_identifier(DWORD,DWORD,LP##struct_identifier);\
  104. DUMP_##struct_identifier(level,topic,struct_ptr);}
  105. #define D3D_ERR D3DErrorPrintf
  106. #define D3D_WARN D3DWarnPrintf
  107. #define D3D_INFO D3DInfoPrintf
  108. #else
  109. #pragma warning(disable:4002)
  110. #define dprintf()
  111. #define DPFINIT()
  112. #define DPFFINI()
  113. #define DPF()
  114. #define DPF_ENTERAPI()
  115. #define DPF_APIRETURNS()
  116. #define DPF_DUMP()
  117. #define DPF_DUMPHEX()
  118. #define DPF_DUMPGUID()
  119. #define DDASSERT()
  120. #define DPF_ERR()
  121. #define DEBUG_BREAK()
  122. #define DPF_MUTEWHEN()
  123. #define DPF_SPEWWHEN()
  124. #define DPF_MUTE()
  125. #define DPF_UNMUTE()
  126. #define DPF_SETTOPICS()
  127. #define DPF_DUMPGUID()
  128. #define DPF_STRUCT()
  129. #define D3D_ERR(a)
  130. #define D3D_WARN()
  131. #define D3D_INFO()
  132. #endif
  133. #ifdef _WIN32
  134. #ifdef DEBUG
  135. __inline DWORD clockrate() {LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.LowPart;}
  136. __inline DWORD clock() {LARGE_INTEGER li; QueryPerformanceCounter(&li); return li.LowPart;}
  137. #define TIMEVAR(t) DWORD t ## T; DWORD t ## N
  138. #define TIMEZERO(t) t ## T = 0, t ## N = 0
  139. #define TIMESTART(t) t ## T -= clock(), t ## N ++
  140. #define TIMESTOP(t) t ## T += clock()
  141. #define TIMEFMT(t) ((DWORD)(t) / clockrate()), (((DWORD)(t) * 1000 / clockrate())%1000)
  142. #define TIMEOUT(t) if (t ## N) DPF(4, #t ": %ld calls, %ld.%03ld sec (%ld.%03ld)", t ## N, TIMEFMT(t ## T), TIMEFMT(t ## T / t ## N))
  143. #else
  144. #define TIMEVAR(t)
  145. #define TIMEZERO(t)
  146. #define TIMESTART(t)
  147. #define TIMESTOP(t)
  148. #define TIMEFMT(t)
  149. #define TIMEOUT(t)
  150. #endif
  151. #endif
  152. #endif //__DEBUG_PF