Skip to content

Commit c2ffb42

Browse files
authored
[lldb] Fix TestLoadUnload.py (#117416)
ELF core debugging fix #117070 broke TestLoadUnload.py tests due to GetModuleSpec call, ProcessGDBRemote fetches modules from remote. Revise the original PR, renamed FindBuildId to FindModuleUUID.
1 parent ff97b28 commit c2ffb42

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed

lldb/include/lldb/Target/Process.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,8 @@ class Process : public std::enable_shared_from_this<Process>,
13801380

13811381
virtual bool GetProcessInfo(ProcessInstanceInfo &info);
13821382

1383+
virtual lldb_private::UUID FindModuleUUID(const llvm::StringRef path);
1384+
13831385
/// Get the exit status for a process.
13841386
///
13851387
/// \return

lldb/source/Core/DynamicLoader.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,9 @@ 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;
160+
if (UUID uuid = m_process->FindModuleUUID(file.GetPath())) {
161+
// Process may be able to augment the module_spec with UUID, e.g. ELF core.
162+
module_spec.GetUUID() = uuid;
165163
}
166164

167165
if (ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec))

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,12 @@ 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;
289+
UUID ProcessElfCore::FindModuleUUID(const llvm::StringRef path) {
290+
// Returns the gnu uuid from matched NT_FILE entry
291+
for (NT_FILE_Entry &entry : m_nt_file_entries)
292+
if (path == entry.path)
293+
return entry.uuid;
294+
return UUID();
303295
}
304296

305297
lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ 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;
166+
lldb_private::UUID FindModuleUUID(const llvm::StringRef path) override;
169167

170168
// Returns the value of certain type of note of a given start address
171169
lldb_private::UUID FindBuidIdInCoreMemory(lldb::addr_t address);

lldb/source/Target/Process.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6080,6 +6080,10 @@ bool Process::GetProcessInfo(ProcessInstanceInfo &info) {
60806080
return platform_sp->GetProcessInfo(GetID(), info);
60816081
}
60826082

6083+
lldb_private::UUID Process::FindModuleUUID(const llvm::StringRef path) {
6084+
return lldb_private::UUID();
6085+
}
6086+
60836087
ThreadCollectionSP Process::GetHistoryThreads(lldb::addr_t addr) {
60846088
ThreadCollectionSP threads;
60856089

0 commit comments

Comments
 (0)