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.

192 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. debug.h
  5. Abstract:
  6. This file contains debugging macros for the webdav client.
  7. Author:
  8. Andy Herron (andyhe) 30-Mar-1999
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. --*/
  13. #ifndef DAV_DEBUG_H
  14. #define DAV_DEBUG_H
  15. #if DBG
  16. //
  17. // Memory allocation and tracking
  18. //
  19. #define DEBUG_OUTPUT_BUFFER_SIZE 1024
  20. typedef struct _MEMORYBLOCK {
  21. HLOCAL hlocal;
  22. DWORD dwBytes;
  23. UINT uFlags;
  24. LPCSTR pszFile;
  25. UINT uLine;
  26. LPCSTR pszModule;
  27. LPCSTR pszComment;
  28. struct _MEMORYBLOCK *pNext;
  29. } MEMORYBLOCK, *LPMEMORYBLOCK;
  30. #define DEFAULT_MAXIMUM_DEBUGFILE_SIZE (1024 * 1024)
  31. //
  32. // Controls access to the memeory tracing routines. We need this since multiple
  33. // threads could be allocating memory simultaneously.
  34. //
  35. EXTERN CRITICAL_SECTION g_TraceMemoryCS;
  36. //
  37. // List of memory blocks (see the structure defined above) being maintained for
  38. // tracking memory.
  39. //
  40. EXTERN LPVOID g_TraceMemoryTable INIT_GLOBAL(NULL);
  41. //
  42. // Controls access to the debug log file. We need this since multiple threads
  43. // could be writing to it simultaneously.
  44. //
  45. EXTERN CRITICAL_SECTION DavGlobalDebugFileCritSect;
  46. //
  47. // These are used in persistent logging. They define the file handle of the
  48. // file to which the debug o/p is written, the max file size and the path
  49. // of the file.
  50. //
  51. EXTERN HANDLE DavGlobalDebugFileHandle INIT_GLOBAL(INVALID_HANDLE_VALUE);
  52. EXTERN ULONG DavGlobalDebugFileMaxSize INIT_GLOBAL(DEFAULT_MAXIMUM_DEBUGFILE_SIZE);
  53. EXTERN LPWSTR DavGlobalDebugSharePath;
  54. //
  55. // This flag (value) is used in filtering/controlling the debug messages.
  56. //
  57. EXTERN ULONG DavGlobalDebugFlag;
  58. #define DEBUG_DIR L"\\debug"
  59. #define DEBUG_FILE L"\\davclnt.log"
  60. #define DEBUG_BAK_FILE L"\\davclnt.bak"
  61. HLOCAL
  62. DebugAlloc(
  63. LPCSTR pszFile,
  64. UINT uLine,
  65. LPCSTR pszModule,
  66. UINT uFlags,
  67. DWORD dwBytes,
  68. LPCSTR pszComment
  69. );
  70. #define DavAllocateMemory(x) ( \
  71. DebugAlloc(__FILE__, \
  72. __LINE__, \
  73. "DAV", \
  74. LMEM_FIXED | LMEM_ZEROINIT, \
  75. x, \
  76. #x) \
  77. )
  78. HLOCAL
  79. DebugFree(
  80. HLOCAL hglobal
  81. );
  82. #define DavFreeMemory(x) DebugFree(x)
  83. VOID
  84. DebugInitialize(
  85. VOID
  86. );
  87. VOID
  88. DebugUninitialize(
  89. VOID
  90. );
  91. VOID
  92. DavAssertFailed(
  93. LPSTR FailedAssertion,
  94. LPSTR FileName,
  95. DWORD LineNumber,
  96. LPSTR Message
  97. );
  98. #define DavAssert(Predicate) { \
  99. if (!(Predicate)) { \
  100. DavAssertFailed( #Predicate, __FILE__, __LINE__, NULL ); \
  101. } \
  102. }
  103. #define DavAssertMsg(Predicate, Message) { \
  104. if (!(Predicate)) { \
  105. DavAssertFailed( #Predicate, __FILE__, __LINE__, #Message ); \
  106. } \
  107. }
  108. #define IF_DEBUG(flag) if (DavGlobalDebugFlag & (DEBUG_ ## flag))
  109. //
  110. // The debug flags used.
  111. //
  112. #define DEBUG_CONNECT 0x00000001 // connect events
  113. #define DEBUG_ERRORS 0x00000002 // errors
  114. #define DEBUG_INIT 0x00000004 // init events
  115. #define DEBUG_SCAVENGER 0x00000008 // sacvenger error
  116. #define DEBUG_REGISTRY 0x00000010 // Registry operation
  117. #define DEBUG_MISC 0x00000020 // misc info.
  118. #define DEBUG_RPC 0x00000040 // debug rpc messages
  119. #define DEBUG_MEMORY 0x00000080 // Memory Allocation Tracking Spew
  120. #define DEBUG_FUNC 0x00000100 // function entry/exit
  121. #define DEBUG_STARTUP_BRK 0x00000200 // breakin debugger during startup.
  122. #define DEBUG_LOG_IN_FILE 0x00000400 // log debug output in a file.
  123. #define DEBUG_DEBUG 0x00000800 // scope the debugging
  124. VOID
  125. DavPrintRoutine(
  126. IN DWORD DebugFlag,
  127. IN LPSTR Format,
  128. ...
  129. );
  130. #define DavPrint(_x_) DavPrintRoutine _x_;
  131. VOID
  132. DebugMemoryCheck(
  133. VOID
  134. );
  135. #else // not DBG
  136. #define DavAllocateMemory(x) LocalAlloc( LMEM_FIXED | LMEM_ZEROINIT, x)
  137. #define DavFreeMemory(x) LocalFree(x)
  138. #define IF_DEBUG(flag) if (FALSE)
  139. #define DavPrint(_x_)
  140. #define DavAssert(_x_)
  141. #define DavAssertMsg(_x_, _y_)
  142. #endif // DBG
  143. VOID
  144. DavClientEventLog(
  145. DWORD EventID,
  146. DWORD EventType,
  147. DWORD ErrorCode
  148. );
  149. #endif // DAV_DEBUG_H