summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp')
-rw-r--r--contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp61
1 files changed, 52 insertions, 9 deletions
diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp
index 341b097..0c4c54d 100644
--- a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp
+++ b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp
@@ -13,8 +13,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocationList.h"
+
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/Breakpoint.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Target/Target.h"
@@ -74,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
@@ -286,7 +295,41 @@ BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc
return false;
}
-
+void
+BreakpointLocationList::RemoveInvalidLocations (const ArchSpec &arch)
+{
+ Mutex::Locker locker (m_mutex);
+ size_t idx = 0;
+ // 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);
+ continue;
+ }
+ if (arch.IsValid())
+ {
+ ModuleSP module_sp (bp_loc->GetAddress().GetModule());
+ if (module_sp)
+ {
+ 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);
+ continue;
+ }
+ }
+ }
+ // Only increment the index if we didn't remove the locations at index "idx"
+ ++idx;
+ }
+}
void
BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations)
OpenPOWER on IntegriCloud