[Lldb-commits] [lldb] [lldb] Fix ELF core debugging (PR #117070)
Kazuki Sakamoto via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 21 20:02:28 PST 2024
https://github.com/splhack updated https://github.com/llvm/llvm-project/pull/117070
>From b93478345fbaa747b44d678207b768948db0a7d6 Mon Sep 17 00:00:00 2001
From: Kazuki Sakamoto <sakamoto at splhack.org>
Date: Wed, 20 Nov 2024 13:49:26 -0800
Subject: [PATCH] [lldb] Fix ELF core debugging
DynamicLoader does not use ProcessElfCore NT_FILE entries to get
UUID. Use GetModuleSpec to get UUID from Process.
---
lldb/source/Core/DynamicLoader.cpp | 6 ++++++
.../Plugins/Process/elf-core/ProcessElfCore.cpp | 16 ++++++++++++++++
.../Plugins/Process/elf-core/ProcessElfCore.h | 4 ++++
3 files changed, 26 insertions(+)
diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp
index 68d6ab0850853f..3c6c6bd365706e 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -157,6 +157,12 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP module) const {
ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) {
Target &target = m_process->GetTarget();
ModuleSpec module_spec(file, target.GetArchitecture());
+ ModuleSpec module_spec_from_process;
+ // Process may be able to augment the module_spec with UUID, e.g. ELF core.
+ if (m_process->GetModuleSpec(file, target.GetArchitecture(),
+ module_spec_from_process)) {
+ module_spec = module_spec_from_process;
+ }
if (ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec))
return module_sp;
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index a5ee3cfdb2932a..e4284905c07240 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -286,6 +286,22 @@ void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
}
}
+bool ProcessElfCore::GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch,
+ ModuleSpec &module_spec) {
+ module_spec.Clear();
+ for (NT_FILE_Entry &entry : m_nt_file_entries) {
+ if (module_file_spec.GetPath() == entry.path) {
+ module_spec.GetFileSpec() = module_file_spec;
+ module_spec.GetArchitecture() = arch;
+ module_spec.GetUUID().SetFromStringRef(entry.uuid.GetAsString());
+ return true;
+ }
+ }
+
+ return false;
+}
+
lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
if (m_dyld_up.get() == nullptr)
m_dyld_up.reset(DynamicLoader::FindPlugin(
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index 280c61ed376396..a7b1822ccf01ff 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -163,6 +163,10 @@ class ProcessElfCore : public lldb_private::PostMortemProcess {
// Populate gnu uuid for each NT_FILE entry
void UpdateBuildIdForNTFileEntries();
+ bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
+ const lldb_private::ArchSpec &arch,
+ lldb_private::ModuleSpec &module_spec) override;
+
// Returns the value of certain type of note of a given start address
lldb_private::UUID FindBuidIdInCoreMemory(lldb::addr_t address);
More information about the lldb-commits
mailing list