[NTOSKRNL] Implement (it's a bit raw for now!) the !filecache command in KDBG

This commit is contained in:
Pierre Schweitzer 2018-01-24 21:45:37 +01:00
parent 9d1e16663a
commit cb52c82125
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B
2 changed files with 57 additions and 0 deletions

View file

@ -1493,4 +1493,59 @@ CcInitView (
return TRUE;
}
BOOLEAN
ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[])
{
PLIST_ENTRY ListEntry;
UNICODE_STRING NoName = RTL_CONSTANT_STRING(L"No name for File");
KdbpPrint("Control\t\tValid\tDirty\tName\n");
/* No need to lock the spin lock here, we're in DBG */
for (ListEntry = CcCleanSharedCacheMapList.Flink;
ListEntry != &CcCleanSharedCacheMapList;
ListEntry = ListEntry->Flink)
{
PLIST_ENTRY Vacbs;
ULONG Valid = 0, Dirty = 0;
PROS_SHARED_CACHE_MAP SharedCacheMap;
PUNICODE_STRING FileName;
SharedCacheMap = CONTAINING_RECORD(ListEntry, ROS_SHARED_CACHE_MAP, SharedCacheMapLinks);
/* First, count for all the associated VACB */
for (Vacbs = SharedCacheMap->CacheMapVacbListHead.Flink;
Vacbs != &SharedCacheMap->CacheMapVacbListHead;
Vacbs = Vacbs->Flink)
{
PROS_VACB Vacb;
Vacb = CONTAINING_RECORD(Vacbs, ROS_VACB, CacheMapVacbListEntry);
if (Vacb->Dirty)
{
Dirty += VACB_MAPPING_GRANULARITY / 1024;
}
if (Vacb->Valid)
{
Valid += VACB_MAPPING_GRANULARITY / 1024;
}
}
/* Setup name */
if (SharedCacheMap->FileObject != NULL &&
SharedCacheMap->FileObject->FileName.Length != 0)
{
FileName = &SharedCacheMap->FileObject->FileName;
}
else
{
FileName = &NoName;
}
/* And print */
KdbpPrint("%p\t%d\t%d\t%wZ\n", SharedCacheMap, Valid, Dirty, FileName);
}
return TRUE;
}
/* EOF */

View file

@ -93,6 +93,7 @@ static BOOLEAN KdbpCmdDmesg(ULONG Argc, PCHAR Argv[]);
BOOLEAN ExpKdbgExtPool(ULONG Argc, PCHAR Argv[]);
BOOLEAN ExpKdbgExtPoolUsed(ULONG Argc, PCHAR Argv[]);
BOOLEAN ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[]);
#ifdef __ROS_DWARF__
static BOOLEAN KdbpCmdPrintStruct(ULONG Argc, PCHAR Argv[]);
@ -186,6 +187,7 @@ static const struct
{ "help", "help", "Display help screen.", KdbpCmdHelp },
{ "!pool", "!pool [Address [Flags]]", "Display information about pool allocations.", ExpKdbgExtPool },
{ "!poolused", "!poolused [Flags [Tag]]", "Display pool usage.", ExpKdbgExtPoolUsed },
{ "!filecache", "!filecache", "Display cache usage.", ExpKdbgExtFileCache },
};
/* FUNCTIONS *****************************************************************/