mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-08 23:42:53 +03: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:
parent
c76dc9a047
commit
3f050c1972
Notes:
sideshowbarker
2024-07-19 18:37:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3f050c19720
@ -16,6 +16,7 @@ enum class PageFaultResponse {
|
||||
};
|
||||
|
||||
struct Zone : public Retainable<Zone> {
|
||||
friend ByteBuffer procfs$mm();
|
||||
public:
|
||||
~Zone();
|
||||
size_t size() const { return m_pages.size() * PAGE_SIZE; }
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user