void SearchFilter::SearchInModuleList (Searcher &searcher, ModuleList &modules) { SymbolContext empty_sc; if (!m_target_sp) return; empty_sc.target_sp = m_target_sp; if (searcher.GetDepth() == Searcher::eDepthTarget) searcher.SearchCallback (*this, empty_sc, NULL, false); else { Mutex::Locker modules_locker(modules.GetMutex()); const size_t numModules = modules.GetSize(); for (size_t i = 0; i < numModules; i++) { ModuleSP module_sp(modules.GetModuleAtIndexUnlocked(i)); if (ModulePasses(module_sp)) { if (DoModuleIteration(module_sp, searcher) == Searcher::eCallbackReturnStop) return; } } } }
void SearchFilter::SearchInModuleList(Searcher &searcher, ModuleList &modules) { SymbolContext empty_sc; if (!m_target_sp) return; empty_sc.target_sp = m_target_sp; if (searcher.GetDepth() == lldb::eSearchDepthTarget) searcher.SearchCallback(*this, empty_sc, nullptr, false); else { std::lock_guard<std::recursive_mutex> guard(modules.GetMutex()); const size_t numModules = modules.GetSize(); for (size_t i = 0; i < numModules; i++) { ModuleSP module_sp(modules.GetModuleAtIndexUnlocked(i)); if (ModulePasses(module_sp)) { if (DoModuleIteration(module_sp, searcher) == Searcher::eCallbackReturnStop) return; } } } }
void Breakpoint::ModulesChanged(ModuleList &module_list, bool load, bool delete_locations) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (log) log->Printf("Breakpoint::ModulesChanged: num_modules: %zu load: %i " "delete_locations: %i\n", module_list.GetSize(), load, delete_locations); std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex()); if (load) { // The logic for handling new modules is: // 1) If the filter rejects this module, then skip it. // 2) Run through the current location list and if there are any locations // for that module, we mark the module as "seen" and we don't try to // re-resolve // breakpoint locations for that module. // However, we do add breakpoint sites to these locations if needed. // 3) If we don't see this module in our breakpoint location list, call // ResolveInModules. ModuleList new_modules; // We'll stuff the "unseen" modules in this list, // and then resolve // them after the locations pass. Have to do it this way because // resolving breakpoints will add new locations potentially. for (ModuleSP module_sp : module_list.ModulesNoLocking()) { bool seen = false; if (!m_filter_sp->ModulePasses(module_sp)) continue; for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations()) { if (!break_loc_sp->IsEnabled()) continue; SectionSP section_sp(break_loc_sp->GetAddress().GetSection()); if (!section_sp || section_sp->GetModule() == module_sp) { if (!seen) seen = true; if (!break_loc_sp->ResolveBreakpointSite()) { if (log) log->Printf("Warning: could not set breakpoint site for " "breakpoint location %d of breakpoint %d.\n", break_loc_sp->GetID(), GetID()); } } } if (!seen) new_modules.AppendIfNeeded(module_sp); } if (new_modules.GetSize() > 0) { ResolveBreakpointInModules(new_modules); } } else { // Go through the currently set locations and if any have breakpoints in // the module list, then remove their breakpoint sites, and their locations // if asked to. BreakpointEventData *removed_locations_event; if (!IsInternal()) removed_locations_event = new BreakpointEventData( eBreakpointEventTypeLocationsRemoved, shared_from_this()); else removed_locations_event = nullptr; size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; i++) { ModuleSP module_sp(module_list.GetModuleAtIndexUnlocked(i)); if (m_filter_sp->ModulePasses(module_sp)) { size_t loc_idx = 0; 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()); if (section_sp && section_sp->GetModule() == module_sp) { // Remove this breakpoint since the shared library is // unloaded, but keep the breakpoint location around // so we always get complete hit count and breakpoint // lifetime info break_loc_sp->ClearBreakpointSite(); if (removed_locations_event) { removed_locations_event->GetBreakpointLocationCollection().Add( break_loc_sp); } if (delete_locations) locations_to_remove.Add(break_loc_sp); } } 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)); } } } SendBreakpointChangedEvent(removed_locations_event); } }