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.

171 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. wintrace.h
  5. Abstract:
  6. This module contains public definitions of the wintrace debug system.
  7. Author:
  8. Michael Tsang (MikeTs) 01-May-2000
  9. Environment:
  10. User mode
  11. Revision History:
  12. --*/
  13. #ifndef _WINTRACE_H
  14. #define _WINTRACE_H
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. //
  19. // Constants
  20. //
  21. #define MAX_CLIENTNAME_LEN 16
  22. #define MAX_TRACETXT_LEN 256
  23. #define TRACETXT_MSGTYPE_MASK 0x00000003
  24. #define TRACETXT_MSGTYPE_NONE 0x00000000
  25. #define TRACETXT_MSGTYPE_INFO 0x00000001
  26. #define TRACETXT_MSGTYPE_WARN 0x00000002
  27. #define TRACETXT_MSGTYPE_ERROR 0x00000003
  28. #define TRACETXT_BREAK 0x80000000
  29. //
  30. // Macros
  31. //
  32. #ifndef EXPORT
  33. #define EXPORT __stdcall
  34. #endif
  35. #ifndef LOCAL
  36. #define LOCAL __stdcall
  37. #endif
  38. #ifdef WINTRACE
  39. #define TRACEINIT(p,t,v) TraceInit(p,t,v)
  40. #define TRACETERMINATE() TraceTerminate()
  41. #define TRACEPROC(s,n) static PSZ ProcName = s; \
  42. static int ProcLevel = n;
  43. #define TRACEENTER(p) { \
  44. if (IsTraceProcOn(ProcName, ProcLevel, TRUE))\
  45. { \
  46. TraceProc p; \
  47. } \
  48. giIndentLevel++; \
  49. if (gdwfTraceTxt & TRACETXT_BREAK) \
  50. { \
  51. DebugBreak(); \
  52. } \
  53. }
  54. #define TRACEEXIT(p) { \
  55. giIndentLevel--; \
  56. if (IsTraceProcOn(ProcName, ProcLevel, FALSE))\
  57. { \
  58. TraceProc p; \
  59. } \
  60. }
  61. #define TRACEMSG(t,n,p) if (IsTraceMsgOn(ProcName, n)) \
  62. { \
  63. gdwfTraceTxt |= (t); \
  64. TraceMsg p; \
  65. }
  66. #define TRACEINFO(n,p) TRACEMSG(TRACETXT_MSGTYPE_INFO, n, p)
  67. #define TRACEWARN(p) TRACEMSG(TRACETXT_MSGTYPE_WARN, 1, p)
  68. #define TRACEERROR(p) TRACEMSG(TRACETXT_MSGTYPE_ERROR, 0, p)
  69. #define TRACEASSERT(x) if (!(x)) \
  70. { \
  71. TRACEERROR(("Assertion failed in file %s " \
  72. "at line %d\n", \
  73. __FILE__, __LINE__)); \
  74. }
  75. #else
  76. #define TRACEINIT(p,t,v)
  77. #define TRACETERMINATE()
  78. #define TRACEPROC(s,n)
  79. #define TRACEENTER(p)
  80. #define TRACEEXIT(p)
  81. #define TRACEMSG(t,n,p)
  82. #define TRACEINFO(n,p)
  83. #define TRACEWARN(p)
  84. #define TRACEERROR(p)
  85. #define TRACEASSERT(x)
  86. #endif
  87. //
  88. // Type definitions
  89. //
  90. typedef struct _NAMETABLE
  91. {
  92. ULONG Code;
  93. PSZ pszName;
  94. } NAMETABLE, *PNAMETABLE;
  95. //
  96. // Exported Data
  97. //
  98. #ifdef WINTRACE
  99. extern int giIndentLevel;
  100. extern DWORD gdwfTraceTxt;
  101. extern NAMETABLE WMMsgNames[];
  102. #endif
  103. //
  104. // Exported function prototypes
  105. //
  106. #ifdef WINTRACE
  107. BOOL EXPORT
  108. TraceInit(
  109. IN PSZ pszClientName,
  110. IN int iDefTraceLevel,
  111. IN int iDefVerboseLevel
  112. );
  113. VOID EXPORT
  114. TraceTerminate(
  115. VOID
  116. );
  117. BOOL EXPORT
  118. IsTraceProcOn(
  119. IN PSZ pszProcName,
  120. IN int iProcLevel,
  121. IN BOOL fEnter
  122. );
  123. VOID EXPORT
  124. TraceProc(
  125. IN PSZ pszFormat,
  126. ...
  127. );
  128. BOOL EXPORT
  129. IsTraceMsgOn(
  130. IN PSZ pszProcName,
  131. IN int iVerboseLevel
  132. );
  133. VOID EXPORT
  134. TraceMsg(
  135. IN PSZ pszFormat,
  136. ...
  137. );
  138. PSZ EXPORT
  139. LookupName(
  140. IN ULONG Code,
  141. IN PNAMETABLE NameTable
  142. );
  143. #endif
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147. #endif //ifndef _WINTRACE_H