summaryrefslogtreecommitdiff
path: root/source/Breakpoint/BreakpointLocationList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Breakpoint/BreakpointLocationList.cpp')
-rw-r--r--source/Breakpoint/BreakpointLocationList.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/source/Breakpoint/BreakpointLocationList.cpp b/source/Breakpoint/BreakpointLocationList.cpp
index 1e4b4412a427..23ca89da6ce1 100644
--- a/source/Breakpoint/BreakpointLocationList.cpp
+++ b/source/Breakpoint/BreakpointLocationList.cpp
@@ -49,12 +49,12 @@ bool BreakpointLocationList::ShouldStop(StoppointCallbackContext *context,
BreakpointLocationSP bp = FindByID(break_id);
if (bp) {
// Let the BreakpointLocation decide if it should stop here (could not have
- // reached it's target hit count yet, or it could have a callback
- // that decided it shouldn't stop (shared library loads/unloads).
+ // reached it's target hit count yet, or it could have a callback that
+ // decided it shouldn't stop (shared library loads/unloads).
return bp->ShouldStop(context);
}
- // We should stop here since this BreakpointLocation isn't valid anymore or it
- // doesn't exist.
+ // We should stop here since this BreakpointLocation isn't valid anymore or
+ // it doesn't exist.
return true;
}
@@ -246,10 +246,10 @@ bool BreakpointLocationList::RemoveLocation(
m_address_to_location.erase(bp_loc_sp->GetAddress());
- collection::iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos) {
- if ((*pos).get() == bp_loc_sp.get()) {
- m_locations.erase(pos);
+ size_t num_locations = m_locations.size();
+ for (size_t idx = 0; idx < num_locations; idx++) {
+ if (m_locations[idx].get() == bp_loc_sp.get()) {
+ RemoveLocationByIndex(idx);
return true;
}
}
@@ -257,17 +257,23 @@ bool BreakpointLocationList::RemoveLocation(
return false;
}
+void BreakpointLocationList::RemoveLocationByIndex(size_t idx) {
+ assert (idx < m_locations.size());
+ m_address_to_location.erase(m_locations[idx]->GetAddress());
+ m_locations.erase(m_locations.begin() + idx);
+}
+
void BreakpointLocationList::RemoveInvalidLocations(const ArchSpec &arch) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
size_t idx = 0;
- // Don't cache m_location.size() as it will change since we might
- // remove locations from our vector...
+ // Don't cache m_location.size() as it will change since we might remove
+ // locations from our vector...
while (idx < m_locations.size()) {
BreakpointLocation *bp_loc = m_locations[idx].get();
if (bp_loc->GetAddress().SectionWasDeleted()) {
// Section was deleted which means this breakpoint comes from a module
// that is no longer valid, so we should remove it.
- m_locations.erase(m_locations.begin() + idx);
+ RemoveLocationByIndex(idx);
continue;
}
if (arch.IsValid()) {
@@ -276,12 +282,13 @@ void BreakpointLocationList::RemoveInvalidLocations(const ArchSpec &arch) {
if (!arch.IsCompatibleMatch(module_sp->GetArchitecture())) {
// The breakpoint was in a module whose architecture is no longer
// compatible with "arch", so we need to remove it
- m_locations.erase(m_locations.begin() + idx);
+ RemoveLocationByIndex(idx);
continue;
}
}
}
- // Only increment the index if we didn't remove the locations at index "idx"
+ // Only increment the index if we didn't remove the locations at index
+ // "idx"
++idx;
}
}