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.

166 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1998-2002 Microsoft Corporation
  3. Module Name:
  4. reftrace.h
  5. Abstract:
  6. This module contains public declarations and definitions for tracing
  7. and debugging reference count problems. This module uses the generic
  8. TRACE_LOG facility in tracelog.h.
  9. The REF_ACTION_* codes are declared separately in refaction.h
  10. Author:
  11. Keith Moore (keithmo) 10-Jun-1998
  12. Revision History:
  13. --*/
  14. #ifndef _REFTRACE_H_
  15. #define _REFTRACE_H_
  16. //
  17. // Pull in the action codes
  18. //
  19. #include "refaction.h"
  20. #define REF_TRACE_PROCESSOR_BITS 6 // MAXIMUM_PROCESSORS == 64 on Win64
  21. #define REF_TRACE_ACTION_BITS (16 - REF_TRACE_PROCESSOR_BITS)
  22. C_ASSERT((1 << REF_TRACE_PROCESSOR_BITS) >= MAXIMUM_PROCESSORS);
  23. C_ASSERT((1 << REF_TRACE_ACTION_BITS) >= REF_ACTION_MAX);
  24. #define REF_TRACE_CALL_STACK_DEPTH 3
  25. //
  26. // This defines the entry written to the trace log.
  27. //
  28. typedef struct _REF_TRACE_LOG_ENTRY
  29. {
  30. PVOID pContext;
  31. PCSTR pFileName;
  32. PETHREAD pThread;
  33. PVOID CallStack[REF_TRACE_CALL_STACK_DEPTH];
  34. LONG NewRefCount;
  35. USHORT LineNumber;
  36. USHORT Action : REF_TRACE_ACTION_BITS;
  37. USHORT Processor : REF_TRACE_PROCESSOR_BITS;
  38. } REF_TRACE_LOG_ENTRY, *PREF_TRACE_LOG_ENTRY;
  39. #define REF_TRACELOG_SIGNATURE MAKE_SIGNATURE('RfLg')
  40. //
  41. // Subtract REF_TRACE_OVERHEAD from a power of 2 when calculating the
  42. // number of entries in a reftrace log, to ensure that overall size is
  43. // a nice power of 2 and doesn't spill onto another page. This accounts
  44. // for the size of the TRACE_LOG struct itself and the overhead
  45. // imposed by the pool and the verifier. On x86, a REF_TRACE_LOG_ENTRY
  46. // is currently 32 bytes. If you modify the struct, please recalculate
  47. // REF_TRACE_OVERHEAD and *change the per-object* reftrace logs (in
  48. // UL_CONNECTION, UL_HTTP_CONNECTION, UL_TCI_INTERFACE,
  49. // and UL_INTERNAL_REQUEST) accordingly.
  50. //
  51. #define REF_TRACE_OVERHEAD 2 // entries
  52. //
  53. // Manipulators.
  54. //
  55. PTRACE_LOG
  56. CreateRefTraceLog(
  57. IN ULONG LogSize,
  58. IN ULONG ExtraBytesInHeader,
  59. IN TRACELOG_PRIORITY AllocationPriority,
  60. IN ULONG PoolTag
  61. );
  62. VOID
  63. DestroyRefTraceLog(
  64. IN PTRACE_LOG pLog,
  65. IN ULONG PoolTag
  66. );
  67. VOID
  68. ResetRefTraceLog(
  69. IN PTRACE_LOG pLog
  70. );
  71. LONGLONG
  72. WriteRefTraceLog(
  73. IN PTRACE_LOG pLog,
  74. IN PTRACE_LOG pLog2,
  75. IN USHORT Action,
  76. IN LONG NewRefCount,
  77. IN PVOID pContext,
  78. IN PCSTR pFileName,
  79. IN USHORT LineNumber
  80. );
  81. #if REFERENCE_DEBUG
  82. #define CREATE_REF_TRACE_LOG( ptr, size, extra, pri, pooltag ) \
  83. (ptr) = CreateRefTraceLog( (size), (extra), (pri), (pooltag) )
  84. #define DESTROY_REF_TRACE_LOG( ptr, pooltag ) \
  85. do \
  86. { \
  87. DestroyRefTraceLog( ptr, pooltag ); \
  88. (ptr) = NULL; \
  89. } while (FALSE, FALSE)
  90. #define RESET_REF_TRACE_LOG( ptr ) \
  91. ResetRefTraceLog( ptr )
  92. #define WRITE_REF_TRACE_LOG( plog, act, ref, pctx, pfile, line ) \
  93. WriteRefTraceLog( \
  94. (plog), \
  95. NULL, \
  96. (act), \
  97. (ref), \
  98. (pctx), \
  99. (pfile), \
  100. (line) \
  101. )
  102. #define WRITE_REF_TRACE_LOG2( plog1, plog2, act, ref, pctx, pfile, line ) \
  103. WriteRefTraceLog( \
  104. (plog1), \
  105. (plog2), \
  106. (act), \
  107. (ref), \
  108. (pctx), \
  109. (pfile), \
  110. (line) \
  111. )
  112. #else // !REFERENCE_DEBUG
  113. #define CREATE_REF_TRACE_LOG( ptr, size, extra, pri, pooltag ) NOP_FUNCTION
  114. #define DESTROY_REF_TRACE_LOG( ptr, pooltag ) NOP_FUNCTION
  115. #define RESET_REF_TRACE_LOG( ptr ) NOP_FUNCTION
  116. #define WRITE_REF_TRACE_LOG( plog, act, ref, pctx, pfile, line ) NOP_FUNCTION
  117. #define WRITE_REF_TRACE_LOG2( plog1, plog2 , act, ref, pctx, pfile, line ) \
  118. NOP_FUNCTION
  119. #endif // !REFERENCE_DEBUG
  120. #endif // _REFTRACE_H_