<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/95107>95107</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [LLDB][Linux]Can not load the right module when loading a module having same name but different path with a loaded module
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          LeoJialiang
      </td>
    </tr>
</table>

<pre>
    Some dynamic linker support to load module with the same name under different directories, like bionic.

When debugging a program which will link /PathA/liba.so by default, and it will dlopen /PathB/liba.so during runtime, the /PathB/liba.so can not be loaded correctly. LLDB will use /PathA/liba.so as the module of /PathB/liba.so. But /PathA/liba.so and /PathB/liba.so are different.

I find that, in [Status NativeProcessLinux::GetLoadedModuleFileSpec](https://github.com/llvm/llvm-project/blob/3cc2710e0dd53bb82742904fa13014018a1137ed/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp#L1840) , lldb will look for the module_path in the m_mem_region_cache, and just check the Filename without checking directory. This logic let lldb think two different so with same name the same.

Shall we change the NativeProcessLinux::GetLoadedModuleFileSpe to:
`Status NativeProcessLinux::GetLoadedModuleFileSpec(const char *module_path,
 FileSpec &file_spec) {
 Status error = PopulateMemoryRegionCache();
  if (error.Fail())
 return error;

  FileSpec module_file_spec(module_path);
 FileSystem::Instance().Resolve(module_file_spec);

 file_spec.Clear();
  for (const auto &it : m_mem_region_cache) {
    if (it.second.GetFilename() == module_file_spec.GetFilename() &&
 it.second.GetDirectory() == module_file_spec.GetDirectory()) {
 file_spec = it.second;
      return Status();
    }
  }
  return Status("Module file (%s) not found in /proc/%" PRIu64 "/maps file!",
 module_file_spec.GetFilename().AsCString(), GetID());
}`

I am not sure whether this change will make some other bug. Please take a look.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVttu4zYQ_Rr6ZVBBomzLfvCDL_AiR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