[llvm-branch-commits] [lldb] r270133 - Properly unload modules from target image list when using svr4 packets
Francis Ricci via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu May 19 14:04:16 PDT 2016
Author: fjricci
Date: Thu May 19 16:04:16 2016
New Revision: 270133
URL: http://llvm.org/viewvc/llvm-project?rev=270133&view=rev
Log:
Properly unload modules from target image list when using svr4 packets
Summary:
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.
Reviewers: zturner, tfiala, ADodds
Subscribers: lldb-commits, sas
Differential Revision: http://reviews.llvm.org/D19230
This is a cherry-pick of 267467
Modified:
lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Modified: lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=270133&r1=270132&r2=270133&view=diff
==============================================================================
--- lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/branches/release_38/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu May 19 16:04:16 2016
@@ -4851,7 +4851,31 @@ ProcessGDBRemote::LoadModules (LoadedMod
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
{
@@ -4867,13 +4891,11 @@ ProcessGDBRemote::LoadModules (LoadedMod
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
More information about the llvm-branch-commits
mailing list