Remove the bad assumption that breakpoint locations won't get deleted in BreakpointLocationList::FindByID.

<rdar://problem/15566148>

llvm-svn: 196197
This commit is contained in:
Jim Ingham 2013-12-03 02:31:17 +00:00
parent 98b28a1eaa
commit 177553e4c0
2 changed files with 15 additions and 9 deletions

View File

@ -260,7 +260,7 @@ protected:
Address::ModulePointerAndOffsetLessThanFunctionObject> addr_map;
Breakpoint &m_owner;
collection m_locations;
collection m_locations; // Vector of locations, sorted by ID
addr_map m_address_to_location;
mutable Mutex m_mutex;
lldb::break_id_t m_next_id;

View File

@ -77,19 +77,25 @@ BreakpointLocationList::FindIDByAddress (const Address &addr)
return LLDB_INVALID_BREAK_ID;
}
static bool
Compare (BreakpointLocationSP lhs, lldb::break_id_t val)
{
return lhs->GetID() < val;
}
BreakpointLocationSP
BreakpointLocationList::FindByID (lldb::break_id_t break_id) const
{
BreakpointLocationSP bp_loc_sp;
Mutex::Locker locker (m_mutex);
// We never remove a breakpoint locations, so the ID can be translated into
// the location index by subtracting 1
uint32_t idx = break_id - 1;
if (idx <= m_locations.size())
{
bp_loc_sp = m_locations[idx];
}
return bp_loc_sp;
collection::const_iterator begin = m_locations.begin(), end = m_locations.end();
collection::const_iterator result;
result = std::lower_bound(begin, end, break_id, Compare);
if (result == end)
return bp_loc_sp;
else
return *(result);
}
size_t