1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

LibDebug:: Add DwarfInfo::get_die_at_address

This function returns the die object whose address range intersects
with the given address.

This function will also construct the DIE cache, if it hasn't been
constructed yet.
This commit is contained in:
Itamar 2021-06-19 11:59:48 +03:00 committed by Andreas Kling
parent 92d4962d04
commit fb31aae20d
2 changed files with 22 additions and 0 deletions

View file

@ -288,4 +288,24 @@ void DwarfInfo::build_cached_dies() const
m_built_cached_dies = true;
}
Optional<DIE> DwarfInfo::get_die_at_address(FlatPtr address) const
{
if (!m_built_cached_dies)
build_cached_dies();
auto iter = m_cached_dies_by_range.find_largest_not_above_iterator(address);
while (!iter.is_end() && !iter.is_begin() && iter->range.end_address < address) {
--iter;
}
if (iter.is_end())
return {};
if (iter->range.start_address > address || iter->range.end_address < address) {
return {};
}
return iter->die;
}
}