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.

154 lines
3.7 KiB

  1. //
  2. // TRACEINT.H
  3. //
  4. // Async tracing internal include file
  5. //
  6. #include "dbgtrace.h"
  7. #include "dbgfile.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #ifndef ASSERT
  12. #define ASSERT( x ) (x) ? 1 : DebugBreak()
  13. #endif
  14. #define MAX_BUFFER_SIZE 160
  15. #define MAX_FILENAME_SIZE 16
  16. #define MAX_FUNCTNAME_SIZE 32
  17. #define TRACE_SIGNATURE (DWORD)'carT'
  18. //
  19. // +2 == potential CR+LF
  20. //
  21. #define MAX_VARIABLE_SIZE (MAX_FILENAME_SIZE + MAX_FUNCTNAME_SIZE + MAX_BUFFER_SIZE)
  22. #define MAX_TRACE_ENTRY_SIZE (sizeof(FIXEDTRACE) + MAX_VARIABLE_SIZE)
  23. typedef struct tagSPECIALBUF
  24. {
  25. DWORD dwSignature;
  26. struct tagTRACEBUF *pNext;
  27. } SPECIALBUF, * LPSPECIALBUF;
  28. typedef struct tagTRACEBUF
  29. {
  30. DWORD dwSignature;
  31. struct tagTRACEBUF *pNext;
  32. DWORD dwLastError;
  33. //
  34. // fixed buffer committed to permanent storage ( ie disk )
  35. //
  36. #pragma pack(2)
  37. FIXEDTRACE Fixed;
  38. char Buffer[MAX_VARIABLE_SIZE];
  39. #pragma pack()
  40. } TRACEBUF, * LPTRACEBUF;
  41. #define MAX_WRITE_BUFFER_SIZE 16*1024
  42. typedef struct tagPENDQ
  43. {
  44. LPTRACEBUF pHead;
  45. LPTRACEBUF pTail;
  46. SPECIALBUF Special;
  47. HANDLE hEvent;
  48. HANDLE hFlushEvent;
  49. HANDLE hFlushedEvent;
  50. DWORD dwCount;
  51. DWORD dwThresholdCount;
  52. DWORD dwProcessId;
  53. BOOL fShutdown;
  54. HANDLE hWriteThread;
  55. HANDLE hRegNotifyThread;
  56. HANDLE hFile;
  57. CRITICAL_SECTION critSecTail;
  58. HANDLE hFileMutex;
  59. DWORD cbBufferEnd;
  60. char Buffer[MAX_WRITE_BUFFER_SIZE];
  61. } PENDQ, * LPPENDQ;
  62. ////////////////////////////////////////////////////////////////////////////////
  63. ////////////////////////////////////////////////////////////////////////////////
  64. //
  65. // These are the real functions for tracing.
  66. //
  67. extern DWORD* INTERNAL__dwEnabledTraces;
  68. BOOL WINAPI INTERNAL__InitAsyncTrace ( DWORD* dwEnabledTraces );
  69. BOOL WINAPI INTERNAL__TermAsyncTrace ( void );
  70. BOOL WINAPI INTERNAL__FlushAsyncTrace( void );
  71. void WINAPI INTERNAL__DebugAssert( DWORD dwLine, LPCSTR lpszFunction, LPCSTR lpszExpression );
  72. int WINAPI INTERNAL__SetAsyncTraceParams( LPCSTR pszFile, int iLine, LPCSTR szFunction, DWORD dwTraceMask );
  73. int WINAPI INTERNAL__AsyncStringTrace( LPARAM lParam, LPCSTR szFormat , va_list marker );
  74. int WINAPI INTERNAL__AsyncBinaryTrace( LPARAM lParam, DWORD dwBinaryType, LPBYTE pbData, DWORD cbData );
  75. ////////////////////////////////////////////////////////////////////////////////
  76. ////////////////////////////////////////////////////////////////////////////////
  77. //
  78. // Internal Function declarations
  79. //
  80. extern BOOL WINAPI InitTraceBuffers( DWORD dwThresholdCount, DWORD dwIncrement );
  81. extern void WINAPI TermTraceBuffers( void );
  82. extern LPTRACEBUF WINAPI GetTraceBuffer( void );
  83. extern void WINAPI FreeTraceBuffer( LPTRACEBUF lpBuf );
  84. extern LPTRACEBUF DequeueAsyncTraceBuffer( void );
  85. extern void QueueAsyncTraceBuffer( LPTRACEBUF lpBuf );
  86. extern DWORD WriteTraceThread( LPDWORD lpdw );
  87. extern BOOL WriteTraceBuffer( LPTRACEBUF lpBuf );
  88. extern BOOL AsyncTraceCleanup( void );
  89. extern BOOL GetTraceFlagsFromRegistry( void );
  90. extern DWORD RegNotifyThread( LPDWORD lpdw );
  91. extern PENDQ PendQ;
  92. extern BOOL fInitialized;
  93. extern HANDLE hShutdownEvent;
  94. extern DWORD dwNumTraces;
  95. extern DWORD dwTraceOutputType;
  96. extern DWORD dwAsyncTraceFlag;
  97. extern int nAsyncThreadPriority;
  98. extern DWORD dwMaxFileSize;
  99. extern DWORD dwIncrementSize;
  100. #define DEFAULT_MAX_FILE_SIZE 1024*1024*5 // 5 megabytes
  101. #define AVERAGE_TRACE_SIZE ( sizeof(FIXEDTRACE) + 64 )
  102. extern CRITICAL_SECTION critSecWrite;
  103. #ifdef TRACE_ENABLED
  104. extern void CDECL InternalTrace( const char *s, ... );
  105. #define INT_TRACE InternalTrace
  106. #else
  107. __inline void CDECL InternalTrace( const char *s, ... ) {}
  108. #define INT_TRACE 1 ? (void)0 : InternalTrace
  109. #endif
  110. #ifdef __cplusplus
  111. }
  112. #endif