diff options
author | Zachary Turner <zturner@google.com> | 2014-10-14 21:55:08 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2014-10-14 21:55:08 +0000 |
commit | 172d37d3b92ca70e65f11f9a7caf7af4c8a5e44f (patch) | |
tree | 0df4532b38c6277c18c69659225f56a8188c6092 /lldb/source/Host/posix/ProcessLauncherPosix.cpp | |
parent | 756acbaa0e76c17426983863099d42449b0a6729 (diff) | |
download | bcm5719-llvm-172d37d3b92ca70e65f11f9a7caf7af4c8a5e44f.tar.gz bcm5719-llvm-172d37d3b92ca70e65f11f9a7caf7af4c8a5e44f.zip |
Create a process launcher abstraction.
This implements Host::LaunchProcess for windows, and in doing so
does some minor refactor to move towards a more modular process
launching design.
The original motivation for this is that launching processes on
windows needs some very windows specific code, which would live
most appropriately in source/Host/windows somewhere. However,
there is already some common code that all platforms use when
launching a process before delegating to the platform specific
stuff, which lives in source/Host/common/Host.cpp which would
be nice to reuse without duplicating.
This commonality has been abstracted into MonitoringProcessLauncher,
a class which abstracts out the notion of launching a process using
an arbitrary algorithm, and then monitoring it for state changes.
The windows specific launching code lives in ProcessLauncherWindows,
and the posix specific launching code lives in ProcessLauncherPosix.
When launching a process MonitoringProcessLauncher is created, and
then an appropriate delegate launcher is created and given to the
MonitoringProcessLauncher.
Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5781
llvm-svn: 219731
Diffstat (limited to 'lldb/source/Host/posix/ProcessLauncherPosix.cpp')
-rw-r--r-- | lldb/source/Host/posix/ProcessLauncherPosix.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lldb/source/Host/posix/ProcessLauncherPosix.cpp b/lldb/source/Host/posix/ProcessLauncherPosix.cpp new file mode 100644 index 00000000000..dd5c5121a97 --- /dev/null +++ b/lldb/source/Host/posix/ProcessLauncherPosix.cpp @@ -0,0 +1,33 @@ +//===-- ProcessLauncherPosix.cpp --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Host/Host.h" +#include "lldb/Host/HostProcess.h" +#include "lldb/Host/posix/ProcessLauncherPosix.h" + +#include "lldb/Target/ProcessLaunchInfo.h" + +#include <limits.h> + +using namespace lldb; +using namespace lldb_private; + +HostProcess +ProcessLauncherPosix::LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error) +{ + lldb::pid_t pid; + char exe_path[PATH_MAX]; + + launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path)); + + // TODO(zturner): Move the code from LaunchProcessPosixSpawn to here, and make MacOSX re-use this + // ProcessLauncher when it wants a posix_spawn launch. + error = Host::LaunchProcessPosixSpawn(exe_path, launch_info, pid); + return HostProcess(pid); +} |