From 54bd2ee73805a3a6dd3991fa24043a9187138908 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 9 Mar 2021 14:44:54 +0100 Subject: UserspaceEmulator: Add Emulator::dump_regions() helper function --- Userland/DevTools/UserspaceEmulator/Emulator.cpp | 17 +++++++++++++++++ Userland/DevTools/UserspaceEmulator/Emulator.h | 2 ++ 2 files changed, 19 insertions(+) (limited to 'Userland/DevTools/UserspaceEmulator') diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index 439eb4f130..0afe309bc6 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -1846,4 +1846,21 @@ int Emulator::virt$msyscall(FlatPtr) return 0; } +void Emulator::dump_regions() const +{ + const_cast(m_mmu).for_each_region([&](const Region& region) { + reportln("{:p}-{:p} {:c}{:c}{:c} {} {}{}{} ", + region.base(), + region.end() - 1, + region.is_readable() ? 'R' : '-', + region.is_writable() ? 'W' : '-', + region.is_executable() ? 'X' : '-', + is(region) ? static_cast(region).name() : "", + is(region) ? "(mmap) " : "", + region.is_stack() ? "(stack) " : "", + region.is_text() ? "(text) " : ""); + return IterationDecision::Continue; + }); +} + } diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h index 1faafa9052..d4fc71d5ea 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.h +++ b/Userland/DevTools/UserspaceEmulator/Emulator.h @@ -68,6 +68,8 @@ public: void did_receive_signal(int signum) { m_pending_signals |= (1 << signum); } + void dump_regions() const; + private: const String m_executable_path; const Vector m_arguments; -- cgit v1.2.3