diff options
author | Vince Harron <vharron@google.com> | 2015-02-10 21:09:04 +0000 |
---|---|---|
committer | Vince Harron <vharron@google.com> | 2015-02-10 21:09:04 +0000 |
commit | df3f00f30a83ba0e526ad13097dd4f841f6045a6 (patch) | |
tree | 2df9dea155ccb0d88a601587dfe7037e10b1b344 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | c008539736dea40fc1982a6d6cdd4c8c81129222 (diff) | |
download | bcm5719-llvm-df3f00f30a83ba0e526ad13097dd4f841f6045a6.tar.gz bcm5719-llvm-df3f00f30a83ba0e526ad13097dd4f841f6045a6.zip |
Fix 'process launch -i' for remote processes
We want to forward stdin when stdio is not disabled and when we're not
redirecting stdin from a file.
renamed m_stdio_disable to m_stdin_forward and inverted value because
that's what we want to remember.
There was previously a bug that if you redirected stdin from a file,
stdout and stderr would also be redirected to /dev/null
Adds support for remote target to TestProcessIO.py
Fixes ProcessIOTestCase.test_stdin_redirection_with_dwarf for remote
Linux targets
llvm-svn: 228744
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index cb0b4bb5100..1a0c9ecc854 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -793,6 +793,18 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) log->Printf ("ProcessGDBRemote::%s no STDIO paths given via launch_info", __FUNCTION__); } + const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0; + if (stdin_path || disable_stdio) + { + // the inferior will be reading stdin from the specified file + // or stdio is completely disabled + m_stdin_forward = false; + } + else + { + m_stdin_forward = true; + } + // ::LogSetBitMask (GDBR_LOG_DEFAULT); // ::LogSetOptions (LLDB_LOG_OPTION_THREADSAFE | LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD); // ::LogSetLogFile ("/dev/stdout"); @@ -811,13 +823,23 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) lldb_utility::PseudoTerminal pty; const bool disable_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0; - // If the debugserver is local and we aren't disabling STDIO, lets use - // a pseudo terminal to instead of relying on the 'O' packets for stdio - // since 'O' packets can really slow down debugging if the inferior - // does a lot of output. PlatformSP platform_sp (m_target.GetPlatform()); - if (platform_sp && platform_sp->IsHost() && !disable_stdio) + if (disable_stdio) { + // set to /dev/null unless redirected to a file above + if (!stdin_path) + stdin_path = "/dev/null"; + if (!stdout_path) + stdout_path = "/dev/null"; + if (!stderr_path) + stderr_path = "/dev/null"; + } + else if (platform_sp && platform_sp->IsHost()) + { + // If the debugserver is local and we aren't disabling STDIO, lets use + // a pseudo terminal to instead of relying on the 'O' packets for stdio + // since 'O' packets can really slow down debugging if the inferior + // does a lot of output. const char *slave_name = NULL; if (stdin_path == NULL || stdout_path == NULL || stderr_path == NULL) { @@ -841,21 +863,6 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) stderr_path ? stderr_path : "<null>"); } - // Set STDIN to /dev/null if we want STDIO disabled or if either - // STDOUT or STDERR have been set to something and STDIN hasn't - if (disable_stdio || (stdin_path == NULL && (stdout_path || stderr_path))) - stdin_path = "/dev/null"; - - // Set STDOUT to /dev/null if we want STDIO disabled or if either - // STDIN or STDERR have been set to something and STDOUT hasn't - if (disable_stdio || (stdout_path == NULL && (stdin_path || stderr_path))) - stdout_path = "/dev/null"; - - // Set STDERR to /dev/null if we want STDIO disabled or if either - // STDIN or STDOUT have been set to something and STDERR hasn't - if (disable_stdio || (stderr_path == NULL && (stdin_path || stdout_path))) - stderr_path = "/dev/null"; - if (log) log->Printf ("ProcessGDBRemote::%s final STDIO paths after all adjustments: stdin=%s, stdout=%s, stdout=%s", __FUNCTION__, @@ -942,7 +949,6 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) SetPrivateState (SetThreadStopInfo (m_last_stop_packet)); - m_stdio_disable = disable_stdio; if (!disable_stdio) { if (pty.GetMasterFileDescriptor() != lldb_utility::PseudoTerminal::invalid_fd) @@ -2478,7 +2484,7 @@ ProcessGDBRemote::PutSTDIN (const char *src, size_t src_len, Error &error) ConnectionStatus status; m_stdio_communication.Write(src, src_len, status, NULL); } - else if (!m_stdio_disable) + else if (m_stdin_forward) { m_gdb_comm.SendStdinNotification(src, src_len); } |