@@ -785,38 +785,50 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
785
785
return LLDB_INVALID_ADDRESS;
786
786
}
787
787
788
+ ModuleList images = target->GetImages ();
789
+ // We'll process module_sp separately, before the other modules.
790
+ images.Remove (sc.module_sp );
791
+
788
792
LoadAddressResolver resolver (target, symbol_was_missing_weak);
789
793
790
794
ModuleFunctionSearchOptions function_options;
791
795
function_options.include_symbols = true ;
792
796
function_options.include_inlines = false ;
793
797
794
798
for (const ConstString &name : names) {
799
+ // The lookup order here is as follows:
800
+ // 1) Functions in `sc.module_sp`
801
+ // 2) Functions in the other modules
802
+ // 3) Symbols in `sc.module_sp`
803
+ // 4) Symbols in the other modules
804
+ SymbolContextList sc_list;
795
805
if (sc.module_sp ) {
796
- SymbolContextList sc_list;
797
806
sc.module_sp ->FindFunctions (name, CompilerDeclContext (),
798
807
lldb::eFunctionNameTypeFull, function_options,
799
808
sc_list);
800
809
if (auto load_addr = resolver.Resolve (sc_list))
801
810
return *load_addr;
811
+ sc_list.Clear ();
802
812
}
803
813
804
- if (sc.target_sp ) {
805
- SymbolContextList sc_list;
806
- sc.target_sp ->GetImages ().FindFunctions (name, lldb::eFunctionNameTypeFull,
807
- function_options, sc_list);
808
- if (auto load_addr = resolver.Resolve (sc_list))
809
- return *load_addr;
810
- }
814
+ images.FindFunctions (name, lldb::eFunctionNameTypeFull, function_options,
815
+ sc_list);
816
+ if (auto load_addr = resolver.Resolve (sc_list))
817
+ return *load_addr;
818
+ sc_list.Clear ();
811
819
812
- if (sc.target_sp ) {
813
- SymbolContextList sc_list;
814
- sc.target_sp ->GetImages ().FindSymbolsWithNameAndType (
815
- name, lldb::eSymbolTypeAny, sc_list);
820
+ if (sc.module_sp ) {
821
+ sc.module_sp ->FindSymbolsWithNameAndType (name, lldb::eSymbolTypeAny,
822
+ sc_list);
816
823
if (auto load_addr = resolver.Resolve (sc_list))
817
824
return *load_addr;
825
+ sc_list.Clear ();
818
826
}
819
827
828
+ images.FindSymbolsWithNameAndType (name, lldb::eSymbolTypeAny, sc_list);
829
+ if (auto load_addr = resolver.Resolve (sc_list))
830
+ return *load_addr;
831
+
820
832
lldb::addr_t best_internal_load_address =
821
833
resolver.GetBestInternalLoadAddress ();
822
834
if (best_internal_load_address != LLDB_INVALID_ADDRESS)
0 commit comments