fjricci created this revision. fjricci added reviewers: ADodds, zturner, tfiala. fjricci added subscribers: sas, lldb-commits.
When we receive an svr4 packet from the remote, we check for new modules and add them to the list of images in the target. However, we did not do the same for modules which have been removed. This was causing TestLoadUnload to fail when using ds2, which uses svr4 packets to communicate all library info on Linux. This patch fixes the failing test. http://reviews.llvm.org/D19230 Files: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4879,7 +4879,31 @@ if (new_modules.GetSize() > 0) { + ModuleList removed_modules; Target &target = GetTarget(); + ModuleList &loaded_modules = m_process->GetTarget().GetImages(); + + for (size_t i = 0; i < loaded_modules.GetSize(); ++i) + { + const lldb::ModuleSP loaded_module = loaded_modules.GetModuleAtIndex(i); + + bool found = false; + for (size_t j = 0; j < new_modules.GetSize(); ++j) + { + if (new_modules.GetModuleAtIndex(j).get() == loaded_module.get()) + found = true; + } + + if (!found) + { + lldb_private::ObjectFile * obj = loaded_module->GetObjectFile (); + if (obj && obj->GetType () != ObjectFile::Type::eTypeExecutable) + removed_modules.Append (loaded_module); + } + } + + loaded_modules.Remove (removed_modules); + m_process->GetTarget().ModulesDidUnload (removed_modules, false); new_modules.ForEach ([&target](const lldb::ModuleSP module_sp) -> bool { @@ -4895,13 +4919,11 @@ return false; }); - ModuleList &loaded_modules = m_process->GetTarget().GetImages(); loaded_modules.AppendIfNeeded (new_modules); m_process->GetTarget().ModulesDidLoad (new_modules); } return new_modules.GetSize(); - } size_t
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4879,7 +4879,31 @@ if (new_modules.GetSize() > 0) { + ModuleList removed_modules; Target &target = GetTarget(); + ModuleList &loaded_modules = m_process->GetTarget().GetImages(); + + for (size_t i = 0; i < loaded_modules.GetSize(); ++i) + { + const lldb::ModuleSP loaded_module = loaded_modules.GetModuleAtIndex(i); + + bool found = false; + for (size_t j = 0; j < new_modules.GetSize(); ++j) + { + if (new_modules.GetModuleAtIndex(j).get() == loaded_module.get()) + found = true; + } + + if (!found) + { + lldb_private::ObjectFile * obj = loaded_module->GetObjectFile (); + if (obj && obj->GetType () != ObjectFile::Type::eTypeExecutable) + removed_modules.Append (loaded_module); + } + } + + loaded_modules.Remove (removed_modules); + m_process->GetTarget().ModulesDidUnload (removed_modules, false); new_modules.ForEach ([&target](const lldb::ModuleSP module_sp) -> bool { @@ -4895,13 +4919,11 @@ return false; }); - ModuleList &loaded_modules = m_process->GetTarget().GetImages(); loaded_modules.AppendIfNeeded (new_modules); m_process->GetTarget().ModulesDidLoad (new_modules); } return new_modules.GetSize(); - } size_t
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits