Skip to content

Commit 1290e95

Browse files
authored
[lldb] Fix ELF core debugging (#117070)
DynamicLoader does not use ProcessElfCore NT_FILE entries to get UUID. Use GetModuleSpec to get UUID from Process.
1 parent e131b0d commit 1290e95

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

lldb/source/Core/DynamicLoader.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP module) const {
157157
ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) {
158158
Target &target = m_process->GetTarget();
159159
ModuleSpec module_spec(file, target.GetArchitecture());
160+
ModuleSpec module_spec_from_process;
161+
// Process may be able to augment the module_spec with UUID, e.g. ELF core.
162+
if (m_process->GetModuleSpec(file, target.GetArchitecture(),
163+
module_spec_from_process)) {
164+
module_spec = module_spec_from_process;
165+
}
160166

161167
if (ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec))
162168
return module_sp;

lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,22 @@ void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
286286
}
287287
}
288288

289+
bool ProcessElfCore::GetModuleSpec(const FileSpec &module_file_spec,
290+
const ArchSpec &arch,
291+
ModuleSpec &module_spec) {
292+
module_spec.Clear();
293+
for (NT_FILE_Entry &entry : m_nt_file_entries) {
294+
if (module_file_spec.GetPath() == entry.path) {
295+
module_spec.GetFileSpec() = module_file_spec;
296+
module_spec.GetArchitecture() = arch;
297+
module_spec.GetUUID() = entry.uuid;
298+
return true;
299+
}
300+
}
301+
302+
return false;
303+
}
304+
289305
lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
290306
if (m_dyld_up.get() == nullptr)
291307
m_dyld_up.reset(DynamicLoader::FindPlugin(

lldb/source/Plugins/Process/elf-core/ProcessElfCore.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ class ProcessElfCore : public lldb_private::PostMortemProcess {
163163
// Populate gnu uuid for each NT_FILE entry
164164
void UpdateBuildIdForNTFileEntries();
165165

166+
bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
167+
const lldb_private::ArchSpec &arch,
168+
lldb_private::ModuleSpec &module_spec) override;
169+
166170
// Returns the value of certain type of note of a given start address
167171
lldb_private::UUID FindBuidIdInCoreMemory(lldb::addr_t address);
168172

0 commit comments

Comments
 (0)