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.

128 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. ready.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Ramon J San Andres (ramonsa) 8-Nov-1993
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. Jamie Hankins (a-jamhan) 20-Oct-1997 Added CheckControlC to loop.
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. DECLARE_API( ready )
  17. /*++
  18. Routine Description:
  19. Arguments:
  20. args -
  21. Return Value:
  22. None
  23. --*/
  24. {
  25. ULONG64 KiDispatcherReadyListHead;
  26. ULONG ListEntrySize, WaitListOpffset;
  27. ULONG result;
  28. DWORD Flags = 6;
  29. LONG i;
  30. BOOLEAN ThreadDumped = FALSE;
  31. ULONG dwProcessor=0;
  32. GetCurrentProcessor(Client, &dwProcessor, NULL);
  33. Flags = (ULONG)GetExpression(args);
  34. KiDispatcherReadyListHead = GetExpression( "nt!KiDispatcherReadyListHead" );
  35. if ( KiDispatcherReadyListHead ) {
  36. ListEntrySize = GetTypeSize("nt!_LIST_ENTRY");
  37. if (ListEntrySize == 0) {
  38. ListEntrySize = DBG_PTR_SIZE * 2;
  39. }
  40. GetFieldOffset("nt!_ETHREAD", "Tcb.WaitListEntry", &WaitListOpffset);
  41. for (i = MAXIMUM_PRIORITY-1; i >= 0 ; i -= 1 ) {
  42. ULONG64 Flink, Blink;
  43. if ( GetFieldValue( KiDispatcherReadyListHead + i*ListEntrySize,
  44. "nt!_LIST_ENTRY",
  45. "Flink",
  46. Flink) ) {
  47. dprintf(
  48. "Could not read contents of KiDispatcherReadyListHead at %08p [%ld]\n",
  49. (KiDispatcherReadyListHead + i * ListEntrySize), i
  50. );
  51. return E_INVALIDARG;
  52. }
  53. if (Flink != KiDispatcherReadyListHead+i*ListEntrySize) {
  54. ULONG64 ThreadEntry, ThreadFlink;
  55. dprintf("Ready Threads at priority %ld\n", i);
  56. for (ThreadEntry = Flink ;
  57. ThreadEntry != KiDispatcherReadyListHead+i*ListEntrySize ;
  58. ThreadEntry = ThreadFlink ) {
  59. ULONG64 ThreadBaseAddress = (ThreadEntry - WaitListOpffset);
  60. if ( GetFieldValue( ThreadBaseAddress,
  61. "nt!_ETHREAD",
  62. "Tcb.WaitListEntry.Flink",
  63. ThreadFlink) ) {
  64. dprintf("Could not read contents of thread %p\n", ThreadBaseAddress);
  65. }
  66. if(CheckControlC()) {
  67. return E_INVALIDARG;
  68. }
  69. DumpThreadEx(dwProcessor," ", ThreadBaseAddress, Flags, Client);
  70. ThreadDumped = TRUE;
  71. }
  72. } else {
  73. GetFieldValue( KiDispatcherReadyListHead + i*ListEntrySize,
  74. "nt!_LIST_ENTRY",
  75. "Blink",
  76. Blink);
  77. if (Flink != Blink) {
  78. dprintf("Ready linked list may to be corrupt...\n");
  79. }
  80. }
  81. }
  82. if (!ThreadDumped) {
  83. dprintf("No threads in READY state\n");
  84. }
  85. } else {
  86. dprintf("Could not determine address of KiDispatcherReadyListHead\n");
  87. return E_INVALIDARG;
  88. }
  89. return S_OK;
  90. }