Index: include/lldb/Target/FileAction.h =================================================================== --- include/lldb/Target/FileAction.h +++ include/lldb/Target/FileAction.h @@ -1,4 +1,4 @@ -//===-- ProcessLaunchInfo.h -------------------------------------*- C++ -*-===// +//===-- FileAction.h --------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Index: include/lldb/Target/ProcessLaunchInfo.h =================================================================== --- include/lldb/Target/ProcessLaunchInfo.h +++ include/lldb/Target/ProcessLaunchInfo.h @@ -76,6 +76,9 @@ const FileAction * GetFileActionForFD (int fd) const; + FileAction * + GetFileActionForFD (int fd); + Flags & GetFlags () { Index: source/Target/ProcessLaunchInfo.cpp =================================================================== --- source/Target/ProcessLaunchInfo.cpp +++ source/Target/ProcessLaunchInfo.cpp @@ -148,6 +148,17 @@ return NULL; } +FileAction * +ProcessLaunchInfo::GetFileActionForFD(int fd) +{ + for (size_t idx=0, count=m_file_actions.size(); idx < count; ++idx) + { + if (m_file_actions[idx].GetFD () == fd) + return &m_file_actions[idx]; + } + return nullptr; +} + const char * ProcessLaunchInfo::GetWorkingDirectory () const { Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -2314,6 +2314,36 @@ } } } + + if (launch_info) + { + // copy stdin redirect, if any + FileAction* stdin_action = launch_info->GetFileActionForFD(STDIN_FILENO); + if (stdin_action) + { + if (stdin_action->GetAction() == FileAction::eFileActionOpen) + { + // hopefully the stdin file and the executable don't have the same name! + FileSpec local_file; + local_file.SetFile(stdin_action->GetPath(), false); + + FileSpec remote_file; + + remote_file.GetDirectory() = platform_sp->GetWorkingDirectory(); + remote_file.GetFilename() = local_file.GetFilename(); + error = platform_sp->Install(local_file, remote_file); + if (error.Success()) + { + // update FileAction in place + stdin_action->Open(STDIN_FILENO, remote_file.GetPath().c_str(), true, false); + } + } + else + { + error.SetErrorStringWithFormat("stdin file action (%i) is unsupported for remote targets", stdin_action->GetAction()); + } + } + } } } }