forked from OSchip/llvm-project
Fix the RangeMapVector::FindEntryThatContainsOrFollows method to
back up the iterator, as long as it still contains the address. std::lower_bound will point us to the entry after the one we are really interested in, leading to problems with backtracing in corefiles. <rdar://problem/27823549> llvm-svn: 278901
This commit is contained in:
parent
f7ba716bcb
commit
0dace2d3a1
|
@ -1341,6 +1341,14 @@ namespace lldb_private {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method will return the entry that contains the given address, or the
|
||||||
|
// entry following that address. If you give it an address of 0 and the first
|
||||||
|
// entry starts at address 0x100, you will get the entry at 0x100.
|
||||||
|
//
|
||||||
|
// For most uses, FindEntryThatContains is the correct one to use, this is a
|
||||||
|
// less commonly needed behavior. It was added for core file memory regions,
|
||||||
|
// where we want to present a gap in the memory regions as a distinct region,
|
||||||
|
// so we need to know the start address of the next memory section that exists.
|
||||||
const Entry *
|
const Entry *
|
||||||
FindEntryThatContainsOrFollows(B addr) const
|
FindEntryThatContainsOrFollows(B addr) const
|
||||||
{
|
{
|
||||||
|
@ -1349,12 +1357,16 @@ namespace lldb_private {
|
||||||
#endif
|
#endif
|
||||||
if (!m_entries.empty())
|
if (!m_entries.empty())
|
||||||
{
|
{
|
||||||
|
typename Collection::const_iterator begin = m_entries.begin();
|
||||||
typename Collection::const_iterator end = m_entries.end();
|
typename Collection::const_iterator end = m_entries.end();
|
||||||
typename Collection::const_iterator pos =
|
typename Collection::const_iterator pos =
|
||||||
std::lower_bound(m_entries.begin(), end, addr, [](const Entry &lhs, B rhs_base) -> bool {
|
std::lower_bound(m_entries.begin(), end, addr, [](const Entry &lhs, B rhs_base) -> bool {
|
||||||
return lhs.GetRangeEnd() <= rhs_base;
|
return lhs.GetRangeEnd() <= rhs_base;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
while (pos != begin && pos[-1].Contains(addr))
|
||||||
|
--pos;
|
||||||
|
|
||||||
if (pos != end)
|
if (pos != end)
|
||||||
return &(*pos);
|
return &(*pos);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue