https://git.reactos.org/?p=reactos.git;a=commitdiff;h=78b55550bb984bc14b387…
commit 78b55550bb984bc14b387812660e2c6d86ba5cfe
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Fri Dec 29 08:21:40 2017 +0100
[NTOSKRNL] Make the memory dumper available as a kdbg command: !poolused
---
ntoskrnl/kdbg/kdb_cli.c | 4 +++-
ntoskrnl/mm/ARM3/expool.c | 41 ++++++++++++++++++++++++++++++++---------
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index f5e71bd369..ff87f56a4c 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -92,6 +92,7 @@ static BOOLEAN KdbpCmdHelp(ULONG Argc, PCHAR Argv[]);
static BOOLEAN KdbpCmdDmesg(ULONG Argc, PCHAR Argv[]);
BOOLEAN ExpKdbgExtPool(ULONG Argc, PCHAR Argv[]);
+BOOLEAN ExpKdbgExtPoolUsed(ULONG Argc, PCHAR Argv[]);
#ifdef __ROS_DWARF__
static BOOLEAN KdbpCmdPrintStruct(ULONG Argc, PCHAR Argv[]);
@@ -183,7 +184,8 @@ static const struct
{ "dmesg", "dmesg", "Display debug messages on screen, with
navigation on pages.", KdbpCmdDmesg },
{ "kmsg", "kmsg", "Kernel dmesg. Alias for dmesg.",
KdbpCmdDmesg },
{ "help", "help", "Display help screen.", KdbpCmdHelp
},
- { "!pool", "!pool [Address [Flags]]", "Display information
about pool allocations.", ExpKdbgExtPool }
+ { "!pool", "!pool [Address [Flags]]", "Display information
about pool allocations.", ExpKdbgExtPool },
+ { "!poolused", "!poolused", "Display non-paged pool
usage.", ExpKdbgExtPoolUsed },
};
/* FUNCTIONS *****************************************************************/
diff --git a/ntoskrnl/mm/ARM3/expool.c b/ntoskrnl/mm/ARM3/expool.c
index 13a75be7c5..129b3d0de6 100644
--- a/ntoskrnl/mm/ARM3/expool.c
+++ b/ntoskrnl/mm/ARM3/expool.c
@@ -475,13 +475,23 @@ ExpTagAllowPrint(CHAR Tag)
return FALSE;
}
+#define MiDumperPrint(dbg, fmt, ...) \
+ if (dbg) KdbpPrint(fmt, ##__VA_ARGS__); \
+ else DPRINT1(fmt, ##__VA_ARGS__)
+
VOID
-MiDumpNonPagedPoolConsumers(VOID)
+MiDumpNonPagedPoolConsumers(BOOLEAN CalledFromDbg)
{
SIZE_T i;
- DPRINT1("---------------------\n");
- DPRINT1("Out of memory dumper!\n");
+ //
+ // Only print header if called from OOM situation
+ //
+ if (!CalledFromDbg)
+ {
+ DPRINT1("---------------------\n");
+ DPRINT1("Out of memory dumper!\n");
+ }
//
// We'll extract allocations for all the tracked pools
@@ -517,21 +527,24 @@ MiDumpNonPagedPoolConsumers(VOID)
//
// Print in reversed order to match what is in source code
//
- DPRINT1("Tag: '%c%c%c%c', Size: %ld\n", Tag[3],
Tag[2], Tag[1], Tag[0], TableEntry->NonPagedBytes);
+ MiDumperPrint(CalledFromDbg, "Tag: '%c%c%c%c', Size:
%ld\n", Tag[3], Tag[2], Tag[1], Tag[0], TableEntry->NonPagedBytes);
}
else
{
- DPRINT1("Tag: %x, Size: %ld\n", TableEntry->Key,
TableEntry->NonPagedBytes);
+ MiDumperPrint(CalledFromDbg, "Tag: %x, Size: %ld\n",
TableEntry->Key, TableEntry->NonPagedBytes);
}
}
else
{
- DPRINT1("Anon, Size: %ld\n", TableEntry->NonPagedBytes);
+ MiDumperPrint(CalledFromDbg, "Anon, Size: %ld\n",
TableEntry->NonPagedBytes);
}
}
}
- DPRINT1("---------------------\n");
+ if (!CalledFromDbg)
+ {
+ DPRINT1("---------------------\n");
+ }
}
#endif
@@ -1722,7 +1735,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType,
//
if ((OriginalType & BASE_POOL_TYPE_MASK) == NonPagedPool)
{
- MiDumpNonPagedPoolConsumers();
+ MiDumpNonPagedPoolConsumers(FALSE);
}
#endif
@@ -2058,7 +2071,7 @@ ExAllocatePoolWithTag(IN POOL_TYPE PoolType,
//
if ((OriginalType & BASE_POOL_TYPE_MASK) == NonPagedPool)
{
- MiDumpNonPagedPoolConsumers();
+ MiDumpNonPagedPoolConsumers(FALSE);
}
#endif
@@ -2914,6 +2927,16 @@ ExpKdbgExtPool(
return TRUE;
}
+BOOLEAN
+ExpKdbgExtPoolUsed(
+ ULONG Argc,
+ PCHAR Argv[])
+{
+ MiDumpNonPagedPoolConsumers(TRUE);
+
+ return TRUE;
+}
+
#endif // DBG && KDBG
/* EOF */