summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp')
-rw-r--r--lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp58
1 files changed, 30 insertions, 28 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
index a4063e53d41..d5341f19f9f 100644
--- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -1185,18 +1185,18 @@ ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor,
lldb_private::Module *module,
char const **argv,
char const **envp,
- const char *stdin_path,
- const char *stdout_path,
- const char *stderr_path,
- const char *working_dir,
+ const FileSpec &stdin_file_spec,
+ const FileSpec &stdout_file_spec,
+ const FileSpec &stderr_file_spec,
+ const FileSpec &working_dir,
const lldb_private::ProcessLaunchInfo &launch_info)
: OperationArgs(monitor),
m_module(module),
m_argv(argv),
m_envp(envp),
- m_stdin_path(stdin_path),
- m_stdout_path(stdout_path),
- m_stderr_path(stderr_path),
+ m_stdin_file_spec(stdin_file_spec),
+ m_stdout_file_spec(stdout_file_spec),
+ m_stderr_file_spec(stderr_file_spec),
m_working_dir(working_dir),
m_launch_info(launch_info)
{
@@ -1228,10 +1228,10 @@ ProcessMonitor::ProcessMonitor(ProcessPOSIX *process,
Module *module,
const char *argv[],
const char *envp[],
- const char *stdin_path,
- const char *stdout_path,
- const char *stderr_path,
- const char *working_dir,
+ const FileSpec &stdin_file_spec,
+ const FileSpec &stdout_file_spec,
+ const FileSpec &stderr_file_spec,
+ const FileSpec &working_dir,
const lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Error &error)
: m_process(static_cast<ProcessLinux *>(process)),
@@ -1242,8 +1242,11 @@ ProcessMonitor::ProcessMonitor(ProcessPOSIX *process,
m_operation(0)
{
std::unique_ptr<LaunchArgs> args(new LaunchArgs(this, module, argv, envp,
- stdin_path, stdout_path, stderr_path,
- working_dir, launch_info));
+ stdin_file_spec,
+ stdout_file_spec,
+ stderr_file_spec,
+ working_dir,
+ launch_info));
sem_init(&m_operation_pending, 0, 0);
sem_init(&m_operation_done, 0, 0);
@@ -1378,10 +1381,10 @@ ProcessMonitor::Launch(LaunchArgs *args)
ProcessLinux &process = monitor->GetProcess();
const char **argv = args->m_argv;
const char **envp = args->m_envp;
- const char *stdin_path = args->m_stdin_path;
- const char *stdout_path = args->m_stdout_path;
- const char *stderr_path = args->m_stderr_path;
- const char *working_dir = args->m_working_dir;
+ const FileSpec &stdin_file_spec = args->m_stdin_file_spec;
+ const FileSpec &stdout_file_spec = args->m_stdout_file_spec;
+ const FileSpec &stderr_file_spec = args->m_stderr_file_spec;
+ const FileSpec &working_dir = args->m_working_dir;
lldb_utility::PseudoTerminal terminal;
const size_t err_len = 1024;
@@ -1436,22 +1439,21 @@ ProcessMonitor::Launch(LaunchArgs *args)
//
// FIXME: If two or more of the paths are the same we needlessly open
// the same file multiple times.
- if (stdin_path != NULL && stdin_path[0])
- if (!DupDescriptor(stdin_path, STDIN_FILENO, O_RDONLY))
+ if (stdin_file_spec)
+ if (!DupDescriptor(stdin_file_spec, STDIN_FILENO, O_RDONLY))
exit(eDupStdinFailed);
- if (stdout_path != NULL && stdout_path[0])
- if (!DupDescriptor(stdout_path, STDOUT_FILENO, O_WRONLY | O_CREAT))
+ if (stdout_file_spec)
+ if (!DupDescriptor(stdout_file_spec, STDOUT_FILENO, O_WRONLY | O_CREAT))
exit(eDupStdoutFailed);
- if (stderr_path != NULL && stderr_path[0])
- if (!DupDescriptor(stderr_path, STDERR_FILENO, O_WRONLY | O_CREAT))
+ if (stderr_file_spec)
+ if (!DupDescriptor(stderr_file_spec, STDERR_FILENO, O_WRONLY | O_CREAT))
exit(eDupStderrFailed);
// Change working directory
- if (working_dir != NULL && working_dir[0])
- if (0 != ::chdir(working_dir))
- exit(eChdirFailed);
+ if (working_dir && 0 != ::chdir(working_dir.GetCString()))
+ exit(eChdirFailed);
// Disable ASLR if requested.
if (args->m_launch_info.GetFlags ().Test (lldb::eLaunchFlagDisableASLR))
@@ -2402,9 +2404,9 @@ ProcessMonitor::Detach(lldb::tid_t tid)
}
bool
-ProcessMonitor::DupDescriptor(const char *path, int fd, int flags)
+ProcessMonitor::DupDescriptor(const FileSpec &file_spec, int fd, int flags)
{
- int target_fd = open(path, flags, 0666);
+ int target_fd = open(file_spec.GetCString(), flags, 0666);
if (target_fd == -1)
return false;
OpenPOWER on IntegriCloud