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.

123 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. kdlog.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Neil Sandlin (neilsa) 31-Oct-2000
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. DECLARE_API( kdlog )
  16. /*++
  17. Routine Description:
  18. This routine dumps the KdLog buffer. This is logging data created
  19. by the KD client code (e.g. KD1394.DLL).
  20. Arguments:
  21. args - not used
  22. Return Value:
  23. None
  24. --*/
  25. {
  26. ULONG64 LogContext;
  27. ULONG64 Index, LastIndex, Count, EntryLength, TotalLogged;
  28. ULONG64 LogData;
  29. CHAR buffer[256];
  30. ULONG64 LogEntry;
  31. ULONG bytesRead;
  32. LogContext = GetExpression("kdcom!KdLogContext");
  33. if (LogContext == 0) {
  34. LogContext = GetExpression("kd1394!KdLogContext");
  35. if (LogContext == 0) {
  36. dprintf("Error resolving address of hal!KdDebuggerLogContext\n");
  37. return E_INVALIDARG;
  38. }
  39. }
  40. if (GetFieldValue(LogContext, "_KD_DBG_LOG_CONTEXT", "Index", Index)) {
  41. dprintf("Error resolving field 'Index'\n");
  42. return E_INVALIDARG;
  43. }
  44. if (GetFieldValue(LogContext, "_KD_DBG_LOG_CONTEXT", "LastIndex", LastIndex)) {
  45. dprintf("Error resolving field 'LastIndex'\n");
  46. return E_INVALIDARG;
  47. }
  48. if (GetFieldValue(LogContext, "_KD_DBG_LOG_CONTEXT", "Count", Count)) {
  49. dprintf("Error resolving field 'Count'\n");
  50. return E_INVALIDARG;
  51. }
  52. if (GetFieldValue(LogContext, "_KD_DBG_LOG_CONTEXT", "EntryLength", EntryLength)) {
  53. dprintf("Error resolving field 'EntryLength'\n");
  54. return E_INVALIDARG;
  55. }
  56. if (GetFieldValue(LogContext, "_KD_DBG_LOG_CONTEXT", "TotalLogged", TotalLogged)) {
  57. dprintf("Error resolving field 'TotalLogged'\n");
  58. return E_INVALIDARG;
  59. }
  60. if (GetFieldValue(LogContext, "_KD_DBG_LOG_CONTEXT", "LogData", LogData)) {
  61. dprintf("Error resolving field 'Index'\n");
  62. return E_INVALIDARG;
  63. }
  64. dprintf("Context Ptr %.8p TotalLogged %.8p EntryLength %.8p\n", LogContext, TotalLogged, EntryLength);
  65. dprintf("Index %.8p LastIndex %.8p Count %.8p LogData %.8p\n\n", Index, LastIndex, Count, LogData);
  66. if (EntryLength > 256) {
  67. dprintf("Entry length %d too long\n", EntryLength);
  68. return E_INVALIDARG;
  69. }
  70. Index = ((Index - Count) + (LastIndex+1)) % (LastIndex+1);
  71. while(Count--) {
  72. if (CheckControlC()) {
  73. return S_OK;
  74. }
  75. LogEntry = LogData + Index*EntryLength;
  76. if (!ReadMemory(LogEntry, buffer, (ULONG)EntryLength, &bytesRead)) {
  77. dprintf("ReadMemory error at %.8p\n", LogEntry);
  78. return E_INVALIDARG;
  79. }
  80. dprintf("%s", buffer);
  81. Index++;
  82. if (Index == (LastIndex+1)) {
  83. Index = 0;
  84. }
  85. }
  86. return S_OK;
  87. }