mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
Add zone dump to /proc/mm.
Sweet, now we can look at all the zones (physical memory) currently in play. Building the procfs files with ksprintf and rickety buffer presizing feels pretty shoddy but I'll fix it up eventually.
This commit is contained in:
@@ -121,10 +121,19 @@ void ProcFileSystem::removeProcess(Task& task)
|
||||
ByteBuffer procfs$mm()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
auto buffer = ByteBuffer::createUninitialized(1024);
|
||||
size_t zonePageCount = 0;
|
||||
for (auto* zone : MM.m_zones)
|
||||
zonePageCount += zone->m_pages.size();
|
||||
auto buffer = ByteBuffer::createUninitialized(1024 + 80 * MM.m_zones.size() + zonePageCount * 10);
|
||||
char* ptr = (char*)buffer.pointer();
|
||||
ptr += ksprintf(ptr, "Zone count: %u\n", MM.m_zones.size());
|
||||
ptr += ksprintf(ptr, "Free physical pages: %u\n", MM.m_freePages.size());
|
||||
for (auto* zone : MM.m_zones) {
|
||||
ptr += ksprintf(ptr, "Zone %p size: %u\n ", zone, zone->size());
|
||||
for (auto page : zone->m_pages)
|
||||
ptr += ksprintf(ptr, "%x ", page);
|
||||
ptr += ksprintf(ptr, "\n");
|
||||
}
|
||||
buffer.trim(ptr - (char*)buffer.pointer());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user