Searcher::CallbackReturn SearchFilter::DoCUIteration(const ModuleSP &module_sp, const SymbolContext &context, Searcher &searcher) { Searcher::CallbackReturn shouldContinue; if (context.comp_unit == nullptr) { const size_t num_comp_units = module_sp->GetNumCompileUnits(); for (size_t i = 0; i < num_comp_units; i++) { CompUnitSP cu_sp(module_sp->GetCompileUnitAtIndex(i)); if (cu_sp) { if (!CompUnitPasses(*(cu_sp.get()))) continue; if (searcher.GetDepth() == Searcher::eDepthCompUnit) { SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get()); shouldContinue = searcher.SearchCallback(*this, matchingContext, nullptr, false); if (shouldContinue == Searcher::eCallbackReturnPop) return Searcher::eCallbackReturnContinue; else if (shouldContinue == Searcher::eCallbackReturnStop) return shouldContinue; } else { // FIXME Descend to block. } } } } else { if (CompUnitPasses(*context.comp_unit)) { SymbolContext matchingContext(m_target_sp, module_sp, context.comp_unit); return searcher.SearchCallback(*this, matchingContext, nullptr, false); } } return Searcher::eCallbackReturnContinue; }
Searcher::CallbackReturn SearchFilter::DoCUIteration(const ModuleSP &module_sp, const SymbolContext &context, Searcher &searcher) { Searcher::CallbackReturn shouldContinue; if (context.comp_unit == nullptr) { const size_t num_comp_units = module_sp->GetNumCompileUnits(); for (size_t i = 0; i < num_comp_units; i++) { CompUnitSP cu_sp(module_sp->GetCompileUnitAtIndex(i)); if (cu_sp) { if (!CompUnitPasses(*(cu_sp.get()))) continue; if (searcher.GetDepth() == lldb::eSearchDepthCompUnit) { SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get()); shouldContinue = searcher.SearchCallback(*this, matchingContext, nullptr, false); if (shouldContinue == Searcher::eCallbackReturnPop) return Searcher::eCallbackReturnContinue; else if (shouldContinue == Searcher::eCallbackReturnStop) return shouldContinue; } else { // First make sure this compile unit's functions are parsed // since CompUnit::ForeachFunction only iterates over already // parsed functions. SymbolVendor *sym_vendor = module_sp->GetSymbolVendor(); if (!sym_vendor) continue; if (!sym_vendor->ParseFunctions(*cu_sp)) continue; // If we got any functions, use ForeachFunction to do the iteration. cu_sp->ForeachFunction([&](const FunctionSP &func_sp) { if (!FunctionPasses(*func_sp.get())) return false; // Didn't pass the filter, just keep going. if (searcher.GetDepth() == lldb::eSearchDepthFunction) { SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get(), func_sp.get()); shouldContinue = searcher.SearchCallback(*this, matchingContext, nullptr, false); } else { shouldContinue = DoFunctionIteration(func_sp.get(), context, searcher); } return shouldContinue != Searcher::eCallbackReturnContinue; }); } } } } else { if (CompUnitPasses(*context.comp_unit)) { SymbolContext matchingContext(m_target_sp, module_sp, context.comp_unit); return searcher.SearchCallback(*this, matchingContext, nullptr, false); } } return Searcher::eCallbackReturnContinue; }