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.

141 lines
3.4 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. #if !defined(DllExport)
  12. #define DllExport __declspec( dllexport )
  13. #endif
  14. #ifndef ASSERT
  15. #define ASSERT( x ) (x) ? 1 : DebugBreak()
  16. #endif
  17. #define MAX_BUFFER_SIZE 200
  18. #define MAX_FILENAME_SIZE 16
  19. #define MAX_FUNCTNAME_SIZE 32
  20. #define TRACE_SIGNATURE (DWORD)'carT'
  21. //
  22. // +2 == potential CR+LF
  23. //
  24. #define MAX_VARIABLE_SIZE (MAX_FILENAME_SIZE + MAX_FUNCTNAME_SIZE + MAX_BUFFER_SIZE)
  25. #define MAX_TRACE_ENTRY_SIZE (sizeof(FIXEDTRACE) + MAX_VARIABLE_SIZE)
  26. typedef struct tagSPECIALBUF
  27. {
  28. DWORD dwSignature;
  29. struct tagTRACEBUF *pNext;
  30. } SPECIALBUF, * LPSPECIALBUF;
  31. typedef struct tagTRACEBUF
  32. {
  33. DWORD dwSignature;
  34. struct tagTRACEBUF *pNext;
  35. DWORD dwLastError;
  36. //
  37. // fixed buffer committed to permanent storage ( ie disk )
  38. //
  39. #pragma pack(2)
  40. FIXEDTRACE Fixed;
  41. char Buffer[MAX_VARIABLE_SIZE];
  42. #pragma pack()
  43. } TRACEBUF, * LPTRACEBUF;
  44. #define MAX_WRITE_BUFFER_SIZE 16*1024
  45. typedef struct tagPENDQ
  46. {
  47. LPTRACEBUF pHead;
  48. LPTRACEBUF pTail;
  49. SPECIALBUF Special;
  50. HANDLE hEvent;
  51. HANDLE hFlushEvent;
  52. HANDLE hFlushedEvent;
  53. DWORD dwCount;
  54. DWORD dwThresholdCount;
  55. DWORD dwProcessId;
  56. BOOL fShutdown;
  57. HANDLE hWriteThread;
  58. HANDLE hRegNotifyThread;
  59. HANDLE hFile;
  60. CRITICAL_SECTION critSecTail;
  61. HANDLE hFileMutex;
  62. DWORD cbBufferEnd;
  63. char Buffer[MAX_WRITE_BUFFER_SIZE];
  64. } PENDQ, * LPPENDQ;
  65. //
  66. // Internal Function declarations
  67. //
  68. extern BOOL WINAPI InitTraceBuffers( DWORD dwThresholdCount, DWORD dwIncrement );
  69. extern void WINAPI TermTraceBuffers( void );
  70. extern LPTRACEBUF WINAPI GetTraceBuffer( void );
  71. extern void WINAPI FreeTraceBuffer( LPTRACEBUF lpBuf );
  72. extern LPTRACEBUF DequeueAsyncTraceBuffer( void );
  73. extern void QueueAsyncTraceBuffer( LPTRACEBUF lpBuf );
  74. extern DWORD WriteTraceThread( LPDWORD lpdw );
  75. extern BOOL WriteTraceBuffer( LPTRACEBUF lpBuf );
  76. extern BOOL AsyncTraceCleanup( void );
  77. extern BOOL GetTraceFlagsFromRegistry( void );
  78. extern DWORD RegNotifyThread( LPDWORD lpdw );
  79. extern BOOL ShouldLogModule( LPCSTR szModule );
  80. extern PENDQ PendQ;
  81. extern BOOL fInitialized;
  82. extern HANDLE hShutdownEvent;
  83. extern DWORD dwNumTraces;
  84. extern DWORD dwTraceOutputType;
  85. extern DWORD dwAsyncTraceFlag;
  86. extern int nAsyncThreadPriority;
  87. extern DWORD dwMaxFileSize;
  88. extern DWORD dwIncrementSize;
  89. #define MODULES_BUFFER_SIZE 2048
  90. extern CHAR mszModules[];
  91. #define DEFAULT_MAX_FILE_SIZE 1024*1024*5 // 5 megabytes
  92. #define AVERAGE_TRACE_SIZE ( sizeof(FIXEDTRACE) + 64 )
  93. extern CRITICAL_SECTION critSecWrite;
  94. #ifdef TRACE_ENABLED
  95. extern void CDECL InternalTrace( const char *s, ... );
  96. #define INT_TRACE InternalTrace
  97. #else
  98. __inline void CDECL InternalTrace( const char *s, ... ) {}
  99. #define INT_TRACE 1 ? (void)0 : InternalTrace
  100. #endif
  101. #ifdef __cplusplus
  102. }
  103. #endif