diff options
| -rw-r--r-- | imgdiag/imgdiag.cc | 8 | ||||
| -rw-r--r-- | runtime/dexopt_test.cc | 7 | ||||
| -rw-r--r-- | runtime/mem_map.cc | 35 |
3 files changed, 27 insertions, 23 deletions
diff --git a/imgdiag/imgdiag.cc b/imgdiag/imgdiag.cc index 05fce96780..8aa638a0e0 100644 --- a/imgdiag/imgdiag.cc +++ b/imgdiag/imgdiag.cc @@ -1150,10 +1150,10 @@ class ImgDiagDumper { bool found_boot_map = false; // Find the memory map only for boot.art - for (const backtrace_map_t& map : *tmp_proc_maps) { - if (EndsWith(map.name, GetImageLocationBaseName())) { - if ((map.flags & PROT_WRITE) != 0) { - boot_map_ = map; + for (const backtrace_map_t* map : *tmp_proc_maps) { + if (EndsWith(map->name, GetImageLocationBaseName())) { + if ((map->flags & PROT_WRITE) != 0) { + boot_map_ = *map; found_boot_map = true; break; } diff --git a/runtime/dexopt_test.cc b/runtime/dexopt_test.cc index 3c8243a6c5..d93d76793f 100644 --- a/runtime/dexopt_test.cc +++ b/runtime/dexopt_test.cc @@ -218,10 +218,11 @@ void DexoptTest::ReserveImageSpace() { std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(getpid(), true)); ASSERT_TRUE(map.get() != nullptr) << "Failed to build process map"; - for (BacktraceMap::const_iterator it = map->begin(); + for (BacktraceMap::iterator it = map->begin(); reservation_start < reservation_end && it != map->end(); ++it) { - ReserveImageSpaceChunk(reservation_start, std::min(it->start, reservation_end)); - reservation_start = std::max(reservation_start, it->end); + const backtrace_map_t* entry = *it; + ReserveImageSpaceChunk(reservation_start, std::min(entry->start, reservation_end)); + reservation_start = std::max(reservation_start, entry->end); } ReserveImageSpaceChunk(reservation_start, reservation_end); } diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index 7f68d2faa0..f5d12d5f7b 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -59,14 +59,15 @@ static Maps* gMaps GUARDED_BY(MemMap::GetMemMapsLock()) = nullptr; static std::ostream& operator<<( std::ostream& os, - std::pair<BacktraceMap::const_iterator, BacktraceMap::const_iterator> iters) { - for (BacktraceMap::const_iterator it = iters.first; it != iters.second; ++it) { + std::pair<BacktraceMap::iterator, BacktraceMap::iterator> iters) { + for (BacktraceMap::iterator it = iters.first; it != iters.second; ++it) { + const backtrace_map_t* entry = *it; os << StringPrintf("0x%08x-0x%08x %c%c%c %s\n", - static_cast<uint32_t>(it->start), - static_cast<uint32_t>(it->end), - (it->flags & PROT_READ) ? 'r' : '-', - (it->flags & PROT_WRITE) ? 'w' : '-', - (it->flags & PROT_EXEC) ? 'x' : '-', it->name.c_str()); + static_cast<uint32_t>(entry->start), + static_cast<uint32_t>(entry->end), + (entry->flags & PROT_READ) ? 'r' : '-', + (entry->flags & PROT_WRITE) ? 'w' : '-', + (entry->flags & PROT_EXEC) ? 'x' : '-', entry->name.c_str()); } return os; } @@ -170,9 +171,10 @@ bool MemMap::ContainedWithinExistingMap(uint8_t* ptr, size_t size, std::string* } ScopedBacktraceMapIteratorLock lock(map.get()); - for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { - if ((begin >= it->start && begin < it->end) // start of new within old - && (end > it->start && end <= it->end)) { // end of new within old + for (BacktraceMap::iterator it = map->begin(); it != map->end(); ++it) { + const backtrace_map_t* entry = *it; + if ((begin >= entry->start && begin < entry->end) // start of new within old + && (end > entry->start && end <= entry->end)) { // end of new within old return true; } } @@ -194,17 +196,18 @@ static bool CheckNonOverlapping(uintptr_t begin, return false; } ScopedBacktraceMapIteratorLock lock(map.get()); - for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { - if ((begin >= it->start && begin < it->end) // start of new within old - || (end > it->start && end < it->end) // end of new within old - || (begin <= it->start && end > it->end)) { // start/end of new includes all of old + for (BacktraceMap::iterator it = map->begin(); it != map->end(); ++it) { + const backtrace_map_t* entry = *it; + if ((begin >= entry->start && begin < entry->end) // start of new within old + || (end > entry->start && end < entry->end) // end of new within old + || (begin <= entry->start && end > entry->end)) { // start/end of new includes all of old std::ostringstream map_info; map_info << std::make_pair(it, map->end()); *error_msg = StringPrintf("Requested region 0x%08" PRIxPTR "-0x%08" PRIxPTR " overlaps with " "existing map 0x%08" PRIxPTR "-0x%08" PRIxPTR " (%s)\n%s", begin, end, - static_cast<uintptr_t>(it->start), static_cast<uintptr_t>(it->end), - it->name.c_str(), + static_cast<uintptr_t>(entry->start), static_cast<uintptr_t>(entry->end), + entry->name.c_str(), map_info.str().c_str()); return false; } |