diff options
author | Jim Ingham <jingham@apple.com> | 2012-05-30 02:19:25 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2012-05-30 02:19:25 +0000 |
commit | 3ee12ef26ed534af3d0c85f88df7b06db037bfe3 (patch) | |
tree | 9d46961f3981c27e927926a4ea7d5a2c2b0b6ba7 /lldb/source/Plugins/LanguageRuntime/ObjC | |
parent | 13586ab6d8a1c9f373315a70c384f67089c2371e (diff) | |
download | bcm5719-llvm-3ee12ef26ed534af3d0c85f88df7b06db037bfe3.tar.gz bcm5719-llvm-3ee12ef26ed534af3d0c85f88df7b06db037bfe3.zip |
We were accessing the ModuleList in the target without locking it for tasks like
setting breakpoints. That's dangerous, since while we are setting a breakpoint,
the target might hit the dyld load notification, and start removing modules from
the list. This change adds a GetMutex accessor to the ModuleList class, and
uses it whenever we are accessing the target's ModuleList (as returned by GetImages().)
<rdar://problem/11552372>
llvm-svn: 157668
Diffstat (limited to 'lldb/source/Plugins/LanguageRuntime/ObjC')
3 files changed, 14 insertions, 10 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 1cb7ab8eef9..a2bc88872c1 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -263,11 +263,13 @@ AppleObjCRuntime::GetObjCVersion (Process *process, ModuleSP &objc_module_sp) return eObjC_VersionUnknown; Target &target = process->GetTarget(); - ModuleList &images = target.GetImages(); - size_t num_images = images.GetSize(); + ModuleList &target_modules = target.GetImages(); + Mutex::Locker modules_locker(target_modules.GetMutex()); + + size_t num_images = target_modules.GetSize(); for (size_t i = 0; i < num_images; i++) { - ModuleSP module_sp = images.GetModuleAtIndex(i); + ModuleSP module_sp = target_modules.GetModuleAtIndexUnlocked(i); // One tricky bit here is that we might get called as part of the initial module loading, but // before all the pre-run libraries get winnowed from the module list. So there might actually // be an old and incorrect ObjC library sitting around in the list, and we don't want to look at that. diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp index ff135806f28..00c90c6eacd 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp @@ -43,13 +43,14 @@ AppleObjCSymbolVendor::FindTypes (const SymbolContext& sc, uint32_t ret = 0; - ModuleList &images = m_process->GetTarget().GetImages(); + ModuleList &target_modules = m_process->GetTarget().GetImages(); + Mutex::Locker modules_locker(target_modules.GetMutex()); - for (size_t image_index = 0, end_index = images.GetSize(); + for (size_t image_index = 0, end_index = target_modules.GetSize(); image_index < end_index; ++image_index) { - Module *image = images.GetModulePointerAtIndex(image_index); + Module *image = target_modules.GetModulePointerAtIndexUnlocked(image_index); if (!image) continue; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index f8cab06732d..54eda8bddf5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -334,15 +334,16 @@ AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols () return true; Target &target = m_process_sp->GetTarget(); - ModuleList &modules = target.GetImages(); - size_t num_modules = modules.GetSize(); + ModuleList &target_modules = target.GetImages(); + Mutex::Locker modules_locker(target_modules.GetMutex()); + size_t num_modules = target_modules.GetSize(); if (!m_objc_module_sp) { for (size_t i = 0; i < num_modules; i++) { - if (m_process_sp->GetObjCLanguageRuntime()->IsModuleObjCLibrary (modules.GetModuleAtIndex(i))) + if (m_process_sp->GetObjCLanguageRuntime()->IsModuleObjCLibrary (target_modules.GetModuleAtIndexUnlocked(i))) { - m_objc_module_sp = modules.GetModuleAtIndex(i); + m_objc_module_sp = target_modules.GetModuleAtIndexUnlocked(i); break; } } |