diff options
Diffstat (limited to 'lldb/source/Plugins/Process')
6 files changed, 95 insertions, 18 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp index ecf8479ddde..fa5b5b70ec3 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp @@ -122,7 +122,8 @@ ProcessLinux::DoLaunch(Module *module, uint32_t launch_flags, const char *stdin_path, const char *stdout_path, - const char *stderr_path) + const char *stderr_path, + const char *working_directory) { Error error; assert(m_monitor == NULL); diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.h b/lldb/source/Plugins/Process/Linux/ProcessLinux.h index fbf14df1988..6fe05526647 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessLinux.h +++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.h @@ -72,7 +72,8 @@ public: uint32_t launch_flags, const char *stdin_path, const char *stdout_path, - const char *stderr_path); + const char *stderr_path, + const char *working_directory); virtual void DidLaunch(); diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp index c650f5bb622..9aebc8fdec6 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp @@ -316,7 +316,8 @@ ProcessMacOSX::DoLaunch uint32_t flags, const char *stdin_path, const char *stdout_path, - const char *stderr_path + const char *stderr_path, + const char *working_dir ) { // ::LogSetBitMask (PD_LOG_DEFAULT); diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h index 4f8bdb930b7..c3df2f3a2dc 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h @@ -95,8 +95,9 @@ public: char const *envp[], // Can be NULL uint32_t launch_flags, const char *stdin_path, // Can be NULL - const char *stdout_path, // Can be NULL - const char *stderr_path); // Can be NULL + const char *stdout_path, // Can be NULL + const char *stderr_path, // Can be NULL + const char *working_dir); // Can be NULL virtual void DidLaunch (); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index fe4e06820fc..ffec00e6d6f 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -375,7 +375,8 @@ ProcessGDBRemote::DoLaunch uint32_t launch_flags, const char *stdin_path, const char *stdout_path, - const char *stderr_path + const char *stderr_path, + const char *working_dir ) { Error error; @@ -400,7 +401,10 @@ ProcessGDBRemote::DoLaunch error = StartDebugserverProcess (host_port, argv, envp, - NULL, //stdin_path, + stdin_path, + stdout_path, + stderr_path, + working_dir, launch_process, LLDB_INVALID_PROCESS_ID, NULL, false, @@ -420,10 +424,14 @@ ProcessGDBRemote::DoLaunch error = StartDebugserverProcess (host_port, NULL, NULL, - NULL, //stdin_path + stdin_path, + stdout_path, + stderr_path, + working_dir, launch_process, LLDB_INVALID_PROCESS_ID, - NULL, false, + NULL, + false, launch_flags, inferior_arch); if (error.Fail()) @@ -644,6 +652,9 @@ ProcessGDBRemote::DoAttachToProcessWithID (lldb::pid_t attach_pid) NULL, // inferior_argv NULL, // inferior_envp NULL, // stdin_path + NULL, // stdout_path + NULL, // stderr_path + NULL, // working_dir false, // launch_process == false (we are attaching) LLDB_INVALID_PROCESS_ID, // Don't send any attach to pid options to debugserver NULL, // Don't send any attach by process name option to debugserver @@ -746,6 +757,9 @@ ProcessGDBRemote::DoAttachToProcessWithName (const char *process_name, bool wait NULL, // inferior_argv NULL, // inferior_envp NULL, // stdin_path + NULL, // stdout_path + NULL, // stderr_path + NULL, // working_dir false, // launch_process == false (we are attaching) LLDB_INVALID_PROCESS_ID, // Don't send any attach to pid options to debugserver NULL, // Don't send any attach by process name option to debugserver @@ -1732,7 +1746,10 @@ ProcessGDBRemote::StartDebugserverProcess const char *debugserver_url, // The connection string to use in the spawned debugserver ("localhost:1234" or "/dev/tty...") char const *inferior_argv[], // Arguments for the inferior program including the path to the inferior itself as the first argument char const *inferior_envp[], // Environment to pass along to the inferior program - char const *stdio_path, + const char *stdin_path, + const char *stdout_path, + const char *stderr_path, + const char *working_dir, bool launch_process, // Set to true if we are going to be launching a the process lldb::pid_t attach_pid, // If inferior inferior_argv == NULL, and attach_pid != LLDB_INVALID_PROCESS_ID send this pid as an argument to debugserver const char *attach_name, // Wait for the next process to launch whose basename matches "attach_name" @@ -1824,7 +1841,13 @@ ProcessGDBRemote::StartDebugserverProcess char arg_cstr[PATH_MAX]; lldb_utility::PseudoTerminal pty; - if (launch_process && stdio_path == NULL && m_local_debugserver && !no_stdio) + const char *stdio_path = NULL; + if (launch_process && + stdin_path == NULL && + stdout_path == NULL && + stderr_path == NULL && + m_local_debugserver && + no_stdio == false) { if (pty.OpenFirstAvailableMaster(O_RDWR|O_NOCTTY, NULL, 0)) stdio_path = pty.GetSlaveName (NULL, 0); @@ -1843,14 +1866,60 @@ ProcessGDBRemote::StartDebugserverProcess debugserver_args.AppendArguments("--disable-aslr"); // Only set the inferior - if (launch_process && stdio_path) + if (launch_process) { - debugserver_args.AppendArgument("--stdio-path"); - debugserver_args.AppendArgument(stdio_path); + if (no_stdio) + debugserver_args.AppendArgument("--no-stdio"); + else + { + if (stdin_path && stdout_path && stderr_path && + strcmp(stdin_path, stdout_path) == 0 && + strcmp(stdin_path, stderr_path) == 0) + { + stdio_path = stdin_path; + stdin_path = stdout_path = stderr_path = NULL; + } + + if (stdio_path) + { + // All file handles to stdin, stdout, stderr are the same... + debugserver_args.AppendArgument("--stdio-path"); + debugserver_args.AppendArgument(stdio_path); + } + else + { + if (stdin_path == NULL && (stdout_path || stderr_path)) + stdin_path = "/dev/null"; + + if (stdout_path == NULL && (stdin_path || stderr_path)) + stdout_path = "/dev/null"; + + if (stderr_path == NULL && (stdin_path || stdout_path)) + stderr_path = "/dev/null"; + + if (stdin_path) + { + debugserver_args.AppendArgument("--stdin-path"); + debugserver_args.AppendArgument(stdin_path); + } + if (stdout_path) + { + debugserver_args.AppendArgument("--stdout-path"); + debugserver_args.AppendArgument(stdout_path); + } + if (stderr_path) + { + debugserver_args.AppendArgument("--stderr-path"); + debugserver_args.AppendArgument(stderr_path); + } + } + } } - else if (launch_process && no_stdio) + + if (working_dir) { - debugserver_args.AppendArgument("--no-stdio"); + debugserver_args.AppendArgument("--working-dir"); + debugserver_args.AppendArgument(working_dir); } const char *env_debugserver_log_file = getenv("LLDB_DEBUGSERVER_LOG_FILE"); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index d8a2cebbd33..8c8f1a8a9af 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -82,8 +82,9 @@ public: char const *envp[], // Can be NULL uint32_t flags, const char *stdin_path, // Can be NULL - const char *stdout_path, // Can be NULL - const char *stderr_path); // Can be NULL + const char *stdout_path, // Can be NULL + const char *stderr_path, // Can be NULL + const char *working_dir); // Can be NULL virtual void DidLaunch (); @@ -295,6 +296,9 @@ protected: char const *inferior_argv[], char const *inferior_envp[], const char *stdin_path, + const char *stdout_path, + const char *stderr_path, + const char *working_dir, bool launch_process, // Set to true if we are going to be launching a the process lldb::pid_t attach_pid, // If inferior inferior_argv == NULL, then attach to this pid const char *attach_pid_name, // Wait for the next process to launch whose basename matches "attach_wait_name" |