diff options
Diffstat (limited to 'lldb/source/Breakpoint')
-rw-r--r-- | lldb/source/Breakpoint/Breakpoint.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointList.cpp | 38 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointLocationList.cpp | 39 |
3 files changed, 63 insertions, 20 deletions
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index e07205e360b..32c0b1066f8 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -114,6 +114,12 @@ Breakpoint::GetLocationAtIndex (size_t index) return m_locations.GetByIndex(index); } +void +Breakpoint::RemoveInvalidLocations (const ArchSpec &arch) +{ + m_locations.RemoveInvalidLocations(arch); +} + // For each of the overall options we need to decide how they propagate to // the location options. This will determine the precedence of options on // the breakpoint vs. its locations. diff --git a/lldb/source/Breakpoint/BreakpointList.cpp b/lldb/source/Breakpoint/BreakpointList.cpp index c6030d60ca0..147ad36b040 100644 --- a/lldb/source/Breakpoint/BreakpointList.cpp +++ b/lldb/source/Breakpoint/BreakpointList.cpp @@ -69,12 +69,20 @@ BreakpointList::Remove (break_id_t break_id, bool notify) } void +BreakpointList::RemoveInvalidLocations (const ArchSpec &arch) +{ + Mutex::Locker locker(m_mutex); + for (const auto &bp_sp : m_breakpoints) + bp_sp->RemoveInvalidLocations(arch); +} + + +void BreakpointList::SetEnabledAll (bool enabled) { Mutex::Locker locker(m_mutex); - bp_collection::iterator pos, end = m_breakpoints.end(); - for (pos = m_breakpoints.begin(); pos != end; ++pos) - (*pos)->SetEnabled (enabled); + for (const auto &bp_sp : m_breakpoints) + bp_sp->SetEnabled (enabled); } @@ -163,10 +171,8 @@ BreakpointList::Dump (Stream *s) const s->Indent(); s->Printf("BreakpointList with %u Breakpoints:\n", (uint32_t)m_breakpoints.size()); s->IndentMore(); - bp_collection::const_iterator pos; - bp_collection::const_iterator end = m_breakpoints.end(); - for (pos = m_breakpoints.begin(); pos != end; ++pos) - (*pos)->Dump(s); + for (const auto &bp_sp : m_breakpoints) + bp_sp->Dump(s); s->IndentLess(); } @@ -207,10 +213,8 @@ void BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added, bool delete_locations) { Mutex::Locker locker(m_mutex); - bp_collection::iterator end = m_breakpoints.end(); - bp_collection::iterator pos; - for (pos = m_breakpoints.begin(); pos != end; ++pos) - (*pos)->ModulesChanged (module_list, added, delete_locations); + for (const auto &bp_sp : m_breakpoints) + bp_sp->ModulesChanged (module_list, added, delete_locations); } @@ -218,10 +222,8 @@ void BreakpointList::UpdateBreakpointsWhenModuleIsReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp) { Mutex::Locker locker(m_mutex); - bp_collection::iterator end = m_breakpoints.end(); - bp_collection::iterator pos; - for (pos = m_breakpoints.begin(); pos != end; ++pos) - (*pos)->ModuleReplaced (old_module_sp, new_module_sp); + for (const auto &bp_sp : m_breakpoints) + bp_sp->ModuleReplaced (old_module_sp, new_module_sp); } @@ -229,10 +231,8 @@ void BreakpointList::ClearAllBreakpointSites () { Mutex::Locker locker(m_mutex); - bp_collection::iterator end = m_breakpoints.end(); - bp_collection::iterator pos; - for (pos = m_breakpoints.begin(); pos != end; ++pos) - (*pos)->ClearAllBreakpointSites (); + for (const auto &bp_sp : m_breakpoints) + bp_sp->ClearAllBreakpointSites (); } diff --git a/lldb/source/Breakpoint/BreakpointLocationList.cpp b/lldb/source/Breakpoint/BreakpointLocationList.cpp index 341b0971630..8be3d9b67e2 100644 --- a/lldb/source/Breakpoint/BreakpointLocationList.cpp +++ b/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" @@ -286,7 +289,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) |