@@ -785,38 +785,50 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
785785 return LLDB_INVALID_ADDRESS;
786786 }
787787
788+ ModuleList images = target->GetImages ();
789+ // We'll process module_sp separately, before the other modules.
790+ images.Remove (sc.module_sp );
791+
788792 LoadAddressResolver resolver (target, symbol_was_missing_weak);
789793
790794 ModuleFunctionSearchOptions function_options;
791795 function_options.include_symbols = true ;
792796 function_options.include_inlines = false ;
793797
794798 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;
795805 if (sc.module_sp ) {
796- SymbolContextList sc_list;
797806 sc.module_sp ->FindFunctions (name, CompilerDeclContext (),
798807 lldb::eFunctionNameTypeFull, function_options,
799808 sc_list);
800809 if (auto load_addr = resolver.Resolve (sc_list))
801810 return *load_addr;
811+ sc_list.Clear ();
802812 }
803813
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 ();
811819
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);
816823 if (auto load_addr = resolver.Resolve (sc_list))
817824 return *load_addr;
825+ sc_list.Clear ();
818826 }
819827
828+ images.FindSymbolsWithNameAndType (name, lldb::eSymbolTypeAny, sc_list);
829+ if (auto load_addr = resolver.Resolve (sc_list))
830+ return *load_addr;
831+
820832 lldb::addr_t best_internal_load_address =
821833 resolver.GetBestInternalLoadAddress ();
822834 if (best_internal_load_address != LLDB_INVALID_ADDRESS)
0 commit comments