UserspaceEmulator: Use for_each_region_of_type in find_text_region

Since we now have this helper template, we can make our code cleaner.
This commit is contained in:
Daniel Bertalan 2021-07-28 17:30:20 +02:00 committed by Andreas Kling
parent c1d6637dc7
commit e9dd9d1f2c
Notes: sideshowbarker 2024-07-18 07:16:22 +09:00

View file

@ -378,13 +378,10 @@ Vector<FlatPtr> Emulator::raw_backtrace()
MmapRegion const* Emulator::find_text_region(FlatPtr address)
{
MmapRegion const* matching_region = nullptr;
mmu().for_each_region([&](auto& region) {
if (!is<MmapRegion>(region))
mmu().for_each_region_of_type<MmapRegion>([&](auto& region) {
if (!(region.is_executable() && address >= region.base() && address < region.base() + region.size()))
return IterationDecision::Continue;
auto const& mmap_region = static_cast<MmapRegion const&>(region);
if (!(mmap_region.is_executable() && address >= mmap_region.base() && address < mmap_region.base() + mmap_region.size()))
return IterationDecision::Continue;
matching_region = &mmap_region;
matching_region = &region;
return IterationDecision::Break;
});
return matching_region;