diff options
author | Jason Molenda <jmolenda@apple.com> | 2019-04-08 23:03:02 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2019-04-08 23:03:02 +0000 |
commit | 1724a179e7ae2d0485f0fc8fee7ac3a18cc29152 (patch) | |
tree | 87bbd2f536267e1116e4243d67fe446449be3c35 /lldb/source/Core/ModuleList.cpp | |
parent | e794752bdfb334b64b2d356e9c0444572ad19da1 (diff) | |
download | bcm5719-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/Core/ModuleList.cpp')
-rw-r--r-- | lldb/source/Core/ModuleList.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index d59e429ad9f..e02c6e5af27 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -147,11 +147,13 @@ void ModuleList::AppendImpl(const ModuleSP &module_sp, bool use_notifier) { std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); m_modules.push_back(module_sp); if (use_notifier && m_notifier) - m_notifier->ModuleAdded(*this, module_sp); + m_notifier->NotifyModuleAdded(*this, module_sp); } } -void ModuleList::Append(const ModuleSP &module_sp) { AppendImpl(module_sp); } +void ModuleList::Append(const ModuleSP &module_sp, bool notify) { + AppendImpl(module_sp, notify); +} void ModuleList::ReplaceEquivalent(const ModuleSP &module_sp) { if (module_sp) { @@ -177,7 +179,7 @@ void ModuleList::ReplaceEquivalent(const ModuleSP &module_sp) { } } -bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp) { +bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp, bool notify) { if (module_sp) { std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); collection::iterator pos, end = m_modules.end(); @@ -186,7 +188,7 @@ bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp) { return false; // Already in the list } // Only push module_sp on the list if it wasn't already in there. - Append(module_sp); + Append(module_sp, notify); return true; } return false; @@ -214,7 +216,7 @@ bool ModuleList::RemoveImpl(const ModuleSP &module_sp, bool use_notifier) { if (pos->get() == module_sp.get()) { m_modules.erase(pos); if (use_notifier && m_notifier) - m_notifier->ModuleRemoved(*this, module_sp); + m_notifier->NotifyModuleRemoved(*this, module_sp); return true; } } @@ -228,12 +230,12 @@ ModuleList::RemoveImpl(ModuleList::collection::iterator pos, ModuleSP module_sp(*pos); collection::iterator retval = m_modules.erase(pos); if (use_notifier && m_notifier) - m_notifier->ModuleRemoved(*this, module_sp); + m_notifier->NotifyModuleRemoved(*this, module_sp); return retval; } -bool ModuleList::Remove(const ModuleSP &module_sp) { - return RemoveImpl(module_sp); +bool ModuleList::Remove(const ModuleSP &module_sp, bool notify) { + return RemoveImpl(module_sp, notify); } bool ModuleList::ReplaceModule(const lldb::ModuleSP &old_module_sp, @@ -242,7 +244,7 @@ bool ModuleList::ReplaceModule(const lldb::ModuleSP &old_module_sp, return false; AppendImpl(new_module_sp, false); if (m_notifier) - m_notifier->ModuleUpdated(*this, old_module_sp, new_module_sp); + m_notifier->NotifyModuleUpdated(*this, old_module_sp, new_module_sp); return true; } @@ -291,9 +293,11 @@ size_t ModuleList::Remove(ModuleList &module_list) { size_t num_removed = 0; collection::iterator pos, end = module_list.m_modules.end(); for (pos = module_list.m_modules.begin(); pos != end; ++pos) { - if (Remove(*pos)) + if (Remove(*pos, false /* notify */)) ++num_removed; } + if (m_notifier) + m_notifier->NotifyModulesRemoved(module_list); return num_removed; } @@ -304,7 +308,7 @@ void ModuleList::Destroy() { ClearImpl(); } void ModuleList::ClearImpl(bool use_notifier) { std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); if (use_notifier && m_notifier) - m_notifier->WillClearList(*this); + m_notifier->NotifyWillClearList(*this); m_modules.clear(); } |