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.

169 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. reftrace.c
  5. Abstract:
  6. This module implements a reference count tracing facility.
  7. Author:
  8. Keith Moore (keithmo) 01-May-1997
  9. Revision History:
  10. --*/
  11. #include "spudp.h"
  12. #if 0
  13. NOT PAGEABLE -- CreateRefTraceLog
  14. NOT PAGEABLE -- DestroyRefTraceLog
  15. NOT PAGEABLE -- WriteRefTraceLog
  16. #endif
  17. //
  18. // Public functions.
  19. //
  20. PTRACE_LOG
  21. CreateRefTraceLog(
  22. IN LONG LogSize,
  23. IN LONG ExtraBytesInHeader
  24. )
  25. /*++
  26. Routine Description:
  27. Creates a new (empty) ref count trace log buffer.
  28. Arguments:
  29. LogSize - The number of entries in the log.
  30. ExtraBytesInHeader - The number of extra bytes to include in the
  31. log header. This is useful for adding application-specific
  32. data to the log.
  33. Return Value:
  34. PTRACE_LOG - Pointer to the newly created log if successful,
  35. NULL otherwise.
  36. --*/
  37. {
  38. return CreateTraceLog(
  39. LogSize,
  40. ExtraBytesInHeader,
  41. sizeof(REF_TRACE_LOG_ENTRY)
  42. );
  43. } // CreateRefTraceLog
  44. VOID
  45. DestroyRefTraceLog(
  46. IN PTRACE_LOG Log
  47. )
  48. /*++
  49. Routine Description:
  50. Destroys a ref count trace log buffer created with CreateRefTraceLog().
  51. Arguments:
  52. Log - The ref count trace log buffer to destroy.
  53. Return Value:
  54. None.
  55. --*/
  56. {
  57. DestroyTraceLog( Log );
  58. } // DestroyRefTraceLog
  59. VOID
  60. WriteRefTraceLog(
  61. IN PTRACE_LOG Log,
  62. IN PVOID Object,
  63. IN ULONG Operation,
  64. IN PSTR FileName,
  65. IN ULONG LineNumber
  66. )
  67. /*++
  68. Routine Description:
  69. Writes a new entry to the specified ref count trace log. The entry
  70. written contains the object, operation (ref or deref), filename, and
  71. line number of the caller.
  72. Arguments:
  73. Log - The log to write to.
  74. Object - The object being referenced or dereferenced.
  75. Operation - Usually either +1 (ref) or -1 (deref).
  76. FileName - The file name of the caller.
  77. LineNumber - The line number of the caller.
  78. Return Value:
  79. None.
  80. --*/
  81. {
  82. REF_TRACE_LOG_ENTRY entry;
  83. POBJECT_HEADER header;
  84. //
  85. // Initialize the entry.
  86. //
  87. entry.Object = Object;
  88. entry.Operation = Operation;
  89. entry.FileName = FileName;
  90. entry.LineNumber = LineNumber;
  91. header = OBJECT_TO_OBJECT_HEADER( Object );
  92. entry.PointerCount = header->PointerCount;
  93. entry.HandleCount = header->HandleCount;
  94. entry.Type = header->Type;
  95. entry.Header = header;
  96. //
  97. // Write it to the log.
  98. //
  99. WriteTraceLog(
  100. Log,
  101. &entry
  102. );
  103. } // WriteRefTraceLog