|
19 | 19 | #include "lldb/Symbol/SymbolContext.h" |
20 | 20 | #include "lldb/Symbol/TypeList.h" |
21 | 21 | #include "lldb/Symbol/VariableList.h" |
| 22 | +#include "lldb/Target/Platform.h" |
22 | 23 | #include "lldb/Target/Target.h" |
23 | 24 | #include "lldb/Utility/ArchSpec.h" |
24 | 25 | #include "lldb/Utility/ConstString.h" |
@@ -1031,7 +1032,8 @@ size_t ModuleList::RemoveOrphanSharedModules(bool mandatory) { |
1031 | 1032 | Status |
1032 | 1033 | ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, |
1033 | 1034 | llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, |
1034 | | - bool *did_create_ptr, bool always_create) { |
| 1035 | + bool *did_create_ptr, bool always_create, |
| 1036 | + bool allow_locate_callback) { |
1035 | 1037 | ModuleList &shared_module_list = GetSharedModuleList(); |
1036 | 1038 | std::lock_guard<std::recursive_mutex> guard( |
1037 | 1039 | shared_module_list.m_modules_mutex); |
@@ -1087,6 +1089,24 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, |
1087 | 1089 | if (module_sp) |
1088 | 1090 | return error; |
1089 | 1091 |
|
| 1092 | + // Try target's platform locate module callback before second attempt |
| 1093 | + if (allow_locate_callback) { |
| 1094 | + ModuleSpec module_spec_copy(module_spec); |
| 1095 | + Target *target = module_spec_copy.GetTargetPtr(); |
| 1096 | + if (target && target->IsValid()) { |
| 1097 | + Platform *platform = target->GetPlatform().get(); |
| 1098 | + if (platform) { |
| 1099 | + FileSpec symbol_file_spec; |
| 1100 | + platform->CallLocateModuleCallbackIfSet( |
| 1101 | + module_spec, module_sp, symbol_file_spec, did_create_ptr); |
| 1102 | + if (module_sp) { |
| 1103 | + // Success! The callback found a module |
| 1104 | + return error; |
| 1105 | + } |
| 1106 | + } |
| 1107 | + } |
| 1108 | + } |
| 1109 | + |
1090 | 1110 | module_sp = std::make_shared<Module>(module_spec); |
1091 | 1111 | // Make sure there are a module and an object file since we can specify a |
1092 | 1112 | // valid file path with an architecture that might not be in that file. By |
@@ -1119,7 +1139,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, |
1119 | 1139 | Target *target = module_spec_copy.GetTargetPtr(); |
1120 | 1140 | FileSpecList module_search_paths; |
1121 | 1141 | FileSpecList *module_search_paths_ptr = nullptr; |
1122 | | - if (target) { |
| 1142 | + if (target && target->IsValid()) { |
1123 | 1143 | module_search_paths = target->GetExecutableSearchPaths(); |
1124 | 1144 | module_search_paths_ptr = &module_search_paths; |
1125 | 1145 | } |
|
0 commit comments