[Lldb-commits] [lldb] [lldb][ElfCore] Improve main executable detection in core files (PR #157170)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 10 11:02:59 PDT 2025
================
@@ -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
More information about the lldb-commits
mailing list