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.

177 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 2001-2002 Microsoft Corporation
  3. Module Name:
  4. strlogp.h
  5. Abstract:
  6. A tracelog for variable-length strings. Private definitions.
  7. Author:
  8. George V. Reilly 23-Jul-2001
  9. Revision History:
  10. --*/
  11. #ifndef _STRLOGP_H_
  12. #define _STRLOGP_H_
  13. #undef WriteGlobalStringLog
  14. #define STRING_LOG_SIGNATURE MAKE_SIGNATURE('$Log')
  15. #define STRING_LOG_SIGNATURE_X MAKE_FREE_SIGNATURE(STRING_LOG_SIGNATURE)
  16. #define STRING_LOG_ENTRY_SIGNATURE MAKE_SIGNATURE('$LE_')
  17. #define STRING_LOG_ENTRY_MULTI_SIGNATURE MAKE_SIGNATURE('$LE#')
  18. #define STRING_LOG_ENTRY_EOB_SIGNATURE MAKE_SIGNATURE('$LE@')
  19. #define STRING_LOG_ENTRY_LAST_SIGNATURE MAKE_SIGNATURE('$LE!')
  20. #define PRINTF_BUFFER_LEN_BITS 9
  21. #define PRINTF_BUFFER_LEN ((1 << PRINTF_BUFFER_LEN_BITS) - 1)
  22. #define STRING_LOG_MULTIPLE_ENTRIES 100
  23. #define STRING_LOG_PROCESSOR_BITS 6 // MAXIMUM_PROCESSORS == 64 on Win64
  24. C_ASSERT((1 << STRING_LOG_PROCESSOR_BITS) >= MAXIMUM_PROCESSORS);
  25. C_ASSERT(PRINTF_BUFFER_LEN_BITS + STRING_LOG_PROCESSOR_BITS <= 16);
  26. //
  27. // There are actually two kinds of STRING_LOG_ENTRYs, regular ones and
  28. // multi-entrys. A regular entry is immediately followed by a zero-terminated
  29. // string; a multi-entry is always followed by a regular entry.
  30. //
  31. // A regular entry uses PrevDelta to point back to the preceding entry
  32. // in the STRING_LOG circular log buffer. Starting at the end (as pointed to by
  33. // STRING_LOG::Offset and STRING_LOG::LastEntryLength), !strlog can walk
  34. // back through all the entries remaining in the circular log buffer.
  35. //
  36. // Multi-entrys allow !ulkd.strlog to skip multiple records, reducing the time
  37. // to walk back a few thousand entries from approximately a minute to under
  38. // a second.
  39. //
  40. typedef struct _STRING_LOG_ENTRY
  41. {
  42. // STRING_LOG_ENTRY_SIGNATURE
  43. ULONG Signature;
  44. // length of string, excluding trailing zeroes
  45. ULONG Length : PRINTF_BUFFER_LEN_BITS;
  46. // delta to beginning of previous entry
  47. ULONG PrevDelta : 1 + PRINTF_BUFFER_LEN_BITS;
  48. // processor executing WriteStringLog
  49. ULONG Processor : STRING_LOG_PROCESSOR_BITS;
  50. // timestamp. Broken into two ULONGs to minimize alignment constraints
  51. ULONG TimeStampLowPart;
  52. ULONG TimeStampHighPart;
  53. } STRING_LOG_ENTRY, *PSTRING_LOG_ENTRY;
  54. // Make sure that USHORT STRING_LOG_MULTI_ENTRY::PrevDelta will not overflow
  55. C_ASSERT((PRINTF_BUFFER_LEN + sizeof(STRING_LOG_ENTRY) + sizeof(ULONG))
  56. * STRING_LOG_MULTIPLE_ENTRIES
  57. < 0x10000);
  58. typedef struct _STRING_LOG_MULTI_ENTRY
  59. {
  60. ULONG Signature; // STRING_LOG_ENTRY_MULTI_SIGNATURE
  61. USHORT NumEntries; // number of regular entries
  62. USHORT PrevDelta; // delta to beginning of previous multi-entry
  63. } STRING_LOG_MULTI_ENTRY, *PSTRING_LOG_MULTI_ENTRY;
  64. typedef struct _STRING_LOG
  65. {
  66. //
  67. // Signature: STRING_LOG_SIGNATURE;
  68. //
  69. ULONG Signature;
  70. //
  71. // The total number of bytes in the string buffer, pLogBuffer
  72. //
  73. ULONG LogSize;
  74. //
  75. // Protects NextEntry and other data
  76. //
  77. KSPIN_LOCK SpinLock;
  78. //
  79. // The notional index of the next entry to record. Unlike regular
  80. // tracelogs, there is no random access to entries.
  81. //
  82. LONGLONG NextEntry;
  83. //
  84. // Offset within pLogBuffer at which next regular entry will be written
  85. //
  86. ULONG Offset;
  87. //
  88. // Number of times we have wrapped around
  89. //
  90. ULONG WrapAroundCount;
  91. //
  92. // Should we also call DbgPrint on each string?
  93. //
  94. BOOLEAN EchoDbgPrint;
  95. //
  96. // Size in bytes of previous entry
  97. //
  98. USHORT LastEntryLength;
  99. //
  100. // Walking back through thousands of entries one-by-one is slow.
  101. // We maintain a second-level index that skips back up to
  102. // STRING_LOG_MULTIPLE_ENTRIES at a time.
  103. //
  104. USHORT MultiNumEntries; // # regular entries since last multi-entry
  105. USHORT MultiByteCount; // # bytes since last multi-entry
  106. ULONG MultiOffset; // offset of last multi-entry from pLogBuffer
  107. //
  108. // Pointer to the start of the circular buffer of strings.
  109. //
  110. PUCHAR pLogBuffer;
  111. //
  112. // When was the first entry written? All other entries are timestamped
  113. // relative to this.
  114. //
  115. LARGE_INTEGER InitialTimeStamp;
  116. //
  117. // The extra header bytes and actual log entries go here.
  118. //
  119. // BYTE ExtraHeaderBytes[ExtraBytesInHeader];
  120. // BYTE Entries[LogSize];
  121. //
  122. } STRING_LOG, *PSTRING_LOG;
  123. #endif // _STRLOGP_H_