summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Target.cpp
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2019-04-08 23:03:02 +0000
committerJason Molenda <jmolenda@apple.com>2019-04-08 23:03:02 +0000
commit1724a179e7ae2d0485f0fc8fee7ac3a18cc29152 (patch)
tree87bbd2f536267e1116e4243d67fe446449be3c35 /lldb/source/Target/Target.cpp
parente794752bdfb334b64b2d356e9c0444572ad19da1 (diff)
downloadbcm5719-llvm-1724a179e7ae2d0485f0fc8fee7ac3a18cc29152.tar.gz
bcm5719-llvm-1724a179e7ae2d0485f0fc8fee7ac3a18cc29152.zip
Rename Target::GetSharedModule to Target::GetOrCreateModule.
Add a flag to control whether the ModulesDidLoad notification is called when a module is added. If the notifications are disabled, the caller must call ModulesDidLoad after adding all the new modules, but postponing this notification until they're all batched up can allow for better efficiency than notifying one-by-one. Change the name of the ModuleList notifier functions that a subclass can implement to start with 'Notify' to make it clear what they are. Add a NotifyModulesRemoved. Add header documentation for the changed/updated methods. Added defaulted-value 'notify' argument to ModuleList Append, AppendIfNeeded, and Remove because callers working with a local ModuleList don't have an obvious idea of what notify means in this context. When the ModuleList is a part of the Target class, the notify behavior matters. DynamicLoaderDarwin has been updated so that libraries being added/removed are correctly batched up before notifications are sent. Added the TestModuleLoadedNotifys.py test to run on Darwin to test this. <rdar://problem/48293064> Differential Revision: https://reviews.llvm.org/D60172 llvm-svn: 357955
Diffstat (limited to 'lldb/source/Target/Target.cpp')
-rw-r--r--lldb/source/Target/Target.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index a1bf4d9de01..f382813a4f8 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1442,7 +1442,8 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
"Target::SetExecutableModule (executable = '%s')",
executable_sp->GetFileSpec().GetPath().c_str());
- m_images.Append(executable_sp); // The first image is our executable file
+ const bool notify = true;
+ m_images.Append(executable_sp, notify); // The first image is our executable file
// If we haven't set an architecture yet, reset our architecture based on
// what we found in the executable module.
@@ -1470,6 +1471,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
}
if (executable_objfile && load_dependents) {
+ ModuleList added_modules;
executable_objfile->GetDependentModules(dependent_files);
for (uint32_t i = 0; i < dependent_files.GetSize(); i++) {
FileSpec dependent_file_spec(
@@ -1482,13 +1484,16 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
platform_dependent_file_spec = dependent_file_spec;
ModuleSpec module_spec(platform_dependent_file_spec, m_arch.GetSpec());
- ModuleSP image_module_sp(GetSharedModule(module_spec));
+ ModuleSP image_module_sp(GetOrCreateModule(module_spec,
+ false /* notify */));
if (image_module_sp) {
+ added_modules.AppendIfNeeded (image_module_sp, false);
ObjectFile *objfile = image_module_sp->GetObjectFile();
if (objfile)
objfile->GetDependentModules(dependent_files);
}
}
+ ModulesDidLoad(added_modules);
}
}
}
@@ -1606,20 +1611,19 @@ bool Target::MergeArchitecture(const ArchSpec &arch_spec) {
return false;
}
-void Target::WillClearList(const ModuleList &module_list) {}
+void Target::NotifyWillClearList(const ModuleList &module_list) {}
-void Target::ModuleAdded(const ModuleList &module_list,
+void Target::NotifyModuleAdded(const ModuleList &module_list,
const ModuleSP &module_sp) {
// A module is being added to this target for the first time
if (m_valid) {
ModuleList my_module_list;
my_module_list.Append(module_sp);
- LoadScriptingResourceForModule(module_sp, this);
ModulesDidLoad(my_module_list);
}
}
-void Target::ModuleRemoved(const ModuleList &module_list,
+void Target::NotifyModuleRemoved(const ModuleList &module_list,
const ModuleSP &module_sp) {
// A module is being removed from this target.
if (m_valid) {
@@ -1629,7 +1633,7 @@ void Target::ModuleRemoved(const ModuleList &module_list,
}
}
-void Target::ModuleUpdated(const ModuleList &module_list,
+void Target::NotifyModuleUpdated(const ModuleList &module_list,
const ModuleSP &old_module_sp,
const ModuleSP &new_module_sp) {
// A module is replacing an already added module
@@ -1641,8 +1645,20 @@ void Target::ModuleUpdated(const ModuleList &module_list,
}
}
+void Target::NotifyModulesRemoved(lldb_private::ModuleList &module_list) {
+ ModulesDidUnload (module_list, false);
+}
+
+
void Target::ModulesDidLoad(ModuleList &module_list) {
if (m_valid && module_list.GetSize()) {
+
+ const ModuleList &modules = GetImages();
+ const size_t num_images = modules.GetSize();
+ for (size_t idx = 0; idx < num_images; ++idx) {
+ ModuleSP module_sp(modules.GetModuleAtIndex(idx));
+ LoadScriptingResourceForModule(module_sp, this);
+ }
m_breakpoint_list.UpdateBreakpoints(module_list, true, false);
m_internal_breakpoint_list.UpdateBreakpoints(module_list, true, false);
if (m_process_sp) {
@@ -1984,8 +2000,8 @@ bool Target::ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
return false;
}
-ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
- Status *error_ptr) {
+ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
+ Status *error_ptr) {
ModuleSP module_sp;
Status error;
@@ -2118,8 +2134,9 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
Module *old_module_ptr = old_module_sp.get();
old_module_sp.reset();
ModuleList::RemoveSharedModuleIfOrphaned(old_module_ptr);
- } else
- m_images.Append(module_sp);
+ } else {
+ m_images.Append(module_sp, notify);
+ }
} else
module_sp.reset();
}
OpenPOWER on IntegriCloud