summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process
diff options
context:
space:
mode:
authorVince Harron <vharron@google.com>2015-02-13 19:15:24 +0000
committerVince Harron <vharron@google.com>2015-02-13 19:15:24 +0000
commit4a8abd3f944dfa15b505e665366c9f06b10e667d (patch)
tree44cfcda6bf6020e7deca8b95a0743492c00816f8 /lldb/source/Plugins/Process
parent99eeb8aae4aa7fc650daba4566bfefc30cad09e4 (diff)
downloadbcm5719-llvm-4a8abd3f944dfa15b505e665366c9f06b10e667d.tar.gz
bcm5719-llvm-4a8abd3f944dfa15b505e665366c9f06b10e667d.zip
Fix TestProcessIO.py when run against a remote target
Fixed test case to copy redirected stdout/stderr files from remote target to host llgs wasn't bothering to put the pty master file handle in the right place if stdout/stderr were redirected to a file. It is still needed for stdin. Corrected some log message text llvm-svn: 229141
Diffstat (limited to 'lldb/source/Plugins/Process')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp57
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h3
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp6
3 files changed, 32 insertions, 34 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 865b3b03b98..feac9b87117 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -223,11 +223,21 @@ GDBRemoteCommunicationServerLLGS::LaunchProcess ()
return error;
}
- // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as needed.
- // llgs local-process debugging may specify PTYs, which will eliminate the need to reflect inferior
- // stdout/stderr over the gdb-remote protocol.
- if (ShouldRedirectInferiorOutputOverGdbRemote (m_process_launch_info))
- {
+ // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol
+ // as needed.
+ // llgs local-process debugging may specify PTY paths, which will make these
+ // file actions non-null
+ // process launch -i/e/o will also make these file actions non-null
+ // nullptr means that the traffic is expected to flow over gdb-remote protocol
+ if (
+ m_process_launch_info.GetFileActionForFD(STDIN_FILENO) == nullptr ||
+ m_process_launch_info.GetFileActionForFD(STDOUT_FILENO) == nullptr ||
+ m_process_launch_info.GetFileActionForFD(STDERR_FILENO) == nullptr
+ )
+ {
+ // nullptr means it's not redirected to file or pty (in case of LLGS local)
+ // at least one of stdio will be transferred pty<->gdb-remote
+ // we need to give the pty master handle to this object to read and/or write
if (log)
log->Printf ("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 " setting up stdout/stderr redirection via $O gdb-remote commands", __FUNCTION__, m_debugged_process_sp->GetID ());
@@ -269,27 +279,6 @@ GDBRemoteCommunicationServerLLGS::LaunchProcess ()
return error;
}
-bool
-GDBRemoteCommunicationServerLLGS::ShouldRedirectInferiorOutputOverGdbRemote (const lldb_private::ProcessLaunchInfo &launch_info) const
-{
- // Retrieve the file actions specified for stdout and stderr.
- auto stdout_file_action = launch_info.GetFileActionForFD (STDOUT_FILENO);
- auto stderr_file_action = launch_info.GetFileActionForFD (STDERR_FILENO);
-
- // If neither stdout and stderr file actions are specified, we're not doing anything special, so
- // assume we want to redirect stdout/stderr over gdb-remote $O messages.
- if ((stdout_file_action == nullptr) && (stderr_file_action == nullptr))
- {
- // Send stdout/stderr over the gdb-remote protocol.
- return true;
- }
-
- // Any other setting for either stdout or stderr implies we are either suppressing
- // it (with /dev/null) or we've got it set to a PTY. Either way, we don't want the
- // output over gdb-remote.
- return false;
-}
-
lldb_private::Error
GDBRemoteCommunicationServerLLGS::AttachToProcess (lldb::pid_t pid)
{
@@ -831,8 +820,20 @@ GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor (int fd)
return error;
}
- m_stdio_communication.SetReadThreadBytesReceivedCallback (STDIOReadThreadBytesReceived, this);
- m_stdio_communication.StartReadThread();
+ // llgs local-process debugging may specify PTY paths, which will make these
+ // file actions non-null
+ // process launch -e/o will also make these file actions non-null
+ // nullptr means that the traffic is expected to flow over gdb-remote protocol
+ if (
+ m_process_launch_info.GetFileActionForFD(STDOUT_FILENO) == nullptr ||
+ m_process_launch_info.GetFileActionForFD(STDERR_FILENO) == nullptr
+ )
+ {
+ // output from the process must be forwarded over gdb-remote
+ // create a thread to read the handle and send the data
+ m_stdio_communication.SetReadThreadBytesReceivedCallback (STDIOReadThreadBytesReceived, this);
+ m_stdio_communication.StartReadThread();
+ }
return error;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
index abd7250ea1b..5c8f6692198 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -284,9 +284,6 @@ private:
void
ClearProcessSpecificData ();
- bool
- ShouldRedirectInferiorOutputOverGdbRemote (const lldb_private::ProcessLaunchInfo &launch_info) const;
-
void
RegisterPacketHandlers ();
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 4ad82eb170b..88b94cc100d 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -784,7 +784,7 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info)
if (log)
{
if (stdin_path || stdout_path || stderr_path)
- log->Printf ("ProcessGDBRemote::%s provided with STDIO paths via launch_info: stdin=%s, stdout=%s, stdout=%s",
+ log->Printf ("ProcessGDBRemote::%s provided with STDIO paths via launch_info: stdin=%s, stdout=%s, stderr=%s",
__FUNCTION__,
stdin_path ? stdin_path : "<null>",
stdout_path ? stdout_path : "<null>",
@@ -856,7 +856,7 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info)
stderr_path = slave_name;
if (log)
- log->Printf ("ProcessGDBRemote::%s adjusted STDIO paths for local platform (IsHost() is true) using slave: stdin=%s, stdout=%s, stdout=%s",
+ log->Printf ("ProcessGDBRemote::%s adjusted STDIO paths for local platform (IsHost() is true) using slave: stdin=%s, stdout=%s, stderr=%s",
__FUNCTION__,
stdin_path ? stdin_path : "<null>",
stdout_path ? stdout_path : "<null>",
@@ -864,7 +864,7 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info)
}
if (log)
- log->Printf ("ProcessGDBRemote::%s final STDIO paths after all adjustments: stdin=%s, stdout=%s, stdout=%s",
+ log->Printf ("ProcessGDBRemote::%s final STDIO paths after all adjustments: stdin=%s, stdout=%s, stderr=%s",
__FUNCTION__,
stdin_path ? stdin_path : "<null>",
stdout_path ? stdout_path : "<null>",
OpenPOWER on IntegriCloud