From 4a94c91077a17d790956a6bfcf2e171b00bae100 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 17 May 2012 18:38:42 +0000 Subject: If we notice that a module with a given file path is replaced by another with the same file path on rerunning, evict the old module from the target module list, inform the breakpoints about this so they can do something intelligent as well. rdar://problem/11273043 llvm-svn: 157008 --- lldb/source/Breakpoint/Breakpoint.cpp | 41 +++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'lldb/source/Breakpoint/Breakpoint.cpp') diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index 62e1b248280..5d0cbd47e20 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -315,7 +315,7 @@ Breakpoint::ClearAllBreakpointSites () //---------------------------------------------------------------------- void -Breakpoint::ModulesChanged (ModuleList &module_list, bool load) +Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_locations) { if (load) { @@ -395,11 +395,7 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load) else { // Go through the currently set locations and if any have breakpoints in - // the module list, then remove their breakpoint sites. - // FIXME: Think about this... Maybe it's better to delete the locations? - // Are we sure that on load-unload-reload the module pointer will remain - // the same? Or do we need to do an equality on modules that is an - // "equivalence"??? + // the module list, then remove their breakpoint sites, and their locations if asked to. BreakpointEventData *removed_locations_event; if (!IsInternal()) @@ -414,7 +410,9 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load) if (m_filter_sp->ModulePasses (module_sp)) { size_t loc_idx = 0; - while (loc_idx < m_locations.GetSize()) + size_t num_locations = m_locations.GetSize(); + BreakpointLocationCollection locations_to_remove; + for (loc_idx = 0; loc_idx < num_locations; loc_idx++) { BreakpointLocationSP break_loc_sp (m_locations.GetByIndex(loc_idx)); SectionSP section_sp (break_loc_sp->GetAddress().GetSection()); @@ -429,9 +427,17 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load) { removed_locations_event->GetBreakpointLocationCollection().Add(break_loc_sp); } - //m_locations.RemoveLocation (break_loc_sp); + if (delete_locations) + locations_to_remove.Add (break_loc_sp); + } - ++loc_idx; + } + + if (delete_locations) + { + size_t num_locations_to_remove = locations_to_remove.GetSize(); + for (loc_idx = 0; loc_idx < num_locations_to_remove; loc_idx++) + m_locations.RemoveLocation (locations_to_remove.GetByIndex(loc_idx)); } } } @@ -439,6 +445,23 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load) } } +void +Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp) +{ + ModuleList temp_list; + temp_list.Append (new_module_sp); + ModulesChanged (temp_list, true); + + // TO DO: For now I'm just adding locations for the new module and removing the + // breakpoint locations that were in the old module. + // We should really go find the ones that are in the new module & if we can determine that they are "equivalent" + // carry over the options from the old location to the new. + + temp_list.Clear(); + temp_list.Append (old_module_sp); + ModulesChanged (temp_list, false, true); +} + void Breakpoint::Dump (Stream *) { -- cgit v1.2.3