From cb8c699802f39aee10c27d4d73de5e14c7dfd09c Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 7 Jan 2019 10:59:57 +0000 Subject: [PATCH] ProcessLaunchInfo: remove Debugger reference Summary: The Debuffer object was being used in "GetListenerForProcess" to provide a default listener object if one was not specified in the launch_info object. Since all the callers of this function immediately passed the result to Target::CreateProcess, it was easy to move this logic there instead. This brings us one step closer towards being able to move the LaunchInfo classes to the Host layer (which is there the launching code that consumes them lives). Reviewers: zturner, jingham, teemperor Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D56174 llvm-svn: 350510 --- lldb/include/lldb/Target/ProcessLaunchInfo.h | 2 -- lldb/include/lldb/Target/Target.h | 4 +++- lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp | 4 ++-- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp | 4 ++-- lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp | 5 ++--- .../Platform/gdb-server/PlatformRemoteGDBServer.cpp | 4 ++-- lldb/source/Target/ProcessLaunchInfo.cpp | 8 -------- lldb/source/Target/Target.cpp | 5 +++-- 8 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lldb/include/lldb/Target/ProcessLaunchInfo.h b/lldb/include/lldb/Target/ProcessLaunchInfo.h index 92c517a3e4609..fbd319abc4f3e 100644 --- a/lldb/include/lldb/Target/ProcessLaunchInfo.h +++ b/lldb/include/lldb/Target/ProcessLaunchInfo.h @@ -131,8 +131,6 @@ class ProcessLaunchInfo : public ProcessInfo { m_listener_sp = listener_sp; } - lldb::ListenerSP GetListenerForProcess(Debugger &debugger); - lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; } void SetHijackListener(const lldb::ListenerSP &listener_sp) { diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index b2c0eb5ccd871..801ffb31c0d47 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -533,7 +533,9 @@ class Target : public std::enable_shared_from_this, //------------------------------------------------------------------ void Dump(Stream *s, lldb::DescriptionLevel description_level); - const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener, + // If listener_sp is null, the listener of the owning Debugger object will be + // used. + const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file); diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 3ce4b208498b3..7498c648d6e4f 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -318,8 +318,8 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, // Now create the gdb-remote process. LLDB_LOG(log, "having target create process with gdb-remote plugin"); - process_sp = target->CreateProcess( - launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr); + process_sp = + target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr); if (!process_sp) { error.SetErrorString("CreateProcess() failed for gdb-remote process"); diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp index eea0887e9c8b0..aadcf961c729a 100644 --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -287,8 +287,8 @@ PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, // Now create the gdb-remote process. LLDB_LOG(log, "having target create process with gdb-remote plugin"); - process_sp = target->CreateProcess( - launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr); + process_sp = + target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr); if (!process_sp) { error.SetErrorString("CreateProcess() failed for gdb-remote process"); diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp index 9d49486d48877..685d49a73a777 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -437,9 +437,8 @@ ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info, ProcessAttachInfo attach_info(launch_info); return Attach(attach_info, debugger, target, error); } else { - ProcessSP process_sp = - target->CreateProcess(launch_info.GetListenerForProcess(debugger), - launch_info.GetProcessPluginName(), nullptr); + ProcessSP process_sp = target->CreateProcess( + launch_info.GetListener(), launch_info.GetProcessPluginName(), nullptr); // We need to launch and attach to the process. launch_info.GetFlags().Set(eLaunchFlagDebug); diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 7187b94a69a7c..f6ace706ca3f0 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -496,8 +496,8 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess( // The darwin always currently uses the GDB remote debugger plug-in // so even when debugging locally we are debugging remotely! - process_sp = target->CreateProcess( - launch_info.GetListenerForProcess(debugger), "gdb-remote", NULL); + process_sp = target->CreateProcess(launch_info.GetListener(), + "gdb-remote", NULL); if (process_sp) { error = process_sp->ConnectRemote(nullptr, connect_url.c_str()); diff --git a/lldb/source/Target/ProcessLaunchInfo.cpp b/lldb/source/Target/ProcessLaunchInfo.cpp index a5947b3c8ea27..a7a5a5c39ddee 100644 --- a/lldb/source/Target/ProcessLaunchInfo.cpp +++ b/lldb/source/Target/ProcessLaunchInfo.cpp @@ -9,7 +9,6 @@ #include -#include "lldb/Core/Debugger.h" #include "lldb/Host/Config.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" @@ -433,10 +432,3 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell( } return false; } - -ListenerSP ProcessLaunchInfo::GetListenerForProcess(Debugger &debugger) { - if (m_listener_sp) - return m_listener_sp; - else - return debugger.GetListener(); -} diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 549b72e0cad1e..84890e0b5cfba 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -194,6 +194,8 @@ void Target::DeleteCurrentProcess() { const lldb::ProcessSP &Target::CreateProcess(ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file) { + if (!listener_sp) + listener_sp = GetDebugger().GetListener(); DeleteCurrentProcess(); m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name, listener_sp, crash_file); @@ -2884,8 +2886,7 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) { } else { // Use a Process plugin to construct the process. const char *plugin_name = launch_info.GetProcessPluginName(); - CreateProcess(launch_info.GetListenerForProcess(debugger), plugin_name, - nullptr); + CreateProcess(launch_info.GetListener(), plugin_name, nullptr); } // Since we didn't have a platform launch the process, launch it here.