diff options
author | Greg Clayton <gclayton@apple.com> | 2011-01-23 05:56:20 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-01-23 05:56:20 +0000 |
commit | bd82a5d2cc9451c15f66d5dc8475fc6e01c19332 (patch) | |
tree | b9305f6381fdf6f2d990f8e95c34d58832cc69a3 /lldb/tools/debugserver/source/debugserver.cpp | |
parent | 4b7b7fba38e029234bbf6260980fb998c705d56a (diff) | |
download | bcm5719-llvm-bd82a5d2cc9451c15f66d5dc8475fc6e01c19332.tar.gz bcm5719-llvm-bd82a5d2cc9451c15f66d5dc8475fc6e01c19332.zip |
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
Diffstat (limited to 'lldb/tools/debugserver/source/debugserver.cpp')
-rw-r--r-- | lldb/tools/debugserver/source/debugserver.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index 49f1f0c9f10..f3a4b69c5e6 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -651,14 +651,14 @@ static struct option g_long_options[] = { "waitfor-interval", required_argument, NULL, 'i' }, // Time in usecs to wait between sampling the pid list when waiting for a process by name { "waitfor-duration", required_argument, NULL, 'd' }, // The time in seconds to wait for a process to show up by name { "native-regs", no_argument, NULL, 'r' }, // Specify to use the native registers instead of the gdb defaults for the architecture. - { "stdio-path", required_argument, NULL, 's' }, // Set the STDIO path to be used when launching applications (STDIN, STDOUT and STDERR) - { "stdin-path", required_argument, NULL, 'I' }, // Set the STDIN path to be used when launching applications - { "stdout-path", required_argument, NULL, 'O' }, // Set the STDIN path to be used when launching applications - { "stderr-path", required_argument, NULL, 'E' }, // Set the STDIN path to be used when launching applications - { "no-stdio", no_argument, NULL, 'n' }, // Do not set up any stdio (perhaps the program is a GUI program) - { "setsid", no_argument, NULL, 'S' }, // call setsid() to make debugserver run in its own sessions + { "stdio-path", required_argument, NULL, 's' }, // Set the STDIO path to be used when launching applications (STDIN, STDOUT and STDERR) (only if debugserver launches the process) + { "stdin-path", required_argument, NULL, 'I' }, // Set the STDIN path to be used when launching applications (only if debugserver launches the process) + { "stdout-path", required_argument, NULL, 'O' }, // Set the STDIN path to be used when launching applications (only if debugserver launches the process) + { "stderr-path", required_argument, NULL, 'E' }, // Set the STDIN path to be used when launching applications (only if debugserver launches the process) + { "no-stdio", no_argument, NULL, 'n' }, // Do not set up any stdio (perhaps the program is a GUI program) (only if debugserver launches the process) + { "setsid", no_argument, NULL, 'S' }, // call setsid() to make debugserver run in its own session { "disable-aslr", no_argument, NULL, 'D' }, // Use _POSIX_SPAWN_DISABLE_ASLR to avoid shared library randomization - { "chdir", no_argument, NULL, 'c' }, // Use _POSIX_SPAWN_DISABLE_ASLR to avoid shared library randomization + { "working-dir", required_argument, NULL, 'W' }, // The working directory that the inferior process should have (only if debugserver launches the process) { NULL, 0, NULL, 0 } }; @@ -699,7 +699,7 @@ main (int argc, char *argv[]) std::string stdout_path; std::string stderr_path; std::string arch_name; - std::string working_directory; // The new working directory to use for the inferior + std::string working_dir; // The new working directory to use for the inferior useconds_t waitfor_interval = 1000; // Time in usecs between process lists polls when waiting for a process by name, default 1 msec. useconds_t waitfor_duration = 0; // Time in seconds to wait for a process by name, 0 means wait forever. bool no_stdio = false; @@ -785,9 +785,9 @@ main (int argc, char *argv[]) } break; - case 'c': + case 'W': if (optarg && optarg[0]) - working_directory.assign(optarg); + working_dir.assign(optarg); break; case 'x': @@ -826,7 +826,7 @@ main (int argc, char *argv[]) else if (strcasecmp(optarg, "stderr") == 0) log_file = stderr; else - log_file = fopen(optarg, "w+"); + log_file = fopen(optarg, "w"); if (log_file == NULL) { @@ -938,11 +938,11 @@ main (int argc, char *argv[]) return -1; } - if (!working_directory.empty()) + if (!working_dir.empty()) { - if (remote->Context().SetWorkingDirectory (working_directory.c_str()) == false) + if (remote->Context().SetWorkingDirectory (working_dir.c_str()) == false) { - RNBLogSTDERR ("error: working directory doesn't exist '%s'.\n", working_directory.c_str()); + RNBLogSTDERR ("error: working directory doesn't exist '%s'.\n", working_dir.c_str()); exit (8); } } |