Extend ContainedRangeMap and StaticContainedRangeMap

This adds a new mode in ContainedRangeMap which allows existance of
equal ranges. Among those equal ranges, the most recently added range is
the innermost range.

This also adds a function to ContainedRangeMap and
StaticContainedRangeMap to allow users get a vector of entries that
contains given address from innermost to outermost ranges.

Change-Id: I84c1f2e49ffcaf8238df60e41498730103d1ead6
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3291137
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Zequan Wu 2021-11-30 13:53:53 -08:00 committed by Joshua Peraza
parent 4ee9854be5
commit 4458a5965a
6 changed files with 240 additions and 45 deletions

View file

@ -87,6 +87,23 @@ bool StaticContainedRangeMap<AddressType, EntryType>::RetrieveRange(
return true;
}
template <typename AddressType, typename EntryType>
bool StaticContainedRangeMap<AddressType, EntryType>::RetrieveRanges(
const AddressType& address,
std::vector<const EntryType*>& entries) const {
MapConstIterator iterator = map_.lower_bound(address);
if (iterator == map_.end())
return false;
const char* memory_child =
reinterpret_cast<const char*>(iterator.GetValuePtr());
StaticContainedRangeMap child_map(memory_child);
if (address < child_map.base_)
return false;
child_map.RetrieveRanges(address, entries);
entries.push_back(child_map.entry_ptr_);
return true;
}
} // namespace google_breakpad
#endif // PROCESSOR_STATIC_CONTAINED_RANGE_MAP_INL_H__