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.

156 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 2000-2002 Microsoft Corporation
  3. Module Name:
  4. uctrace.c
  5. Abstract:
  6. This module implements a tracing facility for the client.
  7. Author:
  8. Rajesh Sundaram (rajeshsu) - 17th July 2001.
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #if !DBG
  13. static int g_UcTraceDummyDeclarationToKeepW4WarningsQuiet;
  14. #else
  15. #ifdef ALLOC_PRAGMA
  16. #pragma alloc_text( PAGEUC, UcCreateTraceLog )
  17. #pragma alloc_text( PAGEUC, UcDestroyTraceLog )
  18. #pragma alloc_text( PAGEUC, UcWriteTraceLog )
  19. #endif
  20. /***************************************************************************++
  21. Routine Description:
  22. Creates a new (empty) trace log buffer.
  23. Arguments:
  24. LogSize - Supplies the number of entries in the log.
  25. ExtraBytesInHeader - Supplies the number of extra bytes to include
  26. in the log header. This is useful for adding application-
  27. specific data to the log.
  28. Return Value:
  29. PTRACE_LOG - Pointer to the newly created log if successful,
  30. NULL otherwise.
  31. --***************************************************************************/
  32. PTRACE_LOG
  33. UcCreateTraceLog(
  34. IN LONG LogSize,
  35. IN LONG ExtraBytesInHeader
  36. )
  37. {
  38. return CreateTraceLog(
  39. UC_TRACE_LOG_SIGNATURE,
  40. LogSize,
  41. ExtraBytesInHeader,
  42. sizeof(UC_TRACE_LOG_ENTRY),
  43. TRACELOG_HIGH_PRIORITY,
  44. UL_REF_TRACE_LOG_POOL_TAG
  45. );
  46. } // UcCreateTraceLog
  47. /***************************************************************************++
  48. Routine Description:
  49. Destroys a filter queue trace log buffer created with
  50. UcCreateTraceLog().
  51. Arguments:
  52. pLog - Supplies the filter queue trace log buffer to destroy.
  53. --***************************************************************************/
  54. VOID
  55. UcDestroyTraceLog(
  56. IN PTRACE_LOG pLog
  57. )
  58. {
  59. DestroyTraceLog( pLog, UL_REF_TRACE_LOG_POOL_TAG );
  60. } // UcDestroyTraceLog
  61. /***************************************************************************++
  62. Routine Description:
  63. Writes a new entry to the specified filter queue trace log.
  64. Arguments:
  65. pLog - Supplies the log to write to.
  66. ConnectionId - the id of the connection we're tracing
  67. RequestId - the id of the request we're tracing
  68. Action - Supplies an action code for the new log entry.
  69. --***************************************************************************/
  70. VOID
  71. UcWriteTraceLog(
  72. IN PTRACE_LOG pLog,
  73. IN USHORT Action,
  74. IN PVOID pContext1,
  75. IN PVOID pContext2,
  76. IN PVOID pContext3,
  77. IN PVOID pContext4,
  78. IN PVOID pFileName,
  79. IN USHORT LineNumber
  80. )
  81. {
  82. UC_TRACE_LOG_ENTRY entry;
  83. //
  84. // Initialize the entry.
  85. //
  86. entry.Action = Action;
  87. entry.Processor = (USHORT)KeGetCurrentProcessorNumber();
  88. entry.pProcess = PsGetCurrentProcess();
  89. entry.pThread = PsGetCurrentThread();
  90. entry.pContext1 = pContext1;
  91. entry.pContext2 = pContext2;
  92. entry.pContext3 = pContext3;
  93. entry.pContext4 = pContext4;
  94. entry.pFileName = pFileName;
  95. entry.LineNumber = LineNumber;
  96. //
  97. // Write it to the logs.
  98. //
  99. WriteTraceLog( pLog, &entry );
  100. } // UcWriteTraceLog
  101. #endif // DBG