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.

146 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. tracelog.h
  5. Abstract:
  6. This module contains public declarations and definitions for creating
  7. trace logs.
  8. A trace log is a fast, in-memory, threadsafe, circular activity log useful
  9. for debugging certain classes of problems. They are especially useful
  10. when debugging reference count bugs.
  11. Note that the creator of the log has the option of adding "extra"
  12. bytes to the log header. This can be useful if the creator wants to
  13. create a set of global logs, each on a linked list.
  14. Author:
  15. Keith Moore (keithmo) 10-Jun-1998
  16. Revision History:
  17. --*/
  18. #ifndef _TRACELOG_H_
  19. #define _TRACELOG_H_
  20. #if defined(__cplusplus)
  21. extern "C" {
  22. #endif // __cplusplus
  23. typedef struct _TRACE_LOG
  24. {
  25. //
  26. // Signature: TRACE_LOG_SIGNATURE;
  27. //
  28. ULONG Signature;
  29. //
  30. // TypeSignature: Ref, FiltQ, Irp, etc
  31. //
  32. ULONG TypeSignature;
  33. //
  34. // The total number of entries available in the log.
  35. //
  36. ULONG LogSize;
  37. //
  38. // The index of the next entry to use. For long runs in a busy
  39. // tracelog, a 32-bit index will overflow in a few days. Consider
  40. // what would happen if we jumped from OxFFFFFFFF (4,294,967,295) to
  41. // 0 when LogSize = 10,000: the index would jump from 7295 to 0,
  42. // leaving a large gap of stale records at the end, and !ulkd.ref
  43. // would not be able to find the preceding ones with high indices.
  44. //
  45. LONGLONG NextEntry;
  46. //
  47. // The byte size of each entry.
  48. //
  49. ULONG EntrySize;
  50. //
  51. // Pointer to the start of the circular buffer.
  52. //
  53. PUCHAR pLogBuffer;
  54. //
  55. // The extra header bytes and actual log entries go here.
  56. //
  57. // BYTE ExtraHeaderBytes[ExtraBytesInHeader];
  58. // BYTE Entries[LogSize][EntrySize];
  59. //
  60. } TRACE_LOG, *PTRACE_LOG;
  61. //
  62. // Log header signature.
  63. //
  64. #define TRACE_LOG_SIGNATURE ((LONG)'gOlT')
  65. #define TRACE_LOG_SIGNATURE_X MAKE_FREE_SIGNATURE(TRACE_LOG_SIGNATURE)
  66. //
  67. // This macro maps a TRACE_LOG pointer to a pointer to the 'extra'
  68. // data associated with the log.
  69. //
  70. #define TRACE_LOG_TO_EXTRA_DATA(log) (PVOID)( (log) + 1 )
  71. //
  72. // Manipulators.
  73. //
  74. // CODEWORK: think about adding alignment flags so that entries will always
  75. // be pointer-aligned on the hardware
  76. PTRACE_LOG
  77. CreateTraceLog(
  78. IN ULONG TypeSignature,
  79. IN ULONG LogSize,
  80. IN ULONG ExtraBytesInHeader,
  81. IN ULONG EntrySize
  82. );
  83. VOID
  84. DestroyTraceLog(
  85. IN PTRACE_LOG pLog
  86. );
  87. LONGLONG
  88. WriteTraceLog(
  89. IN PTRACE_LOG pLog,
  90. IN PVOID pEntry
  91. );
  92. VOID
  93. ResetTraceLog(
  94. IN PTRACE_LOG pLog
  95. );
  96. #if defined(__cplusplus)
  97. } // extern "C"
  98. #endif // __cplusplus
  99. #endif // _TRACELOG_H_