Index: include/lldb/Core/ModuleList.h =================================================================== --- include/lldb/Core/ModuleList.h +++ include/lldb/Core/ModuleList.h @@ -541,7 +541,8 @@ const FileSpecList *module_search_paths_ptr, lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr, - bool always_create = false); + bool always_create = false, + const char* sysroot = nullptr); static bool RemoveSharedModule(lldb::ModuleSP &module_sp); Index: source/Core/ModuleList.cpp =================================================================== --- source/Core/ModuleList.cpp +++ source/Core/ModuleList.cpp @@ -707,7 +707,11 @@ ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, - bool *did_create_ptr, bool always_create) { + bool *did_create_ptr, bool always_create, + const char* sysroot) { + // Make sure no one else can try and get or create a module while this + // function is actively working on it by doing an extra lock on the + // global mutex list. ModuleList &shared_module_list = GetSharedModuleList(); std::lock_guard guard( shared_module_list.m_modules_mutex); @@ -726,9 +730,6 @@ const FileSpec &module_file_spec = module_spec.GetFileSpec(); const ArchSpec &arch = module_spec.GetArchitecture(); - // Make sure no one else can try and get or create a module while this - // function is actively working on it by doing an extra lock on the - // global mutex list. if (!always_create) { ModuleList matching_module_list; const size_t num_matching_modules = @@ -762,7 +763,11 @@ if (module_sp) return error; - module_sp.reset(new Module(module_spec)); + auto resolved_module_spec(module_spec); + if (sysroot != nullptr) + resolved_module_spec.GetFileSpec().PrependPathComponent(sysroot); + + module_sp.reset(new Module(resolved_module_spec)); // Make sure there are a module and an object file since we can specify // a valid file path with an architecture that might not be in that file. // By getting the object file we can guarantee that the architecture matches Index: source/Target/Platform.cpp =================================================================== --- source/Target/Platform.cpp +++ source/Target/Platform.cpp @@ -225,13 +225,14 @@ if (IsHost()) return ModuleList::GetSharedModule( module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, - did_create_ptr, false); + did_create_ptr, false, m_sdk_sysroot.AsCString()); return GetRemoteSharedModule(module_spec, process, module_sp, [&](const ModuleSpec &spec) { Status error = ModuleList::GetSharedModule( spec, module_sp, module_search_paths_ptr, - old_module_sp_ptr, did_create_ptr, false); + old_module_sp_ptr, did_create_ptr, false, + m_sdk_sysroot.AsCString()); if (error.Success() && module_sp) module_sp->SetPlatformFileSpec( spec.GetFileSpec());