diff options
author | Pavel Labath <pavel@labath.sk> | 2023-03-27 17:39:55 +0200 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2023-03-30 12:48:36 +0200 |
commit | e64cc756819d567f453467bf7cc16599ad296fdd (patch) | |
tree | ddfe6ab160305b480a903405528675b34681a6b3 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | |
parent | 44f0c9145c947d660b416bdad61874fd9d73bbae (diff) | |
download | llvm-e64cc756819d567f453467bf7cc16599ad296fdd.zip llvm-e64cc756819d567f453467bf7cc16599ad296fdd.tar.gz llvm-e64cc756819d567f453467bf7cc16599ad296fdd.tar.bz2 |
[lldb-server/linux] Use waitpid(-1) to collect inferior events
This is a follow-up to D116372, which had a rather unfortunate side
effect of making the processing of a single SIGCHLD quadratic in the
number of threads -- which does not matter for simple applications, but
can get really bad for applications with thousands of threads.
This patch fixes the problem by implementing the other possibility
mentioned in the first patch -- doing waitpid(-1) centrally and then
routing the events to the correct process instance. The "uncollected"
threads are held in the process factory class -- which I've renamed to
Manager for this purpose, as it now does more than creating processes.
Differential Revision: https://reviews.llvm.org/D146977
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index c9e57ca..026861bd 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -69,9 +69,9 @@ enum GDBRemoteServerError { // GDBRemoteCommunicationServerLLGS constructor GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS( - MainLoop &mainloop, const NativeProcessProtocol::Factory &process_factory) + MainLoop &mainloop, NativeProcessProtocol::Manager &process_manager) : GDBRemoteCommunicationServerCommon(), m_mainloop(mainloop), - m_process_factory(process_factory), m_current_process(nullptr), + m_process_manager(process_manager), m_current_process(nullptr), m_continue_process(nullptr), m_stdio_communication() { RegisterPacketHandlers(); } @@ -286,8 +286,7 @@ Status GDBRemoteCommunicationServerLLGS::LaunchProcess() { std::lock_guard<std::recursive_mutex> guard(m_debugged_process_mutex); assert(m_debugged_processes.empty() && "lldb-server creating debugged " "process but one already exists"); - auto process_or = - m_process_factory.Launch(m_process_launch_info, *this, m_mainloop); + auto process_or = m_process_manager.Launch(m_process_launch_info, *this); if (!process_or) return Status(process_or.takeError()); m_continue_process = m_current_process = process_or->get(); @@ -356,7 +355,7 @@ Status GDBRemoteCommunicationServerLLGS::AttachToProcess(lldb::pid_t pid) { pid, m_current_process->GetID()); // Try to attach. - auto process_or = m_process_factory.Attach(pid, *this, m_mainloop); + auto process_or = m_process_manager.Attach(pid, *this); if (!process_or) { Status status(process_or.takeError()); llvm::errs() << llvm::formatv("failed to attach to process {0}: {1}\n", pid, @@ -4209,7 +4208,7 @@ std::vector<std::string> GDBRemoteCommunicationServerLLGS::HandleFeatures( // report server-only features using Extension = NativeProcessProtocol::Extension; - Extension plugin_features = m_process_factory.GetSupportedExtensions(); + Extension plugin_features = m_process_manager.GetSupportedExtensions(); if (bool(plugin_features & Extension::pass_signals)) ret.push_back("QPassSignals+"); if (bool(plugin_features & Extension::auxv)) @@ -4255,7 +4254,7 @@ std::vector<std::string> GDBRemoteCommunicationServerLLGS::HandleFeatures( void GDBRemoteCommunicationServerLLGS::SetEnabledExtensions( NativeProcessProtocol &process) { NativeProcessProtocol::Extension flags = m_extensions_supported; - assert(!bool(flags & ~m_process_factory.GetSupportedExtensions())); + assert(!bool(flags & ~m_process_manager.GetSupportedExtensions())); process.SetEnabledExtensions(flags); } |