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.

236 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. thermal
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Environment:
  9. User Mode.
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. #include "devnode.h"
  14. #pragma hdrstop
  15. DECLARE_API(locks);
  16. BOOLEAN
  17. DumpDeviceActionEntry(
  18. IN PDEBUG_CLIENT pDbgClient,
  19. IN ULONG64 Entry
  20. )
  21. {
  22. ULONG64 deviceObject, requestType, requestArgument, module;
  23. ULONG typeId;
  24. CHAR name[MAX_PATH];
  25. dprintf("Dumping nt!_PI_DEVICE_REQUEST @ 0x%08p\n", Entry);
  26. if (GetFieldValue(Entry, "nt!_PI_DEVICE_REQUEST", "DeviceObject", deviceObject)) {
  27. dprintf("Error reading entry->DeviceObject (%#010p)\n", Entry);
  28. return FALSE;
  29. }
  30. if (GetFieldValue(Entry, "nt!_PI_DEVICE_REQUEST", "RequestType", requestType)) {
  31. dprintf("Error reading entry->RequestType (%#010p)\n", Entry);
  32. return FALSE;
  33. }
  34. if (ExtQuery(pDbgClient) != S_OK) {
  35. dprintf("Could not query debugger information\n");
  36. return FALSE;
  37. }
  38. if (g_ExtSymbols->GetSymbolTypeId("nt!_DEVICE_REQUEST_TYPE", &typeId, &module) != S_OK) {
  39. dprintf("Error reading name for request type\n");
  40. return FALSE;
  41. }
  42. if (g_ExtSymbols->GetConstantName(module, typeId, requestType, name, sizeof(name), NULL) != S_OK) {
  43. dprintf("Error reading name for request type\n");
  44. return FALSE;
  45. }
  46. dprintf("\tRequest to %s", name);
  47. if (deviceObject) {
  48. dprintf(" !devstack %08p\n", deviceObject);
  49. } else {
  50. dprintf("\n");
  51. }
  52. if (GetFieldValue(Entry, "nt!_PI_DEVICE_REQUEST", "RequestArgument", requestArgument)) {
  53. dprintf("Error reading entry->RequestType (%#010p)\n", Entry);
  54. return FALSE;
  55. }
  56. dprintf("\tArgument - %08p\n", requestArgument);
  57. ExtRelease();
  58. return TRUE;
  59. }
  60. DECLARE_API(pnpaction)
  61. /*++
  62. Routine Description:
  63. Dumps device action queue.
  64. Arguments:
  65. args - Verbosity.
  66. Return Value:
  67. None
  68. --*/
  69. {
  70. ULONG64 deviceActionListAddress, enumerationInProgressAddress;
  71. ULONG64 link, deviceActionEntry;
  72. ULONG offset, dummy;
  73. BOOLEAN enumerationInProgress;
  74. enumerationInProgressAddress = GetExpression("nt!PipEnumerationInProgress");
  75. if (enumerationInProgressAddress == 0) {
  76. dprintf("Error retrieving address of nt!PipEnumerationInProgress\n");
  77. return E_INVALIDARG;
  78. }
  79. enumerationInProgress = FALSE;
  80. if (!ReadMemory(enumerationInProgressAddress, &enumerationInProgress, sizeof(enumerationInProgress), &dummy)) {
  81. dprintf("Error retrieving value of nt!IopPnpEnumerationRequestList\n");
  82. return E_INVALIDARG;
  83. }
  84. deviceActionListAddress = GetExpression("nt!IopPnpEnumerationRequestList");
  85. if (deviceActionListAddress == 0) {
  86. dprintf("Error retrieving address of nt!IopPnpEnumerationRequestList\n");
  87. return E_INVALIDARG;
  88. }
  89. dprintf("\n********************************************************************************\n");
  90. dprintf("Dumping PnP DeviceAction Queue @ 0x%08p\n", deviceActionListAddress);
  91. dprintf("********************************************************************************\n\n");
  92. if (GetFieldValue(deviceActionListAddress, "nt!_LIST_ENTRY", "Flink", link)) {
  93. dprintf("Error reading IopPnpEnumerationRequestList.Flink (%#010p)\n", deviceActionListAddress);
  94. return E_INVALIDARG;
  95. }
  96. if (GetFieldOffset("nt!_PI_DEVICE_REQUEST", "ListEntry", &offset)) {
  97. dprintf("Cannot find nt!_PI_DEVICE_REQUEST type.\n");
  98. return E_INVALIDARG;
  99. }
  100. while (link != deviceActionListAddress && CheckControlC() == FALSE) {
  101. deviceActionEntry = link - offset; // CONTAINING_RECORD(link, PI_DEVICE_REQUEST, ListEntry);
  102. if (!DumpDeviceActionEntry(Client, deviceActionEntry)) {
  103. return E_INVALIDARG;
  104. }
  105. if (GetFieldValue(deviceActionEntry, "nt!_PI_DEVICE_REQUEST", "ListEntry.Flink", link)) {
  106. dprintf("Error reading deviceRequest->ListEntry.Flink (%#010p)\n", deviceActionEntry);
  107. return E_INVALIDARG;
  108. }
  109. }
  110. if (enumerationInProgress) {
  111. dprintf("PnP DeviceActionWorker active!\n\n");
  112. }
  113. return S_OK;
  114. }
  115. DECLARE_API(pnptriage)
  116. /*++
  117. Routine Description:
  118. Helps triage PnP issues (mostly stress).
  119. Arguments:
  120. args - Stress or otherwise.
  121. Return Value:
  122. None
  123. --*/
  124. {
  125. //
  126. // Dump the PnP device action queue.
  127. //
  128. if (pnpaction(Client, "") == S_OK) {
  129. //
  130. // Dump the PnP event queue.
  131. //
  132. if (pnpevent(Client, "") == S_OK) {
  133. //
  134. // Dump devnodes with problems.
  135. //
  136. dprintf("\n********************************************************************************\n");
  137. dprintf("Dumping devnodes with problems...\n");
  138. dprintf("********************************************************************************\n\n");
  139. devnode(Client, "0 21");
  140. //
  141. // Dump our locks.
  142. //
  143. dprintf("\n********************************************************************************\n");
  144. dprintf("Dumping PnP locks...\n");
  145. dprintf("********************************************************************************\n\n");
  146. locks(Client, "nt!PiEngineLock");
  147. locks(Client, "nt!IopDeviceTreeLock");
  148. locks(Client, "nt!PpRegistryDeviceResource");
  149. dprintf("\n********************************************************************************\n");
  150. dprintf("If NOT available, do !thread on the owner thread to find the thread hung in PnP\n");
  151. dprintf("********************************************************************************\n\n");
  152. }
  153. }
  154. return S_OK;
  155. }