Skip to content

[lldb] Fix ELF core debugging #117070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lldb/source/Core/DynamicLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() = entry.uuid;
return true;
}
}

return false;
}

lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
if (m_dyld_up.get() == nullptr)
m_dyld_up.reset(DynamicLoader::FindPlugin(
Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading