@@ -815,13 +815,27 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
815
815
return LLDB_INVALID_ADDRESS;
816
816
}
817
817
818
+ ModuleList non_local_images = target->GetImages ();
819
+ // We'll process module_sp separately, before the other modules.
820
+ non_local_images.Remove (sc.module_sp );
821
+ // BEGIN SWIFT
822
+ if (m_in_populate_symtab)
823
+ if (lldb::ModuleSP module_sp = m_jit_module_wp.lock ())
824
+ non_local_images.Remove (module_sp);
825
+ // END SWIFT
826
+
818
827
LoadAddressResolver resolver (target, symbol_was_missing_weak);
819
828
820
829
ModuleFunctionSearchOptions function_options;
821
830
function_options.include_symbols = true ;
822
831
function_options.include_inlines = false ;
823
832
824
833
for (const ConstString &name : names) {
834
+ // The lookup order here is as follows:
835
+ // 1) Functions in `sc.module_sp`
836
+ // 2) Functions in the other modules
837
+ // 3) Symbols in `sc.module_sp`
838
+ // 4) Symbols in the other modules
825
839
if (sc.module_sp ) {
826
840
SymbolContextList sc_list;
827
841
sc.module_sp ->FindFunctions (name, CompilerDeclContext (),
@@ -831,21 +845,26 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
831
845
return *load_addr;
832
846
}
833
847
834
- if (sc. target_sp ) {
835
- ModuleList images = sc. target_sp -> GetImages () ;
836
- // BEGIN SWIFT
837
- if (m_in_populate_symtab)
838
- if (lldb::ModuleSP module_sp = m_jit_module_wp. lock ( ))
839
- images. Remove (module_sp) ;
840
- // END SWIFT
848
+ {
849
+ SymbolContextList sc_list ;
850
+ non_local_images. FindFunctions (name, lldb::eFunctionNameTypeFull,
851
+ function_options, sc_list);
852
+ if (auto load_addr = resolver. Resolve (sc_list ))
853
+ return *load_addr ;
854
+ }
841
855
856
+ if (sc.module_sp ) {
842
857
SymbolContextList sc_list;
843
- images. FindFunctions (name, lldb::eFunctionNameTypeFull, function_options ,
844
- sc_list);
858
+ sc. module_sp -> FindSymbolsWithNameAndType (name, lldb::eSymbolTypeAny ,
859
+ sc_list);
845
860
if (auto load_addr = resolver.Resolve (sc_list))
846
861
return *load_addr;
862
+ }
847
863
848
- images.FindSymbolsWithNameAndType (name, lldb::eSymbolTypeAny, sc_list);
864
+ {
865
+ SymbolContextList sc_list;
866
+ non_local_images.FindSymbolsWithNameAndType (name, lldb::eSymbolTypeAny,
867
+ sc_list);
849
868
if (auto load_addr = resolver.Resolve (sc_list))
850
869
return *load_addr;
851
870
}
0 commit comments