emrekultursay created this revision. emrekultursay requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
When rebase_exec=true in DidAttach(), all modules are loaded before the rendezvous breakpoint is set, which means the LoadInterpreterModule() method is not called and m_interpreter_module is not initialized. This causes the very first rendezvous breakpoint hit (with m_initial_modules_added=false) to accidentally unload the module_sp that corresponds to the dynamic loader. This bug was causing the rendezvous mechanism to not work in Android 28, which this CL fixes. Test: Verified rendezvous on Android 28 and 29 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D109797 Files: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -442,14 +442,18 @@ if (module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress( &m_process->GetTarget()) == m_interpreter_base && module_sp != m_interpreter_module.lock()) { - // If this is a duplicate instance of ld.so, unload it. We may end up - // with it if we load it via a different path than before (symlink - // vs real path). - // TODO: remove this once we either fix library matching or avoid - // loading the interpreter when setting the rendezvous breakpoint. - UnloadSections(module_sp); - loaded_modules.Remove(module_sp); - continue; + if (m_interpreter_module.lock() == nullptr) { + m_interpreter_module = module_sp; + } else { + // If this is a duplicate instance of ld.so, unload it. We may end up + // with it if we load it via a different path than before (symlink + // vs real path). + // TODO: remove this once we either fix library matching or avoid + // loading the interpreter when setting the rendezvous breakpoint. + UnloadSections(module_sp); + loaded_modules.Remove(module_sp); + continue; + } } loaded_modules.AppendIfNeeded(module_sp);
Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -442,14 +442,18 @@ if (module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress( &m_process->GetTarget()) == m_interpreter_base && module_sp != m_interpreter_module.lock()) { - // If this is a duplicate instance of ld.so, unload it. We may end up - // with it if we load it via a different path than before (symlink - // vs real path). - // TODO: remove this once we either fix library matching or avoid - // loading the interpreter when setting the rendezvous breakpoint. - UnloadSections(module_sp); - loaded_modules.Remove(module_sp); - continue; + if (m_interpreter_module.lock() == nullptr) { + m_interpreter_module = module_sp; + } else { + // If this is a duplicate instance of ld.so, unload it. We may end up + // with it if we load it via a different path than before (symlink + // vs real path). + // TODO: remove this once we either fix library matching or avoid + // loading the interpreter when setting the rendezvous breakpoint. + UnloadSections(module_sp); + loaded_modules.Remove(module_sp); + continue; + } } loaded_modules.AppendIfNeeded(module_sp);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits