summaryrefslogtreecommitdiffstats
path: root/lldb/source/Breakpoint/BreakpointLocationList.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2013-12-03 02:31:17 +0000
committerJim Ingham <jingham@apple.com>2013-12-03 02:31:17 +0000
commit177553e4c08167ab63b8e7d4845a4a3f6ce283b9 (patch)
treea7cea7ebfe8130da45efcb365a18ecb94567b93f /lldb/source/Breakpoint/BreakpointLocationList.cpp
parent98b28a1eaa3ff788350303bac21d8cea046c542b (diff)
downloadbcm5719-llvm-177553e4c08167ab63b8e7d4845a4a3f6ce283b9.tar.gz
bcm5719-llvm-177553e4c08167ab63b8e7d4845a4a3f6ce283b9.zip
Remove the bad assumption that breakpoint locations won't get deleted in BreakpointLocationList::FindByID.
<rdar://problem/15566148> llvm-svn: 196197
Diffstat (limited to 'lldb/source/Breakpoint/BreakpointLocationList.cpp')
-rw-r--r--lldb/source/Breakpoint/BreakpointLocationList.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/lldb/source/Breakpoint/BreakpointLocationList.cpp b/lldb/source/Breakpoint/BreakpointLocationList.cpp
index 8be3d9b67e2..0c4c54d2f16 100644
--- a/lldb/source/Breakpoint/BreakpointLocationList.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationList.cpp
@@ -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
OpenPOWER on IntegriCloud