[Lldb-commits] [PATCH] support for 'process launch -i' on remote targets

Vince Harron vharron at google.com
Tue Jan 27 17:29:18 PST 2015


Hi clayborg,

Installs stdin file onto remote target in working directory before
launch.

http://reviews.llvm.org/D7215

Files:
  include/lldb/Target/FileAction.h
  include/lldb/Target/ProcessLaunchInfo.h
  source/Target/ProcessLaunchInfo.cpp
  source/Target/Target.cpp

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());
+                        }
+                    }
+                }
             }
         }
     }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7215.18868.patch
Type: text/x-patch
Size: 3199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150128/ad1a9846/attachment.bin>


More information about the lldb-commits mailing list