Skip to content

Commit cb8c699

Browse files
committedJan 7, 2019
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
1 parent 90c0923 commit cb8c699

File tree

8 files changed

+14
-22
lines changed

8 files changed

+14
-22
lines changed
 

‎lldb/include/lldb/Target/ProcessLaunchInfo.h

-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ class ProcessLaunchInfo : public ProcessInfo {
131131
m_listener_sp = listener_sp;
132132
}
133133

134-
lldb::ListenerSP GetListenerForProcess(Debugger &debugger);
135-
136134
lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
137135

138136
void SetHijackListener(const lldb::ListenerSP &listener_sp) {

‎lldb/include/lldb/Target/Target.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ class Target : public std::enable_shared_from_this<Target>,
533533
//------------------------------------------------------------------
534534
void Dump(Stream *s, lldb::DescriptionLevel description_level);
535535

536-
const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener,
536+
// If listener_sp is null, the listener of the owning Debugger object will be
537+
// used.
538+
const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp,
537539
llvm::StringRef plugin_name,
538540
const FileSpec *crash_file);
539541

‎lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
318318

319319
// Now create the gdb-remote process.
320320
LLDB_LOG(log, "having target create process with gdb-remote plugin");
321-
process_sp = target->CreateProcess(
322-
launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
321+
process_sp =
322+
target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr);
323323

324324
if (!process_sp) {
325325
error.SetErrorString("CreateProcess() failed for gdb-remote process");

‎lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
287287

288288
// Now create the gdb-remote process.
289289
LLDB_LOG(log, "having target create process with gdb-remote plugin");
290-
process_sp = target->CreateProcess(
291-
launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
290+
process_sp =
291+
target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr);
292292

293293
if (!process_sp) {
294294
error.SetErrorString("CreateProcess() failed for gdb-remote process");

‎lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,8 @@ ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info,
437437
ProcessAttachInfo attach_info(launch_info);
438438
return Attach(attach_info, debugger, target, error);
439439
} else {
440-
ProcessSP process_sp =
441-
target->CreateProcess(launch_info.GetListenerForProcess(debugger),
442-
launch_info.GetProcessPluginName(), nullptr);
440+
ProcessSP process_sp = target->CreateProcess(
441+
launch_info.GetListener(), launch_info.GetProcessPluginName(), nullptr);
443442

444443
// We need to launch and attach to the process.
445444
launch_info.GetFlags().Set(eLaunchFlagDebug);

‎lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess(
496496

497497
// The darwin always currently uses the GDB remote debugger plug-in
498498
// so even when debugging locally we are debugging remotely!
499-
process_sp = target->CreateProcess(
500-
launch_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
499+
process_sp = target->CreateProcess(launch_info.GetListener(),
500+
"gdb-remote", NULL);
501501

502502
if (process_sp) {
503503
error = process_sp->ConnectRemote(nullptr, connect_url.c_str());

‎lldb/source/Target/ProcessLaunchInfo.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <climits>
1111

12-
#include "lldb/Core/Debugger.h"
1312
#include "lldb/Host/Config.h"
1413
#include "lldb/Host/FileSystem.h"
1514
#include "lldb/Host/HostInfo.h"
@@ -433,10 +432,3 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(
433432
}
434433
return false;
435434
}
436-
437-
ListenerSP ProcessLaunchInfo::GetListenerForProcess(Debugger &debugger) {
438-
if (m_listener_sp)
439-
return m_listener_sp;
440-
else
441-
return debugger.GetListener();
442-
}

‎lldb/source/Target/Target.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ void Target::DeleteCurrentProcess() {
194194
const lldb::ProcessSP &Target::CreateProcess(ListenerSP listener_sp,
195195
llvm::StringRef plugin_name,
196196
const FileSpec *crash_file) {
197+
if (!listener_sp)
198+
listener_sp = GetDebugger().GetListener();
197199
DeleteCurrentProcess();
198200
m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name,
199201
listener_sp, crash_file);
@@ -2884,8 +2886,7 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
28842886
} else {
28852887
// Use a Process plugin to construct the process.
28862888
const char *plugin_name = launch_info.GetProcessPluginName();
2887-
CreateProcess(launch_info.GetListenerForProcess(debugger), plugin_name,
2888-
nullptr);
2889+
CreateProcess(launch_info.GetListener(), plugin_name, nullptr);
28892890
}
28902891

28912892
// Since we didn't have a platform launch the process, launch it here.

0 commit comments

Comments
 (0)
Please sign in to comment.