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/Plugins | |
| 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/Plugins')
8 files changed, 20 insertions, 14 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index d88ce1c9fb7..45f6d49577c 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -841,7 +841,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( // the DebugSymbols framework with the UUID to find the binary via its // search methods. if (!m_module_sp) { - m_module_sp = target.GetSharedModule(module_spec); + m_module_sp = target.GetOrCreateModule(module_spec, true /* notify */); } if (IsKernel() && !m_module_sp) { diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp index e6deab8cd27..0fb05e99a07 100644 --- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp @@ -199,7 +199,7 @@ ModuleSP DynamicLoaderHexagonDYLD::GetTargetExecutable() { return executable; // TODO: What case is this code used? - executable = target.GetSharedModule(module_spec); + executable = target.GetOrCreateModule(module_spec, true /* notify */); if (executable.get() != target.GetExecutableModulePointer()) { // Don't load dependent images since we are in dyld where we will know and // find out about all images that are loaded diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 87e43eb6027..086169d1336 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -122,7 +122,9 @@ ModuleSP DynamicLoaderDarwin::FindTargetModuleForImageInfo( if (!module_sp) { if (can_create) { - module_sp = target.GetSharedModule(module_spec); + // We'll call Target::ModulesDidLoad after all the modules have been + // added to the target, don't let it be called for every one. + module_sp = target.GetOrCreateModule(module_spec, false /* notify */); if (!module_sp || module_sp->GetObjectFile() == NULL) module_sp = m_process->ReadModuleFromMemory(image_info.file_spec, image_info.address); @@ -637,7 +639,8 @@ bool DynamicLoaderDarwin::AddModulesUsingImageInfos( module_spec.SetObjectOffset(objfile->GetFileOffset() + commpage_section->GetFileOffset()); module_spec.SetObjectSize(objfile->GetByteSize()); - commpage_image_module_sp = target.GetSharedModule(module_spec); + commpage_image_module_sp = target.GetOrCreateModule(module_spec, + true /* notify */); if (!commpage_image_module_sp || commpage_image_module_sp->GetObjectFile() == NULL) { commpage_image_module_sp = m_process->ReadModuleFromMemory( diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 6583a809efc..31ab9faca70 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -543,7 +543,8 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule() { FileSpec file(info.GetName().GetCString()); ModuleSpec module_spec(file, target.GetArchitecture()); - if (ModuleSP module_sp = target.GetSharedModule(module_spec)) { + if (ModuleSP module_sp = target.GetOrCreateModule(module_spec, + true /* notify */)) { UpdateLoadedSections(module_sp, LLDB_INVALID_ADDRESS, m_interpreter_base, false); return module_sp; diff --git a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp index a2a17b2d4bd..fa3fbe0d9fa 100644 --- a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp @@ -68,11 +68,9 @@ void DynamicLoaderWindowsDYLD::OnLoadModule(lldb::ModuleSP module_sp, // Resolve the module unless we already have one. if (!module_sp) { - // Confusingly, there is no Target::AddSharedModule. Instead, calling - // GetSharedModule() with a new module will add it to the module list and - // return a corresponding ModuleSP. Status error; - module_sp = m_process->GetTarget().GetSharedModule(module_spec, &error); + module_sp = m_process->GetTarget().GetOrCreateModule(module_spec, + true /* notify */, &error); if (error.Fail()) return; } diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index 2a248f63f95..e9146b558ef 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -915,7 +915,8 @@ void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) { FileSystem::Instance().Resolve(executable_file); ModuleSpec module_spec(executable_file); Status error; - module = GetTarget().GetSharedModule(module_spec, &error); + module = GetTarget().GetOrCreateModule(module_spec, + true /* notify */, &error); if (!module) { return; } diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index 1c7970564d8..21c9be552cf 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -244,7 +244,8 @@ Status ProcessElfCore::DoLoadCore() { exe_module_spec.GetFileSpec().SetFile( m_nt_file_entries[0].path.GetCString(), FileSpec::Style::native); if (exe_module_spec.GetFileSpec()) { - exe_module_sp = GetTarget().GetSharedModule(exe_module_spec); + exe_module_sp = GetTarget().GetOrCreateModule(exe_module_spec, + true /* notify */); if (exe_module_sp) GetTarget().SetExecutableModule(exe_module_sp, eLoadDependentsNo); } diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp index d6ab58c0f05..3da103b9064 100644 --- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -388,7 +388,8 @@ void ProcessMinidump::ReadModuleList() { Status error; // Try and find a module with a full UUID that matches. This function will // add the module to the target if it finds one. - lldb::ModuleSP module_sp = GetTarget().GetSharedModule(module_spec, &error); + lldb::ModuleSP module_sp = GetTarget().GetOrCreateModule(module_spec, + true /* notify */, &error); if (!module_sp) { // Try and find a module without specifying the UUID and only looking for // the file given a basename. We then will look for a partial UUID match @@ -400,7 +401,8 @@ void ProcessMinidump::ReadModuleList() { ModuleSpec basename_module_spec(module_spec); basename_module_spec.GetUUID().Clear(); basename_module_spec.GetFileSpec().GetDirectory().Clear(); - module_sp = GetTarget().GetSharedModule(basename_module_spec, &error); + module_sp = GetTarget().GetOrCreateModule(basename_module_spec, + true /* notify */, &error); if (module_sp) { // We consider the module to be a match if the minidump UUID is a // prefix of the actual UUID, or if either of the UUIDs are empty. @@ -430,7 +432,7 @@ void ProcessMinidump::ReadModuleList() { module_sp = Module::CreateModuleFromObjectFile<PlaceholderObjectFile>( module_spec, module->base_of_image, module->size_of_image); - GetTarget().GetImages().Append(module_sp); + GetTarget().GetImages().Append(module_sp, true /* notify */); } bool load_addr_changed = false; |

