================
@@ -257,12 +257,21 @@ Status ProcessElfCore::DoLoadCore() {
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
   if (!exe_module_sp) {
-    // The first entry in the NT_FILE might be our executable
     if (!m_nt_file_entries.empty()) {
+      // The first entry in the NT_FILE might be our executable
+      llvm::StringRef executable_path = m_nt_file_entries[0].path;
+      // Prefer the NT_FILE entry matching m_executable_name as main 
executable.
+      for (const NT_FILE_Entry &file_entry : m_nt_file_entries)
+        if (llvm::StringRef(file_entry.path)
+                .ends_with("/" + m_executable_name)) {
+          executable_path = file_entry.path;
+          break;
+        }
+
       ModuleSpec exe_module_spec;
       exe_module_spec.GetArchitecture() = arch;
-      exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
-      exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
+      exe_module_spec.GetUUID() = FindModuleUUID(executable_path);
----------------
GeorgeHuyubo wrote:

Actually FindModuleUUID is also used here:
https://github.com/llvm/llvm-project/blob/main/lldb/source/Core/DynamicLoader.cpp#L160

https://github.com/llvm/llvm-project/pull/157170
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to