1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 20:37:34 +00:00

UserspaceEmulator: Put the memory reachability logging behind a macro

This commit is contained in:
Andreas Kling 2020-07-16 17:16:21 +02:00
parent 441918be7e
commit dd68370efc

View file

@ -29,6 +29,8 @@
#include "MmapRegion.h" #include "MmapRegion.h"
#include <AK/LogStream.h> #include <AK/LogStream.h>
//#define REACHABLE_DEBUG
namespace UserspaceEmulator { namespace UserspaceEmulator {
static pid_t s_pid = getpid(); static pid_t s_pid = getpid();
@ -140,7 +142,9 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const
for (size_t i = 0; i < pointers_in_mallocation; ++i) { for (size_t i = 0; i < pointers_in_mallocation; ++i) {
auto value = Emulator::the().mmu().read32({ 0x20, other_mallocation.address + i * sizeof(u32) }); auto value = Emulator::the().mmu().read32({ 0x20, other_mallocation.address + i * sizeof(u32) });
if (value == mallocation.address) { if (value == mallocation.address) {
#ifdef REACHABLE_DEBUG
dbgprintf("mallocation %p is reachable from other mallocation %p\n", mallocation.address, other_mallocation.address); dbgprintf("mallocation %p is reachable from other mallocation %p\n", mallocation.address, other_mallocation.address);
#endif
return true; return true;
} }
} }
@ -159,7 +163,9 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const
for (size_t i = 0; i < pointers_in_region; ++i) { for (size_t i = 0; i < pointers_in_region; ++i) {
auto value = region.read32(i * sizeof(u32)); auto value = region.read32(i * sizeof(u32));
if (value == mallocation.address) { if (value == mallocation.address) {
#ifdef REACHABLE_DEBUG
dbgprintf("mallocation %p is reachable from region %p-%p\n", mallocation.address, region.base(), region.end() - 1); dbgprintf("mallocation %p is reachable from region %p-%p\n", mallocation.address, region.base(), region.end() - 1);
#endif
return true; return true;
} }
} }