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.

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