diff --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h index 0f64753eadbc51..a76294de474bf5 100644 --- a/lldb/include/lldb/Expression/IRExecutionUnit.h +++ b/lldb/include/lldb/Expression/IRExecutionUnit.h @@ -391,6 +391,9 @@ class IRExecutionUnit : public std::enable_shared_from_this, std::vector m_failed_lookups; std::atomic m_did_jit; + // BEGIN SWIFT + std::atomic m_in_populate_symtab = false; + // END SWIFT lldb::addr_t m_function_load_addr; lldb::addr_t m_function_end_load_addr; diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 5841991bd651a9..ff5ddb46269ead 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -840,17 +840,20 @@ IRExecutionUnit::FindInSymbols(const std::vector &names, } if (sc.target_sp) { + ModuleList images = sc.target_sp->GetImages(); + // BEGIN SWIFT + if (m_in_populate_symtab) + if (lldb::ModuleSP module_sp = m_jit_module_wp.lock()) + images.Remove(module_sp); + // END SWIFT + SymbolContextList sc_list; - sc.target_sp->GetImages().FindFunctions(name, lldb::eFunctionNameTypeFull, - function_options, sc_list); + images.FindFunctions(name, lldb::eFunctionNameTypeFull, function_options, + sc_list); if (auto load_addr = resolver.Resolve(sc_list)) return *load_addr; - } - if (sc.target_sp) { - SymbolContextList sc_list; - sc.target_sp->GetImages().FindSymbolsWithNameAndType( - name, lldb::eSymbolTypeAny, sc_list); + images.FindSymbolsWithNameAndType(name, lldb::eSymbolTypeAny, sc_list); if (auto load_addr = resolver.Resolve(sc_list)) return *load_addr; } @@ -1195,6 +1198,9 @@ uint32_t IRExecutionUnit::GetAddressByteSize() const { void IRExecutionUnit::PopulateSymtab(lldb_private::ObjectFile *obj_file, lldb_private::Symtab &symtab) { + // BEGIN SWIFT + m_in_populate_symtab = true; + auto _ = llvm::make_scope_exit([this]() { m_in_populate_symtab = false; }); if (m_execution_engine_up) { uint32_t symbol_id = 0; lldb_private::SectionList *section_list = obj_file->GetSectionList(); @@ -1272,6 +1278,7 @@ void IRExecutionUnit::PopulateSymtab(lldb_private::ObjectFile *obj_file, } } } + // END SWIFT } void IRExecutionUnit::PopulateSectionList(