diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1606,13 +1606,9 @@ } bool Module::MatchesModuleSpec(const ModuleSpec &module_ref) { - const UUID &uuid = module_ref.GetUUID(); - - if (uuid.IsValid()) { - // If the UUID matches, then nothing more needs to match... - return (uuid == GetUUID()); - } - + // We first check the file paths as there can be more than one loaded module + // at different paths with the same UUID. This happens with some Android + // installations where the VNDK modules are the same as the system ones. const FileSpec &file_spec = module_ref.GetFileSpec(); if (file_spec) { if (!FileSpec::Equal(file_spec, m_file, (bool)file_spec.GetDirectory()) && @@ -1628,6 +1624,12 @@ return false; } + const UUID &uuid = module_ref.GetUUID(); + if (uuid.IsValid()) { + // If the UUID matches, then nothing more needs to match... + return (uuid == GetUUID()); + } + const ArchSpec &arch = module_ref.GetArchitecture(); if (arch.IsValid()) { if (!m_arch.IsCompatibleMatch(arch)) diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1628,8 +1628,9 @@ FileSystem::Instance().Resolve(module_file_spec); file_spec.Clear(); + bool full_comparison = false; for (const auto &it : m_mem_region_cache) { - if (it.second.GetFilename() == module_file_spec.GetFilename()) { + if (FileSpec::Compare(it.second, module_file_spec, full_comparison) == 0) { file_spec = it.second; return Status(); } diff --git a/lldb/source/Target/ModuleCache.cpp b/lldb/source/Target/ModuleCache.cpp --- a/lldb/source/Target/ModuleCache.cpp +++ b/lldb/source/Target/ModuleCache.cpp @@ -211,8 +211,8 @@ Status ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname, const ModuleSpec &module_spec, ModuleSP &cached_module_sp, bool *did_create_ptr) { - const auto find_it = - m_loaded_modules.find(module_spec.GetUUID().GetAsString()); + const auto module_path = module_spec.GetFileSpec().GetCString(); + const auto find_it = m_loaded_modules.find(module_path); if (find_it != m_loaded_modules.end()) { cached_module_sp = (*find_it).second.lock(); if (cached_module_sp) @@ -256,8 +256,7 @@ if (FileSystem::Instance().Exists(symfile_spec)) cached_module_sp->SetSymbolFileFileSpec(symfile_spec); - m_loaded_modules.insert( - std::make_pair(module_spec.GetUUID().GetAsString(), cached_module_sp)); + m_loaded_modules.insert(std::make_pair(module_path, cached_module_sp)); return Status(); }