From bd82a5d2cc9451c15f66d5dc8475fc6e01c19332 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Sun, 23 Jan 2011 05:56:20 +0000 Subject: Added a new variant of SBTarget::Launch() that deprectates the old one that takes separate file handles for stdin, stdout, and stder and also allows for the working directory to be specified. Added support to "process launch" to a new option: --working-dir=PATH. We can now set the working directory. If this is not set, it defaults to that of the process that has LLDB loaded. Added the working directory to the host LaunchInNewTerminal function to allows the current working directory to be set in processes that are spawned in their own terminal. Also hooked this up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its API changed, but nothing is making use of it yet. Modfied "debugserver" and "darwin-debug" to also handle the current working directory options and modified the code in LLDB that spawns these tools to pass the info along. Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout and stderr. After clearing the default values for the stdin/out/err file handles for process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable which is now fixed. Also fixed the setting of boolean values to be able to be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no", "off", or "0" for false. Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not already opened. Previous to this fix debugserver would only correctly open and dupe file handles for the slave side of a pseudo terminal. It now correctly handles getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to files. Also made sure the file handles were correctly opened with the NOCTTY flag for terminals. llvm-svn: 124060 --- lldb/source/Commands/CommandObjectProcess.cpp | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'lldb/source/Commands/CommandObjectProcess.cpp') diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index c07de3ee6aee..5239b7bf2d60 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -57,12 +57,13 @@ public: switch (short_option) { - case 's': stop_at_entry = true; break; - case 'e': stderr_path = option_arg; break; - case 'i': stdin_path = option_arg; break; - case 'o': stdout_path = option_arg; break; - case 'p': plugin_name = option_arg; break; - case 'n': no_stdio = true; break; + case 's': stop_at_entry = true; break; + case 'e': stderr_path.assign (option_arg); break; + case 'i': stdin_path.assign (option_arg); break; + case 'o': stdout_path.assign (option_arg); break; + case 'p': plugin_name.assign (option_arg); break; + case 'n': no_stdio = true; break; + case 'w': working_dir.assign (option_arg); break; case 't': if (option_arg && option_arg[0]) tty_name.assign (option_arg); @@ -87,6 +88,7 @@ public: stdout_path.clear(); stderr_path.clear(); plugin_name.clear(); + working_dir.clear(); no_stdio = false; } @@ -110,6 +112,7 @@ public: std::string stdin_path; std::string stdout_path; std::string plugin_name; + std::string working_dir; }; @@ -249,6 +252,9 @@ public: const char **inferior_envp = environment.GetArgumentCount() ? environment.GetConstArgumentVector() : NULL; Error error; + const char *working_dir = NULL; + if (!m_options.working_dir.empty()) + working_dir = m_options.working_dir.c_str(); if (m_options.in_new_tty) { @@ -256,6 +262,7 @@ public: lldb::pid_t pid = Host::LaunchInNewTerminal (m_options.tty_name.c_str(), inferior_argv, inferior_envp, + working_dir, &exe_module->GetArchitecture(), true, process->GetDisableASLR()); @@ -287,19 +294,13 @@ public: stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str(); } - if (stdin_path == NULL) - stdin_path = "/dev/null"; - if (stdout_path == NULL) - stdout_path = "/dev/null"; - if (stderr_path == NULL) - stderr_path = "/dev/null"; - error = process->Launch (inferior_argv, inferior_envp, launch_flags, stdin_path, stdout_path, - stderr_path); + stderr_path, + working_dir); } if (error.Success()) @@ -363,6 +364,7 @@ CommandObjectProcessLaunch::CommandOptions::g_option_table[] = { SET1 | SET2 | SET3, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, { SET2 , false, "tty", 't', optional_argument, NULL, 0, eArgTypePath, "Start the process in a terminal. If is specified, look for a terminal whose name contains , else start the process in a new terminal."}, { SET3, false, "no-stdio", 'n', no_argument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."}, +{ SET1 | SET2 | SET3, false, "working-dir", 'w', required_argument, NULL, 0, eArgTypePath, "Set the current working directory to when running the inferior."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; -- cgit v1.2.3