@@ -785,13 +785,22 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
785
785
return LLDB_INVALID_ADDRESS;
786
786
}
787
787
788
+ ModuleList non_local_images = target->GetImages ();
789
+ // We'll process module_sp separately, before the other modules.
790
+ non_local_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
795
804
if (sc.module_sp ) {
796
805
SymbolContextList sc_list;
797
806
sc.module_sp ->FindFunctions (name, CompilerDeclContext (),
@@ -801,18 +810,26 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
801
810
return *load_addr;
802
811
}
803
812
804
- if (sc.target_sp ) {
813
+ {
814
+ SymbolContextList sc_list;
815
+ non_local_images.FindFunctions (name, lldb::eFunctionNameTypeFull,
816
+ function_options, sc_list);
817
+ if (auto load_addr = resolver.Resolve (sc_list))
818
+ return *load_addr;
819
+ }
820
+
821
+ if (sc.module_sp ) {
805
822
SymbolContextList sc_list;
806
- sc.target_sp -> GetImages (). FindFunctions ( name, lldb::eFunctionNameTypeFull ,
807
- function_options, sc_list);
823
+ sc.module_sp -> FindSymbolsWithNameAndType ( name, lldb::eSymbolTypeAny ,
824
+ sc_list);
808
825
if (auto load_addr = resolver.Resolve (sc_list))
809
826
return *load_addr;
810
827
}
811
828
812
- if (sc. target_sp ) {
829
+ {
813
830
SymbolContextList sc_list;
814
- sc. target_sp -> GetImages (). FindSymbolsWithNameAndType (
815
- name, lldb::eSymbolTypeAny, sc_list);
831
+ non_local_images. FindSymbolsWithNameAndType (name, lldb::eSymbolTypeAny,
832
+ sc_list);
816
833
if (auto load_addr = resolver.Resolve (sc_list))
817
834
return *load_addr;
818
835
}
0 commit comments