[ros-diffs] [ros-arm-bringup] 41639: - This patch is lets you visually dump the entire ReactOS PFN database, useful for debugging. Surprising nobody had done in this in the past, since it wasn't too hard (but it took a bit long to figure out how to get it in there). - That's what she said.

ros-arm-bringup at svn.reactos.org ros-arm-bringup at svn.reactos.org
Sun Jun 28 10:32:12 CEST 2009


Author: ros-arm-bringup
Date: Sat Jun 27 13:54:56 2009
New Revision: 41639

URL: http://svn.reactos.org/svn/reactos?rev=41639&view=rev
Log:
- This patch is lets you visually dump the entire ReactOS PFN database, useful for debugging. Surprising nobody had done in this in the past, since it wasn't too hard (but it took a bit long to figure out how to get it in there).
  - That's what she said.


Modified:
    trunk/reactos/ntoskrnl/include/internal/kd.h
    trunk/reactos/ntoskrnl/include/internal/mm.h
    trunk/reactos/ntoskrnl/kd/kdmain.c
    trunk/reactos/ntoskrnl/mm/freelist.c

Modified: trunk/reactos/ntoskrnl/include/internal/kd.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/kd.h?rev=41639&r1=41638&r2=41639&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/kd.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/kd.h [iso-8859-1] Sat Jun 27 13:54:56 2009
@@ -342,7 +342,8 @@
     KdSpare1 = 0x23, /* h */
     KdSpare2 = 0x17, /* i */
     KdSpare3 = 0x24, /* j */
-    EnterDebugger = 0x25  /* k */
+    EnterDebugger = 0x25,  /* k */
+    ThatsWhatSheSaid = 69 /* FIGURE IT OUT */
 } KDP_DEBUG_SERVICE;
 
 /* Dispatch Table for Wrapper Functions */

Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/mm.h?rev=41639&r1=41638&r2=41639&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sat Jun 27 13:54:56 2009
@@ -292,6 +292,12 @@
     ULONG PagingRequestsInLastFiveMinutes;
     ULONG PagingRequestsInLastFifteenMinutes;
 } MM_STATS;
+
+//
+// These two mappings are actually used by Windows itself, based on the ASSERTS
+//
+#define StartOfAllocation ReadInProgress
+#define EndOfAllocation WriteInProgress
 
 typedef struct _MMPFNENTRY
 {
@@ -1120,6 +1126,12 @@
     VOID
 );
 
+VOID
+NTAPI
+MmDumpPfnDatabase(
+   VOID
+);
+
 PFN_TYPE
 NTAPI
 MmGetContinuousPages(

Modified: trunk/reactos/ntoskrnl/kd/kdmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdmain.c?rev=41639&r1=41638&r2=41639&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kd/kdmain.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd/kdmain.c [iso-8859-1] Sat Jun 27 13:54:56 2009
@@ -84,6 +84,10 @@
 
                 case EnterDebugger:
                     DbgBreakPoint();
+                    break;
+                    
+                case ThatsWhatSheSaid:
+                    MmDumpPfnDatabase();
                     break;
 
                 default:

Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev=41639&r1=41638&r2=41639&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] Sat Jun 27 13:54:56 2009
@@ -249,6 +249,94 @@
 
     /* Return it */
     return Pfn;
+}
+
+VOID
+NTAPI
+MmDumpPfnDatabase(VOID)
+{
+    ULONG i;
+    PPHYSICAL_PAGE Pfn1;
+    PCHAR State = "????", Consumer = "Unknown";
+    KIRQL OldIrql;
+    
+    OldIrql = KfRaiseIrql(HIGH_LEVEL);
+    
+    //
+    // Loop the PFN database
+    //
+    for (i = 0; i <= MmHighestPhysicalPage; i++)
+    {
+        Pfn1 = MiGetPfnEntry(i);
+        
+        //
+        // Get the consumer
+        //
+        switch (Pfn1->Flags.Consumer)
+        {
+            case MC_NPPOOL:
+                
+                Consumer = "Nonpaged Pool";
+                break;
+                
+            case MC_PPOOL:
+                
+                Consumer = "Paged Pool";
+                break;
+                
+            case MC_CACHE:
+                
+                Consumer = "File System Cache";
+                break;
+                
+            case MC_USER:
+                
+                Consumer = "Process Working Set";
+                break;
+                
+            case MC_SYSTEM:
+                
+                Consumer = "System";
+                break;
+        }
+        
+        //
+        // Get the type
+        //
+        switch (Pfn1->Flags.Type)
+        {
+            case MM_PHYSICAL_PAGE_USED:
+                
+                State = "Used";
+                break;
+                
+            case MM_PHYSICAL_PAGE_FREE:
+                
+                State = "Free";
+                Consumer = "Free";
+                break;
+                
+            case MM_PHYSICAL_PAGE_BIOS:
+                
+                State = "BIOS";
+                Consumer = "System Reserved";
+                break;
+        }
+
+        //
+        // Pretty-print the page
+        //
+        DbgPrint("0x%08p:\t%04s\t%20s\t(%02d.%02d.%02d) [%08p])\n",
+                 i << PAGE_SHIFT,
+                 State,
+                 Consumer,
+                 Pfn1->ReferenceCount,
+                 Pfn1->MapCount,
+                 Pfn1->LockCount,
+                 Pfn1->RmapListHead);
+    }
+    
+    KeLowerIrql(OldIrql);
 }
 
 VOID



More information about the Ros-diffs mailing list