diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-16 19:14:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-16 19:21:45 +0200 |
commit | c13da77e8509cdd3e71af049d105fa15de32fd72 (patch) | |
tree | 464b2fd4ede5717847ca27c3d0cbdfe5ab6c8dd1 /DevTools/UserspaceEmulator/MallocTracer.cpp | |
parent | 1dcc21d32eaaefc2764b2897274f73724fae2ba9 (diff) | |
download | serenity-c13da77e8509cdd3e71af049d105fa15de32fd72.zip |
UserspaceEmulator: Add TLS regions to reachability checking
Diffstat (limited to 'DevTools/UserspaceEmulator/MallocTracer.cpp')
-rw-r--r-- | DevTools/UserspaceEmulator/MallocTracer.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/DevTools/UserspaceEmulator/MallocTracer.cpp b/DevTools/UserspaceEmulator/MallocTracer.cpp index 67f921268a..3230e6a093 100644 --- a/DevTools/UserspaceEmulator/MallocTracer.cpp +++ b/DevTools/UserspaceEmulator/MallocTracer.cpp @@ -156,14 +156,16 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const } } + bool reachable = false; + // 2. Search in other memory regions for pointers to this mallocation - for (auto& region : Emulator::the().mmu().regions()) { + Emulator::the().mmu().for_each_region([&](auto& region) { // Skip the stack if (region.is_stack()) - continue; + return IterationDecision::Continue; // Skip malloc blocks if (region.is_mmap() && static_cast<const MmapRegion&>(region).is_malloc_block()) - continue; + return IterationDecision::Continue; size_t pointers_in_region = region.size() / sizeof(u32); for (size_t i = 0; i < pointers_in_region; ++i) { @@ -172,12 +174,13 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const #ifdef REACHABLE_DEBUG dbgprintf("mallocation %p is reachable from region %p-%p\n", mallocation.address, region.base(), region.end() - 1); #endif - return true; + reachable = true; + return IterationDecision::Break; } } - } - - return false; + return IterationDecision::Continue; + }); + return reachable; } void MallocTracer::dump_leak_report() |