<div dir="ltr">FWIW I also did a clean build on FreeBSD 10.0 with Cmake/Ninja and that worked fine.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jun 29, 2014 at 5:30 PM, Todd Fiala <span dir="ltr"><<a href="mailto:todd.fiala@gmail.com" target="_blank">todd.fiala@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: tfiala<br>
Date: Sun Jun 29 19:30:53 2014<br>
New Revision: 212005<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=212005&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=212005&view=rev</a><br>
Log:<br>
Pull ProcessInfo and ProcessLaunchInfo out of Target/Process.<br>
<br>
Elevate ProcessInfo and ProcessLaunchInfo into their own headers.<br>
llgs will be using ProcessLaunchInfo but doesn't need to pull in<br>
the rest of Process.h.<br>
<br>
This also moves a bunch of implementation details from the header<br>
declarations into ProcessInfo.cpp and ProcessLaunchInfo.cpp.<br>
<br>
Tested on Ubuntu 14.04 Cmake and MacOSX Xcode.<br>
<br>
Related to <a href="https://github.com/tfiala/lldb/issues/26" target="_blank">https://github.com/tfiala/lldb/issues/26</a>.<br>
<br>
Added:<br>
    lldb/trunk/include/lldb/Target/ProcessInfo.h<br>
    lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h<br>
    lldb/trunk/source/Target/ProcessInfo.cpp<br>
    lldb/trunk/source/Target/ProcessLaunchInfo.cpp<br>
Modified:<br>
    lldb/trunk/include/lldb/Target/Process.h<br>
    lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
    lldb/trunk/source/Target/CMakeLists.txt<br>
    lldb/trunk/source/Target/Process.cpp<br>
    lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj<br>
<br>
Modified: lldb/trunk/include/lldb/Target/Process.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=212005&r1=212004&r2=212005&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=212005&r1=212004&r2=212005&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/include/lldb/Target/Process.h (original)<br>
+++ lldb/trunk/include/lldb/Target/Process.h Sun Jun 29 19:30:53 2014<br>
@@ -45,6 +45,8 @@<br>
 #include "lldb/Target/JITLoaderList.h"<br>
 #include "lldb/Target/Memory.h"<br>
 #include "lldb/Target/MemoryRegionInfo.h"<br>
+#include "lldb/Target/ProcessInfo.h"<br>
+#include "lldb/Target/ProcessLaunchInfo.h"<br>
 #include "lldb/Target/QueueList.h"<br>
 #include "lldb/Target/ThreadList.h"<br>
 #include "lldb/Target/UnixSignals.h"<br>
@@ -106,232 +108,6 @@ public:<br>
 typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;<br>
<br>
 //----------------------------------------------------------------------<br>
-// ProcessInfo<br>
-//<br>
-// A base class for information for a process. This can be used to fill<br>
-// out information for a process prior to launching it, or it can be<br>
-// used for an instance of a process and can be filled in with the<br>
-// existing values for that process.<br>
-//----------------------------------------------------------------------<br>
-class ProcessInfo<br>
-{<br>
-public:<br>
-    ProcessInfo () :<br>
-        m_executable (),<br>
-        m_arguments (),<br>
-        m_environment (),<br>
-        m_uid (UINT32_MAX),<br>
-        m_gid (UINT32_MAX),<br>
-        m_arch(),<br>
-        m_pid (LLDB_INVALID_PROCESS_ID)<br>
-    {<br>
-    }<br>
-<br>
-    ProcessInfo (const char *name,<br>
-                 const ArchSpec &arch,<br>
-                 lldb::pid_t pid) :<br>
-        m_executable (name, false),<br>
-        m_arguments (),<br>
-        m_environment(),<br>
-        m_uid (UINT32_MAX),<br>
-        m_gid (UINT32_MAX),<br>
-        m_arch (arch),<br>
-        m_pid (pid)<br>
-    {<br>
-    }<br>
-<br>
-    void<br>
-    Clear ()<br>
-    {<br>
-        m_executable.Clear();<br>
-        m_arguments.Clear();<br>
-        m_environment.Clear();<br>
-        m_uid = UINT32_MAX;<br>
-        m_gid = UINT32_MAX;<br>
-        m_arch.Clear();<br>
-        m_pid = LLDB_INVALID_PROCESS_ID;<br>
-    }<br>
-<br>
-    const char *<br>
-    GetName() const<br>
-    {<br>
-        return m_executable.GetFilename().GetCString();<br>
-    }<br>
-<br>
-    size_t<br>
-    GetNameLength() const<br>
-    {<br>
-        return m_executable.GetFilename().GetLength();<br>
-    }<br>
-<br>
-    FileSpec &<br>
-    GetExecutableFile ()<br>
-    {<br>
-        return m_executable;<br>
-    }<br>
-<br>
-    void<br>
-    SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg)<br>
-    {<br>
-        if (exe_file)<br>
-        {<br>
-            m_executable = exe_file;<br>
-            if (add_exe_file_as_first_arg)<br>
-            {<br>
-                char filename[PATH_MAX];<br>
-                if (exe_file.GetPath(filename, sizeof(filename)))<br>
-                    m_arguments.InsertArgumentAtIndex (0, filename);<br>
-            }<br>
-        }<br>
-        else<br>
-        {<br>
-            m_executable.Clear();<br>
-        }<br>
-    }<br>
-<br>
-    const FileSpec &<br>
-    GetExecutableFile () const<br>
-    {<br>
-        return m_executable;<br>
-    }<br>
-<br>
-    uint32_t<br>
-    GetUserID() const<br>
-    {<br>
-        return m_uid;<br>
-    }<br>
-<br>
-    uint32_t<br>
-    GetGroupID() const<br>
-    {<br>
-        return m_gid;<br>
-    }<br>
-<br>
-    bool<br>
-    UserIDIsValid () const<br>
-    {<br>
-        return m_uid != UINT32_MAX;<br>
-    }<br>
-<br>
-    bool<br>
-    GroupIDIsValid () const<br>
-    {<br>
-        return m_gid != UINT32_MAX;<br>
-    }<br>
-<br>
-    void<br>
-    SetUserID (uint32_t uid)<br>
-    {<br>
-        m_uid = uid;<br>
-    }<br>
-<br>
-    void<br>
-    SetGroupID (uint32_t gid)<br>
-    {<br>
-        m_gid = gid;<br>
-    }<br>
-<br>
-    ArchSpec &<br>
-    GetArchitecture ()<br>
-    {<br>
-        return m_arch;<br>
-    }<br>
-<br>
-    const ArchSpec &<br>
-    GetArchitecture () const<br>
-    {<br>
-        return m_arch;<br>
-    }<br>
-<br>
-    void<br>
-    SetArchitecture (ArchSpec arch)<br>
-    {<br>
-        m_arch = arch;<br>
-    }<br>
-<br>
-    lldb::pid_t<br>
-    GetProcessID () const<br>
-    {<br>
-        return m_pid;<br>
-    }<br>
-<br>
-    void<br>
-    SetProcessID (lldb::pid_t pid)<br>
-    {<br>
-        m_pid = pid;<br>
-    }<br>
-<br>
-    bool<br>
-    ProcessIDIsValid() const<br>
-    {<br>
-        return m_pid != LLDB_INVALID_PROCESS_ID;<br>
-    }<br>
-<br>
-    void<br>
-    Dump (Stream &s, Platform *platform) const;<br>
-<br>
-    Args &<br>
-    GetArguments ()<br>
-    {<br>
-        return m_arguments;<br>
-    }<br>
-<br>
-    const Args &<br>
-    GetArguments () const<br>
-    {<br>
-        return m_arguments;<br>
-    }<br>
-<br>
-    const char *<br>
-    GetArg0 () const<br>
-    {<br>
-        if (m_arg0.empty())<br>
-            return NULL;<br>
-        return m_arg0.c_str();<br>
-    }<br>
-<br>
-    void<br>
-    SetArg0 (const char *arg)<br>
-    {<br>
-        if (arg && arg[0])<br>
-            m_arg0 = arg;<br>
-        else<br>
-            m_arg0.clear();<br>
-    }<br>
-<br>
-    void<br>
-    SetArguments (const Args& args, bool first_arg_is_executable);<br>
-<br>
-    void<br>
-    SetArguments (char const **argv, bool first_arg_is_executable);<br>
-<br>
-    Args &<br>
-    GetEnvironmentEntries ()<br>
-    {<br>
-        return m_environment;<br>
-    }<br>
-<br>
-    const Args &<br>
-    GetEnvironmentEntries () const<br>
-    {<br>
-        return m_environment;<br>
-    }<br>
-<br>
-protected:<br>
-    FileSpec m_executable;<br>
-    std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.<br>
-                        // Not all process plug-ins support specifying an argv[0]<br>
-                        // that differs from the resolved platform executable<br>
-                        // (which is in m_executable)<br>
-    Args m_arguments;   // All program arguments except argv[0]<br>
-    Args m_environment;<br>
-    uint32_t m_uid;<br>
-    uint32_t m_gid;<br>
-    ArchSpec m_arch;<br>
-    lldb::pid_t m_pid;<br>
-};<br>
-<br>
-//----------------------------------------------------------------------<br>
 // ProcessInstanceInfo<br>
 //<br>
 // Describes an existing process and any discoverable information that<br>
@@ -436,466 +212,6 @@ protected:<br>
     lldb::pid_t m_parent_pid;<br>
 };<br>
<br>
-<br>
-//----------------------------------------------------------------------<br>
-// ProcessLaunchInfo<br>
-//<br>
-// Describes any information that is required to launch a process.<br>
-//----------------------------------------------------------------------<br>
-<br>
-class ProcessLaunchInfo : public ProcessInfo<br>
-{<br>
-public:<br>
-<br>
-    class FileAction<br>
-    {<br>
-    public:<br>
-        enum Action<br>
-        {<br>
-            eFileActionNone,<br>
-            eFileActionClose,<br>
-            eFileActionDuplicate,<br>
-            eFileActionOpen<br>
-        };<br>
-<br>
-<br>
-        FileAction () :<br>
-            m_action (eFileActionNone),<br>
-            m_fd (-1),<br>
-            m_arg (-1),<br>
-            m_path ()<br>
-        {<br>
-        }<br>
-<br>
-        void<br>
-        Clear()<br>
-        {<br>
-            m_action = eFileActionNone;<br>
-            m_fd = -1;<br>
-            m_arg = -1;<br>
-            m_path.clear();<br>
-        }<br>
-<br>
-        bool<br>
-        Close (int fd);<br>
-<br>
-        bool<br>
-        Duplicate (int fd, int dup_fd);<br>
-<br>
-        bool<br>
-        Open (int fd, const char *path, bool read, bool write);<br>
-<br>
-#ifndef LLDB_DISABLE_POSIX<br>
-        static bool<br>
-        AddPosixSpawnFileAction (void *file_actions,<br>
-                                 const FileAction *info,<br>
-                                 Log *log,<br>
-                                 Error& error);<br>
-#endif<br>
-<br>
-        int<br>
-        GetFD () const<br>
-        {<br>
-            return m_fd;<br>
-        }<br>
-<br>
-        Action<br>
-        GetAction () const<br>
-        {<br>
-            return m_action;<br>
-        }<br>
-<br>
-        int<br>
-        GetActionArgument () const<br>
-        {<br>
-            return m_arg;<br>
-        }<br>
-<br>
-        const char *<br>
-        GetPath () const<br>
-        {<br>
-            if (m_path.empty())<br>
-                return NULL;<br>
-            return m_path.c_str();<br>
-        }<br>
-<br>
-    protected:<br>
-        Action m_action;    // The action for this file<br>
-        int m_fd;           // An existing file descriptor<br>
-        int m_arg;          // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate<br>
-        std::string m_path; // A file path to use for opening after fork or posix_spawn<br>
-    };<br>
-<br>
-    ProcessLaunchInfo () :<br>
-        ProcessInfo(),<br>
-        m_working_dir (),<br>
-        m_plugin_name (),<br>
-        m_shell (),<br>
-        m_flags (0),<br>
-        m_file_actions (),<br>
-        m_pty (),<br>
-        m_resume_count (0),<br>
-        m_monitor_callback (NULL),<br>
-        m_monitor_callback_baton (NULL),<br>
-        m_monitor_signals (false),<br>
-        m_hijack_listener_sp ()<br>
-    {<br>
-    }<br>
-<br>
-    ProcessLaunchInfo (const char *stdin_path,<br>
-                       const char *stdout_path,<br>
-                       const char *stderr_path,<br>
-                       const char *working_directory,<br>
-                       uint32_t launch_flags) :<br>
-        ProcessInfo(),<br>
-        m_working_dir (),<br>
-        m_plugin_name (),<br>
-        m_shell (),<br>
-        m_flags (launch_flags),<br>
-        m_file_actions (),<br>
-        m_pty (),<br>
-        m_resume_count (0),<br>
-        m_monitor_callback (NULL),<br>
-        m_monitor_callback_baton (NULL),<br>
-        m_monitor_signals (false),<br>
-        m_hijack_listener_sp ()<br>
-    {<br>
-        if (stdin_path)<br>
-        {<br>
-            ProcessLaunchInfo::FileAction file_action;<br>
-            const bool read = true;<br>
-            const bool write = false;<br>
-            if (file_action.Open(STDIN_FILENO, stdin_path, read, write))<br>
-                AppendFileAction (file_action);<br>
-        }<br>
-        if (stdout_path)<br>
-        {<br>
-            ProcessLaunchInfo::FileAction file_action;<br>
-            const bool read = false;<br>
-            const bool write = true;<br>
-            if (file_action.Open(STDOUT_FILENO, stdout_path, read, write))<br>
-                AppendFileAction (file_action);<br>
-        }<br>
-        if (stderr_path)<br>
-        {<br>
-            ProcessLaunchInfo::FileAction file_action;<br>
-            const bool read = false;<br>
-            const bool write = true;<br>
-            if (file_action.Open(STDERR_FILENO, stderr_path, read, write))<br>
-                AppendFileAction (file_action);<br>
-        }<br>
-        if (working_directory)<br>
-            SetWorkingDirectory(working_directory);<br>
-    }<br>
-<br>
-    void<br>
-    AppendFileAction (const FileAction &info)<br>
-    {<br>
-        m_file_actions.push_back(info);<br>
-    }<br>
-<br>
-    bool<br>
-    AppendCloseFileAction (int fd)<br>
-    {<br>
-        FileAction file_action;<br>
-        if (file_action.Close (fd))<br>
-        {<br>
-            AppendFileAction (file_action);<br>
-            return true;<br>
-        }<br>
-        return false;<br>
-    }<br>
-<br>
-    bool<br>
-    AppendDuplicateFileAction (int fd, int dup_fd)<br>
-    {<br>
-        FileAction file_action;<br>
-        if (file_action.Duplicate (fd, dup_fd))<br>
-        {<br>
-            AppendFileAction (file_action);<br>
-            return true;<br>
-        }<br>
-        return false;<br>
-    }<br>
-<br>
-    bool<br>
-    AppendOpenFileAction (int fd, const char *path, bool read, bool write)<br>
-    {<br>
-        FileAction file_action;<br>
-        if (file_action.Open (fd, path, read, write))<br>
-        {<br>
-            AppendFileAction (file_action);<br>
-            return true;<br>
-        }<br>
-        return false;<br>
-    }<br>
-<br>
-    bool<br>
-    AppendSuppressFileAction (int fd, bool read, bool write)<br>
-    {<br>
-        FileAction file_action;<br>
-        if (file_action.Open (fd, "/dev/null", read, write))<br>
-        {<br>
-            AppendFileAction (file_action);<br>
-            return true;<br>
-        }<br>
-        return false;<br>
-    }<br>
-<br>
-    void<br>
-    FinalizeFileActions (Target *target,<br>
-                         bool default_to_use_pty);<br>
-<br>
-    size_t<br>
-    GetNumFileActions () const<br>
-    {<br>
-        return m_file_actions.size();<br>
-    }<br>
-<br>
-    const FileAction *<br>
-    GetFileActionAtIndex (size_t idx) const<br>
-    {<br>
-        if (idx < m_file_actions.size())<br>
-            return &m_file_actions[idx];<br>
-        return NULL;<br>
-    }<br>
-<br>
-    const FileAction *<br>
-    GetFileActionForFD (int fd) const<br>
-    {<br>
-        for (size_t idx=0, count=m_file_actions.size(); idx < count; ++idx)<br>
-        {<br>
-            if (m_file_actions[idx].GetFD () == fd)<br>
-                return &m_file_actions[idx];<br>
-        }<br>
-        return NULL;<br>
-    }<br>
-<br>
-    Flags &<br>
-    GetFlags ()<br>
-    {<br>
-        return m_flags;<br>
-    }<br>
-<br>
-    const Flags &<br>
-    GetFlags () const<br>
-    {<br>
-        return m_flags;<br>
-    }<br>
-<br>
-    const char *<br>
-    GetWorkingDirectory () const<br>
-    {<br>
-        if (m_working_dir.empty())<br>
-            return NULL;<br>
-        return m_working_dir.c_str();<br>
-    }<br>
-<br>
-    void<br>
-    SetWorkingDirectory (const char *working_dir)<br>
-    {<br>
-        if (working_dir && working_dir[0])<br>
-            m_working_dir.assign (working_dir);<br>
-        else<br>
-            m_working_dir.clear();<br>
-    }<br>
-<br>
-    void<br>
-    SwapWorkingDirectory (std::string &working_dir)<br>
-    {<br>
-        m_working_dir.swap (working_dir);<br>
-    }<br>
-<br>
-<br>
-    const char *<br>
-    GetProcessPluginName () const<br>
-    {<br>
-        if (m_plugin_name.empty())<br>
-            return NULL;<br>
-        return m_plugin_name.c_str();<br>
-    }<br>
-<br>
-    void<br>
-    SetProcessPluginName (const char *plugin)<br>
-    {<br>
-        if (plugin && plugin[0])<br>
-            m_plugin_name.assign (plugin);<br>
-        else<br>
-            m_plugin_name.clear();<br>
-    }<br>
-<br>
-    const char *<br>
-    GetShell () const<br>
-    {<br>
-        if (m_shell.empty())<br>
-            return NULL;<br>
-        return m_shell.c_str();<br>
-    }<br>
-<br>
-    void<br>
-    SetShell (const char * path)<br>
-    {<br>
-        if (path && path[0])<br>
-        {<br>
-            m_shell.assign (path);<br>
-            m_flags.Set (lldb::eLaunchFlagLaunchInShell);<br>
-        }<br>
-        else<br>
-        {<br>
-            m_shell.clear();<br>
-            m_flags.Clear (lldb::eLaunchFlagLaunchInShell);<br>
-        }<br>
-    }<br>
-<br>
-    uint32_t<br>
-    GetResumeCount () const<br>
-    {<br>
-        return m_resume_count;<br>
-    }<br>
-<br>
-    void<br>
-    SetResumeCount (uint32_t c)<br>
-    {<br>
-        m_resume_count = c;<br>
-    }<br>
-<br>
-    bool<br>
-    GetLaunchInSeparateProcessGroup ()<br>
-    {<br>
-        return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup);<br>
-    }<br>
-<br>
-    void<br>
-    SetLaunchInSeparateProcessGroup (bool separate)<br>
-    {<br>
-        if (separate)<br>
-            m_flags.Set(lldb::eLaunchFlagLaunchInSeparateProcessGroup);<br>
-        else<br>
-            m_flags.Clear (lldb::eLaunchFlagLaunchInSeparateProcessGroup);<br>
-<br>
-    }<br>
-<br>
-    void<br>
-    Clear ()<br>
-    {<br>
-        ProcessInfo::Clear();<br>
-        m_working_dir.clear();<br>
-        m_plugin_name.clear();<br>
-        m_shell.clear();<br>
-        m_flags.Clear();<br>
-        m_file_actions.clear();<br>
-        m_resume_count = 0;<br>
-        m_hijack_listener_sp.reset();<br>
-    }<br>
-<br>
-    bool<br>
-    ConvertArgumentsForLaunchingInShell (Error &error,<br>
-                                         bool localhost,<br>
-                                         bool will_debug,<br>
-                                         bool first_arg_is_full_shell_command,<br>
-                                         int32_t num_resumes);<br>
-<br>
-    void<br>
-    SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback,<br>
-                               void *baton,<br>
-                               bool monitor_signals)<br>
-    {<br>
-        m_monitor_callback = callback;<br>
-        m_monitor_callback_baton = baton;<br>
-        m_monitor_signals = monitor_signals;<br>
-    }<br>
-<br>
-    Host::MonitorChildProcessCallback<br>
-    GetMonitorProcessCallback ()<br>
-    {<br>
-        return m_monitor_callback;<br>
-    }<br>
-<br>
-    const void*<br>
-    GetMonitorProcessBaton () const<br>
-    {<br>
-        return m_monitor_callback_baton;<br>
-    }<br>
-<br>
-    // If the LaunchInfo has a monitor callback, then arrange to monitor the process.<br>
-    // Return true if the LaunchInfo has taken care of monitoring the process, and false if the<br>
-    // caller might want to monitor the process themselves.<br>
-<br>
-    bool<br>
-    MonitorProcess () const<br>
-    {<br>
-        if (m_monitor_callback && ProcessIDIsValid())<br>
-        {<br>
-            Host::StartMonitoringChildProcess (m_monitor_callback,<br>
-                                               m_monitor_callback_baton,<br>
-                                               GetProcessID(),<br>
-                                               m_monitor_signals);<br>
-            return true;<br>
-        }<br>
-        return false;<br>
-    }<br>
-<br>
-    lldb_utility::PseudoTerminal &<br>
-    GetPTY ()<br>
-    {<br>
-        return m_pty;<br>
-    }<br>
-<br>
-    lldb::ListenerSP<br>
-    GetHijackListener () const<br>
-    {<br>
-        return m_hijack_listener_sp;<br>
-    }<br>
-<br>
-    void<br>
-    SetHijackListener (const lldb::ListenerSP &listener_sp)<br>
-    {<br>
-        m_hijack_listener_sp = listener_sp;<br>
-    }<br>
-<br>
-<br>
-    void<br>
-    SetLaunchEventData (const char *data)<br>
-    {<br>
-        m_event_data.assign (data);<br>
-    }<br>
-<br>
-    const char *<br>
-    GetLaunchEventData () const<br>
-    {<br>
-        return m_event_data.c_str();<br>
-    }<br>
-<br>
-    void<br>
-    SetDetachOnError (bool enable)<br>
-    {<br>
-        if (enable)<br>
-            m_flags.Set(lldb::eLaunchFlagDetachOnError);<br>
-        else<br>
-            m_flags.Clear(lldb::eLaunchFlagDetachOnError);<br>
-    }<br>
-<br>
-    bool<br>
-    GetDetachOnError () const<br>
-    {<br>
-        return m_flags.Test(lldb::eLaunchFlagDetachOnError);<br>
-    }<br>
-<br>
-protected:<br>
-    std::string m_working_dir;<br>
-    std::string m_plugin_name;<br>
-    std::string m_shell;<br>
-    Flags m_flags;       // Bitwise OR of bits from lldb::LaunchFlags<br>
-    std::vector<FileAction> m_file_actions; // File actions for any other files<br>
-    lldb_utility::PseudoTerminal m_pty;<br>
-    uint32_t m_resume_count; // How many times do we resume after launching<br>
-    Host::MonitorChildProcessCallback m_monitor_callback;<br>
-    void *m_monitor_callback_baton;<br>
-    bool m_monitor_signals;<br>
-    std::string m_event_data; // A string passed to the plugin launch, having no meaning to the upper levels of lldb.<br>
-    lldb::ListenerSP m_hijack_listener_sp;<br>
-};<br>
-<br>
 //----------------------------------------------------------------------<br>
 // ProcessAttachInfo<br>
 //<br>
<br>
Added: lldb/trunk/include/lldb/Target/ProcessInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ProcessInfo.h?rev=212005&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ProcessInfo.h?rev=212005&view=auto</a><br>

==============================================================================<br>
--- lldb/trunk/include/lldb/Target/ProcessInfo.h (added)<br>
+++ lldb/trunk/include/lldb/Target/ProcessInfo.h Sun Jun 29 19:30:53 2014<br>
@@ -0,0 +1,188 @@<br>
+//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef liblldb_ProcessInfo_h_<br>
+#define liblldb_ProcessInfo_h_<br>
+<br>
+// LLDB headers<br>
+#include "lldb/Core/ArchSpec.h"<br>
+#include "lldb/Host/FileSpec.h"<br>
+#include "lldb/Interpreter/Args.h"<br>
+<br>
+namespace lldb_private<br>
+{<br>
+    //----------------------------------------------------------------------<br>
+    // ProcessInfo<br>
+    //<br>
+    // A base class for information for a process. This can be used to fill<br>
+    // out information for a process prior to launching it, or it can be<br>
+    // used for an instance of a process and can be filled in with the<br>
+    // existing values for that process.<br>
+    //----------------------------------------------------------------------<br>
+    class ProcessInfo<br>
+    {<br>
+    public:<br>
+        ProcessInfo ();<br>
+<br>
+        ProcessInfo (const char *name,<br>
+                     const ArchSpec &arch,<br>
+                     lldb::pid_t pid);<br>
+<br>
+        void<br>
+        Clear ();<br>
+<br>
+        const char *<br>
+        GetName() const;<br>
+<br>
+        size_t<br>
+        GetNameLength() const;<br>
+<br>
+        FileSpec &<br>
+        GetExecutableFile ()<br>
+        {<br>
+            return m_executable;<br>
+        }<br>
+<br>
+        void<br>
+        SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg);<br>
+<br>
+        const FileSpec &<br>
+        GetExecutableFile () const<br>
+        {<br>
+            return m_executable;<br>
+        }<br>
+<br>
+        uint32_t<br>
+        GetUserID() const<br>
+        {<br>
+            return m_uid;<br>
+        }<br>
+<br>
+        uint32_t<br>
+        GetGroupID() const<br>
+        {<br>
+            return m_gid;<br>
+        }<br>
+<br>
+        bool<br>
+        UserIDIsValid () const<br>
+        {<br>
+            return m_uid != UINT32_MAX;<br>
+        }<br>
+<br>
+        bool<br>
+        GroupIDIsValid () const<br>
+        {<br>
+            return m_gid != UINT32_MAX;<br>
+        }<br>
+<br>
+        void<br>
+        SetUserID (uint32_t uid)<br>
+        {<br>
+            m_uid = uid;<br>
+        }<br>
+<br>
+        void<br>
+        SetGroupID (uint32_t gid)<br>
+        {<br>
+            m_gid = gid;<br>
+        }<br>
+<br>
+        ArchSpec &<br>
+        GetArchitecture ()<br>
+        {<br>
+            return m_arch;<br>
+        }<br>
+<br>
+        const ArchSpec &<br>
+        GetArchitecture () const<br>
+        {<br>
+            return m_arch;<br>
+        }<br>
+<br>
+        void<br>
+        SetArchitecture (ArchSpec arch)<br>
+        {<br>
+            m_arch = arch;<br>
+        }<br>
+<br>
+        lldb::pid_t<br>
+        GetProcessID () const<br>
+        {<br>
+            return m_pid;<br>
+        }<br>
+<br>
+        void<br>
+        SetProcessID (lldb::pid_t pid)<br>
+        {<br>
+            m_pid = pid;<br>
+        }<br>
+<br>
+        bool<br>
+        ProcessIDIsValid() const<br>
+        {<br>
+            return m_pid != LLDB_INVALID_PROCESS_ID;<br>
+        }<br>
+<br>
+        void<br>
+        Dump (Stream &s, Platform *platform) const;<br>
+<br>
+        Args &<br>
+        GetArguments ()<br>
+        {<br>
+            return m_arguments;<br>
+        }<br>
+<br>
+        const Args &<br>
+        GetArguments () const<br>
+        {<br>
+            return m_arguments;<br>
+        }<br>
+<br>
+        const char *<br>
+        GetArg0 () const;<br>
+<br>
+        void<br>
+        SetArg0 (const char *arg);<br>
+<br>
+        void<br>
+        SetArguments (const Args& args, bool first_arg_is_executable);<br>
+<br>
+        void<br>
+        SetArguments (char const **argv, bool first_arg_is_executable);<br>
+<br>
+        Args &<br>
+        GetEnvironmentEntries ()<br>
+        {<br>
+            return m_environment;<br>
+        }<br>
+<br>
+        const Args &<br>
+        GetEnvironmentEntries () const<br>
+        {<br>
+            return m_environment;<br>
+        }<br>
+<br>
+    protected:<br>
+        FileSpec m_executable;<br>
+        std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.<br>
+        // Not all process plug-ins support specifying an argv[0]<br>
+        // that differs from the resolved platform executable<br>
+        // (which is in m_executable)<br>
+        Args m_arguments;   // All program arguments except argv[0]<br>
+        Args m_environment;<br>
+        uint32_t m_uid;<br>
+        uint32_t m_gid;<br>
+        ArchSpec m_arch;<br>
+        lldb::pid_t m_pid;<br>
+    };<br>
+}<br>
+<br>
+#endif // #ifndef liblldb_ProcessInfo_h_<br>
+<br>
<br>
Added: lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h?rev=212005&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h?rev=212005&view=auto</a><br>

==============================================================================<br>
--- lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h (added)<br>
+++ lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h Sun Jun 29 19:30:53 2014<br>
@@ -0,0 +1,285 @@<br>
+//===-- ProcessLaunchInfo.h -------------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef liblldb_ProcessLaunch_Info_h<br>
+#define liblldb_ProcessLaunch_Info_h<br>
+<br>
+// C++ Headers<br>
+#include <string><br>
+<br>
+// LLDB Headers<br>
+#include "lldb/Core/Flags.h"<br>
+#include "lldb/Host/Host.h"<br>
+#include "lldb/Target/ProcessInfo.h"<br>
+#include "lldb/Utility/PseudoTerminal.h"<br>
+<br>
+namespace lldb_private<br>
+{<br>
+<br>
+    //----------------------------------------------------------------------<br>
+    // ProcessLaunchInfo<br>
+    //<br>
+    // Describes any information that is required to launch a process.<br>
+    //----------------------------------------------------------------------<br>
+<br>
+    class ProcessLaunchInfo : public ProcessInfo<br>
+    {<br>
+    public:<br>
+<br>
+        class FileAction<br>
+        {<br>
+        public:<br>
+            enum Action<br>
+            {<br>
+                eFileActionNone,<br>
+                eFileActionClose,<br>
+                eFileActionDuplicate,<br>
+                eFileActionOpen<br>
+            };<br>
+<br>
+            FileAction ();<br>
+<br>
+            void<br>
+            Clear();<br>
+<br>
+            bool<br>
+            Close (int fd);<br>
+<br>
+            bool<br>
+            Duplicate (int fd, int dup_fd);<br>
+<br>
+            bool<br>
+            Open (int fd, const char *path, bool read, bool write);<br>
+<br>
+    #ifndef LLDB_DISABLE_POSIX<br>
+            static bool<br>
+            AddPosixSpawnFileAction (void *file_actions,<br>
+                                     const FileAction *info,<br>
+                                     Log *log,<br>
+                                     Error& error);<br>
+    #endif<br>
+<br>
+            int<br>
+            GetFD () const<br>
+            {<br>
+                return m_fd;<br>
+            }<br>
+<br>
+            Action<br>
+            GetAction () const<br>
+            {<br>
+                return m_action;<br>
+            }<br>
+<br>
+            int<br>
+            GetActionArgument () const<br>
+            {<br>
+                return m_arg;<br>
+            }<br>
+<br>
+            const char *<br>
+            GetPath () const;<br>
+<br>
+        protected:<br>
+            Action m_action;    // The action for this file<br>
+            int m_fd;           // An existing file descriptor<br>
+            int m_arg;          // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate<br>
+            std::string m_path; // A file path to use for opening after fork or posix_spawn<br>
+        };<br>
+<br>
+        ProcessLaunchInfo ();<br>
+<br>
+        ProcessLaunchInfo (const char *stdin_path,<br>
+                           const char *stdout_path,<br>
+                           const char *stderr_path,<br>
+                           const char *working_directory,<br>
+                           uint32_t launch_flags);<br>
+<br>
+        void<br>
+        AppendFileAction (const FileAction &info)<br>
+        {<br>
+            m_file_actions.push_back(info);<br>
+        }<br>
+<br>
+        bool<br>
+        AppendCloseFileAction (int fd);<br>
+<br>
+        bool<br>
+        AppendDuplicateFileAction (int fd, int dup_fd);<br>
+<br>
+        bool<br>
+        AppendOpenFileAction (int fd, const char *path, bool read, bool write);<br>
+<br>
+        bool<br>
+        AppendSuppressFileAction (int fd, bool read, bool write);<br>
+<br>
+        void<br>
+        FinalizeFileActions (Target *target,<br>
+                             bool default_to_use_pty);<br>
+<br>
+        size_t<br>
+        GetNumFileActions () const<br>
+        {<br>
+            return m_file_actions.size();<br>
+        }<br>
+<br>
+        const FileAction *<br>
+        GetFileActionAtIndex (size_t idx) const;<br>
+<br>
+        const FileAction *<br>
+        GetFileActionForFD (int fd) const;<br>
+<br>
+        Flags &<br>
+        GetFlags ()<br>
+        {<br>
+            return m_flags;<br>
+        }<br>
+<br>
+        const Flags &<br>
+        GetFlags () const<br>
+        {<br>
+            return m_flags;<br>
+        }<br>
+<br>
+        const char *<br>
+        GetWorkingDirectory () const;<br>
+<br>
+        void<br>
+        SetWorkingDirectory (const char *working_dir);<br>
+<br>
+        void<br>
+        SwapWorkingDirectory (std::string &working_dir)<br>
+        {<br>
+            m_working_dir.swap (working_dir);<br>
+        }<br>
+<br>
+        const char *<br>
+        GetProcessPluginName () const;<br>
+<br>
+        void<br>
+        SetProcessPluginName (const char *plugin);<br>
+<br>
+        const char *<br>
+        GetShell () const;<br>
+<br>
+        void<br>
+        SetShell (const char * path);<br>
+<br>
+        uint32_t<br>
+        GetResumeCount () const<br>
+        {<br>
+            return m_resume_count;<br>
+        }<br>
+<br>
+        void<br>
+        SetResumeCount (uint32_t c)<br>
+        {<br>
+            m_resume_count = c;<br>
+        }<br>
+<br>
+        bool<br>
+        GetLaunchInSeparateProcessGroup ()<br>
+        {<br>
+            return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup);<br>
+        }<br>
+<br>
+        void<br>
+        SetLaunchInSeparateProcessGroup (bool separate);<br>
+<br>
+        void<br>
+        Clear ();<br>
+<br>
+        bool<br>
+        ConvertArgumentsForLaunchingInShell (Error &error,<br>
+                                             bool localhost,<br>
+                                             bool will_debug,<br>
+                                             bool first_arg_is_full_shell_command,<br>
+                                             int32_t num_resumes);<br>
+<br>
+        void<br>
+        SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback,<br>
+                                   void *baton,<br>
+                                   bool monitor_signals);<br>
+<br>
+        Host::MonitorChildProcessCallback<br>
+        GetMonitorProcessCallback ()<br>
+        {<br>
+            return m_monitor_callback;<br>
+        }<br>
+<br>
+        const void*<br>
+        GetMonitorProcessBaton () const<br>
+        {<br>
+            return m_monitor_callback_baton;<br>
+        }<br>
+<br>
+        // If the LaunchInfo has a monitor callback, then arrange to monitor the process.<br>
+        // Return true if the LaunchInfo has taken care of monitoring the process, and false if the<br>
+        // caller might want to monitor the process themselves.<br>
+<br>
+        bool<br>
+        MonitorProcess () const;<br>
+<br>
+        lldb_utility::PseudoTerminal &<br>
+        GetPTY ()<br>
+        {<br>
+            return m_pty;<br>
+        }<br>
+<br>
+        lldb::ListenerSP<br>
+        GetHijackListener () const<br>
+        {<br>
+            return m_hijack_listener_sp;<br>
+        }<br>
+<br>
+        void<br>
+        SetHijackListener (const lldb::ListenerSP &listener_sp)<br>
+        {<br>
+            m_hijack_listener_sp = listener_sp;<br>
+        }<br>
+<br>
+<br>
+        void<br>
+        SetLaunchEventData (const char *data)<br>
+        {<br>
+            m_event_data.assign (data);<br>
+        }<br>
+<br>
+        const char *<br>
+        GetLaunchEventData () const<br>
+        {<br>
+            return m_event_data.c_str();<br>
+        }<br>
+<br>
+        void<br>
+        SetDetachOnError (bool enable);<br>
+<br>
+        bool<br>
+        GetDetachOnError () const<br>
+        {<br>
+            return m_flags.Test(lldb::eLaunchFlagDetachOnError);<br>
+        }<br>
+<br>
+    protected:<br>
+        std::string m_working_dir;<br>
+        std::string m_plugin_name;<br>
+        std::string m_shell;<br>
+        Flags m_flags;       // Bitwise OR of bits from lldb::LaunchFlags<br>
+        std::vector<FileAction> m_file_actions; // File actions for any other files<br>
+        lldb_utility::PseudoTerminal m_pty;<br>
+        uint32_t m_resume_count; // How many times do we resume after launching<br>
+        Host::MonitorChildProcessCallback m_monitor_callback;<br>
+        void *m_monitor_callback_baton;<br>
+        bool m_monitor_signals;<br>
+        std::string m_event_data; // A string passed to the plugin launch, having no meaning to the upper levels of lldb.<br>
+        lldb::ListenerSP m_hijack_listener_sp;<br>
+    };<br>
+}<br>
+<br>
+#endif // liblldb_ProcessLaunch_Info_h<br>
<br>
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=212005&r1=212004&r2=212005&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=212005&r1=212004&r2=212005&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)<br>
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Jun 29 19:30:53 2014<br>
@@ -53,6 +53,8 @@<br>
 /* Begin PBXBuildFile section */<br>
                23059A101958B319007B8189 /* SBUnixSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23059A0F1958B319007B8189 /* SBUnixSignals.cpp */; };<br>
                23059A121958B3B2007B8189 /* SBUnixSignals.h in Headers */ = {isa = PBXBuildFile; fileRef = 23059A111958B37B007B8189 /* SBUnixSignals.h */; settings = {ATTRIBUTES = (Public, ); }; };<br>
+               233B007D1960C9F90090E598 /* ProcessInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 233B007B1960C9E60090E598 /* ProcessInfo.cpp */; };<br>
+               233B007F1960CB280090E598 /* ProcessLaunchInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 233B007E1960CB280090E598 /* ProcessLaunchInfo.cpp */; };<br>
                23EFE389193D1ABC00E54E54 /* SBTypeEnumMember.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EFE388193D1ABC00E54E54 /* SBTypeEnumMember.h */; settings = {ATTRIBUTES = (Public, ); }; };<br>
                23EFE38B193D1AEC00E54E54 /* SBTypeEnumMember.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EFE38A193D1AEC00E54E54 /* SBTypeEnumMember.cpp */; };<br>
                260157C61885F51C00F875CF /* libpanel.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 260157C41885F4FF00F875CF /* libpanel.dylib */; };<br>
@@ -875,6 +877,10 @@<br>
 /* Begin PBXFileReference section */<br>
                23059A0F1958B319007B8189 /* SBUnixSignals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBUnixSignals.cpp; path = source/API/SBUnixSignals.cpp; sourceTree = "<group>"; };<br>

                23059A111958B37B007B8189 /* SBUnixSignals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBUnixSignals.h; path = include/lldb/API/SBUnixSignals.h; sourceTree = "<group>"; };<br>

+               233B007919609DB40090E598 /* ProcessLaunchInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ProcessLaunchInfo.h; path = include/lldb/Target/ProcessLaunchInfo.h; sourceTree = "<group>"; };<br>

+               233B007A1960A0440090E598 /* ProcessInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ProcessInfo.h; path = include/lldb/Target/ProcessInfo.h; sourceTree = "<group>"; };<br>

+               233B007B1960C9E60090E598 /* ProcessInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ProcessInfo.cpp; path = source/Target/ProcessInfo.cpp; sourceTree = "<group>"; };<br>

+               233B007E1960CB280090E598 /* ProcessLaunchInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ProcessLaunchInfo.cpp; path = source/Target/ProcessLaunchInfo.cpp; sourceTree = "<group>"; };<br>

                2360092C193FB21500189DB1 /* MemoryRegionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MemoryRegionInfo.h; path = include/lldb/Target/MemoryRegionInfo.h; sourceTree = "<group>"; };<br>

                23EDE3371926AAD500F6A132 /* RegisterInfoInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegisterInfoInterface.h; path = Utility/RegisterInfoInterface.h; sourceTree = "<group>"; };<br>

                23EFE388193D1ABC00E54E54 /* SBTypeEnumMember.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeEnumMember.h; path = include/lldb/API/SBTypeEnumMember.h; sourceTree = "<group>"; };<br>

@@ -3449,6 +3455,10 @@<br>
                                495BBACB119A0DBE00418BEA /* PathMappingList.cpp */,<br>
                                264A43BB1320B3B4005B4096 /* Platform.h */,<br>
                                264A43BD1320BCEB005B4096 /* Platform.cpp */,<br>
+                               233B007A1960A0440090E598 /* ProcessInfo.h */,<br>
+                               233B007B1960C9E60090E598 /* ProcessInfo.cpp */,<br>
+                               233B007E1960CB280090E598 /* ProcessLaunchInfo.cpp */,<br>
+                               233B007919609DB40090E598 /* ProcessLaunchInfo.h */,<br>
                                26BC7DF310F1B81A00F91463 /* Process.h */,<br>
                                26BC7F3610F1B90C00F91463 /* Process.cpp */,<br>
                                260A63111860FDB600FECF8E /* Queue.h */,<br>
@@ -4610,6 +4620,7 @@<br>
                                2689005613353E0400698AC0 /* Value.cpp in Sources */,<br>
                                2689005713353E0400698AC0 /* ValueObject.cpp in Sources */,<br>
                                2689005813353E0400698AC0 /* ValueObjectChild.cpp in Sources */,<br>
+                               233B007F1960CB280090E598 /* ProcessLaunchInfo.cpp in Sources */,<br>
                                2689005913353E0400698AC0 /* ValueObjectConstResult.cpp in Sources */,<br>
                                2689005A13353E0400698AC0 /* ValueObjectList.cpp in Sources */,<br>
                                2689005B13353E0400698AC0 /* ValueObjectRegister.cpp in Sources */,<br>
@@ -4704,6 +4715,7 @@<br>
                                94D0B10C16D5535900EA9C70 /* LibCxx.cpp in Sources */,<br>
                                268900C513353E5F00698AC0 /* DWARFDIECollection.cpp in Sources */,<br>
                                268900C613353E5F00698AC0 /* DWARFFormValue.cpp in Sources */,<br>
+                               233B007D1960C9F90090E598 /* ProcessInfo.cpp in Sources */,<br>
                                268900C713353E5F00698AC0 /* DWARFLocationDescription.cpp in Sources */,<br>
                                26BC17B118C7F4CB00D2196D /* ThreadElfCore.cpp in Sources */,<br>
                                268900C813353E5F00698AC0 /* DWARFLocationList.cpp in Sources */,<br>
<br>
Modified: lldb/trunk/source/Target/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CMakeLists.txt?rev=212005&r1=212004&r2=212005&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CMakeLists.txt?rev=212005&r1=212004&r2=212005&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Target/CMakeLists.txt (original)<br>
+++ lldb/trunk/source/Target/CMakeLists.txt Sun Jun 29 19:30:53 2014<br>
@@ -15,6 +15,8 @@ add_lldb_library(lldbTarget<br>
   PathMappingList.cpp<br>
   Platform.cpp<br>
   Process.cpp<br>
+  ProcessInfo.cpp<br>
+  ProcessLaunchInfo.cpp<br>
   Queue.cpp<br>
   QueueItem.cpp<br>
   QueueList.cpp<br>
<br>
Modified: lldb/trunk/source/Target/Process.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=212005&r1=212004&r2=212005&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=212005&r1=212004&r2=212005&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/source/Target/Process.cpp (original)<br>
+++ lldb/trunk/source/Target/Process.cpp Sun Jun 29 19:30:53 2014<br>
@@ -393,369 +393,6 @@ ProcessInstanceInfo::DumpAsTableRow (Str<br>
     }<br>
 }<br>
<br>
-<br>
-void<br>
-ProcessInfo::SetArguments (char const **argv, bool first_arg_is_executable)<br>
-{<br>
-    m_arguments.SetArguments (argv);<br>
-<br>
-    // Is the first argument the executable?<br>
-    if (first_arg_is_executable)<br>
-    {<br>
-        const char *first_arg = m_arguments.GetArgumentAtIndex (0);<br>
-        if (first_arg)<br>
-        {<br>
-            // Yes the first argument is an executable, set it as the executable<br>
-            // in the launch options. Don't resolve the file path as the path<br>
-            // could be a remote platform path<br>
-            const bool resolve = false;<br>
-            m_executable.SetFile(first_arg, resolve);<br>
-        }<br>
-    }<br>
-}<br>
-void<br>
-ProcessInfo::SetArguments (const Args& args, bool first_arg_is_executable)<br>
-{<br>
-    // Copy all arguments<br>
-    m_arguments = args;<br>
-<br>
-    // Is the first argument the executable?<br>
-    if (first_arg_is_executable)<br>
-    {<br>
-        const char *first_arg = m_arguments.GetArgumentAtIndex (0);<br>
-        if (first_arg)<br>
-        {<br>
-            // Yes the first argument is an executable, set it as the executable<br>
-            // in the launch options. Don't resolve the file path as the path<br>
-            // could be a remote platform path<br>
-            const bool resolve = false;<br>
-            m_executable.SetFile(first_arg, resolve);<br>
-        }<br>
-    }<br>
-}<br>
-<br>
-void<br>
-ProcessLaunchInfo::FinalizeFileActions (Target *target, bool default_to_use_pty)<br>
-{<br>
-    // If nothing for stdin or stdout or stderr was specified, then check the process for any default<br>
-    // settings that were set with "settings set"<br>
-    if (GetFileActionForFD(STDIN_FILENO) == NULL || GetFileActionForFD(STDOUT_FILENO) == NULL ||<br>
-        GetFileActionForFD(STDERR_FILENO) == NULL)<br>
-    {<br>
-        if (m_flags.Test(eLaunchFlagDisableSTDIO))<br>
-        {<br>
-            AppendSuppressFileAction (STDIN_FILENO , true, false);<br>
-            AppendSuppressFileAction (STDOUT_FILENO, false, true);<br>
-            AppendSuppressFileAction (STDERR_FILENO, false, true);<br>
-        }<br>
-        else<br>
-        {<br>
-            // Check for any values that might have gotten set with any of:<br>
-            // (lldb) settings set target.input-path<br>
-            // (lldb) settings set target.output-path<br>
-            // (lldb) settings set target.error-path<br>
-            FileSpec in_path;<br>
-            FileSpec out_path;<br>
-            FileSpec err_path;<br>
-            if (target)<br>
-            {<br>
-                in_path = target->GetStandardInputPath();<br>
-                out_path = target->GetStandardOutputPath();<br>
-                err_path = target->GetStandardErrorPath();<br>
-            }<br>
-<br>
-            char path[PATH_MAX];<br>
-            if (in_path && in_path.GetPath(path, sizeof(path)))<br>
-                AppendOpenFileAction(STDIN_FILENO, path, true, false);<br>
-<br>
-            if (out_path && out_path.GetPath(path, sizeof(path)))<br>
-                AppendOpenFileAction(STDOUT_FILENO, path, false, true);<br>
-<br>
-            if (err_path && err_path.GetPath(path, sizeof(path)))<br>
-                AppendOpenFileAction(STDERR_FILENO, path, false, true);<br>
-<br>
-            if (default_to_use_pty && (!in_path || !out_path || !err_path)) {<br>
-                if (m_pty.OpenFirstAvailableMaster(O_RDWR| O_NOCTTY, NULL, 0)) {<br>
-                    const char *slave_path = m_pty.GetSlaveName(NULL, 0);<br>
-<br>
-                    if (!in_path) {<br>
-                        AppendOpenFileAction(STDIN_FILENO, slave_path, true, false);<br>
-                    }<br>
-<br>
-                    if (!out_path) {<br>
-                        AppendOpenFileAction(STDOUT_FILENO, slave_path, false, true);<br>
-                    }<br>
-<br>
-                    if (!err_path) {<br>
-                        AppendOpenFileAction(STDERR_FILENO, slave_path, false, true);<br>
-                    }<br>
-                }<br>
-            }<br>
-        }<br>
-    }<br>
-}<br>
-<br>
-<br>
-bool<br>
-ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell (Error &error,<br>
-                                                        bool localhost,<br>
-                                                        bool will_debug,<br>
-                                                        bool first_arg_is_full_shell_command,<br>
-                                                        int32_t num_resumes)<br>
-{<br>
-    error.Clear();<br>
-<br>
-    if (GetFlags().Test (eLaunchFlagLaunchInShell))<br>
-    {<br>
-        const char *shell_executable = GetShell();<br>
-        if (shell_executable)<br>
-        {<br>
-            char shell_resolved_path[PATH_MAX];<br>
-<br>
-            if (localhost)<br>
-            {<br>
-                FileSpec shell_filespec (shell_executable, true);<br>
-<br>
-                if (!shell_filespec.Exists())<br>
-                {<br>
-                    // Resolve the path in case we just got "bash", "sh" or "tcsh"<br>
-                    if (!shell_filespec.ResolveExecutableLocation ())<br>
-                    {<br>
-                        error.SetErrorStringWithFormat("invalid shell path '%s'", shell_executable);<br>
-                        return false;<br>
-                    }<br>
-                }<br>
-                shell_filespec.GetPath (shell_resolved_path, sizeof(shell_resolved_path));<br>
-                shell_executable = shell_resolved_path;<br>
-            }<br>
-<br>
-            const char **argv = GetArguments().GetConstArgumentVector ();<br>
-            if (argv == NULL || argv[0] == NULL)<br>
-                return false;<br>
-            Args shell_arguments;<br>
-            std::string safe_arg;<br>
-            shell_arguments.AppendArgument (shell_executable);<br>
-            shell_arguments.AppendArgument ("-c");<br>
-            StreamString shell_command;<br>
-            if (will_debug)<br>
-            {<br>
-                // Add a modified PATH environment variable in case argv[0]<br>
-                // is a relative path<br>
-                const char *argv0 = argv[0];<br>
-                if (argv0 && (argv0[0] != '/' && argv0[0] != '~'))<br>
-                {<br>
-                    // We have a relative path to our executable which may not work if<br>
-                    // we just try to run "a.out" (without it being converted to "./a.out")<br>
-                    const char *working_dir = GetWorkingDirectory();<br>
-                    // Be sure to put quotes around PATH's value in case any paths have spaces...<br>
-                    std::string new_path("PATH=\"");<br>
-                    const size_t empty_path_len = new_path.size();<br>
-<br>
-                    if (working_dir && working_dir[0])<br>
-                    {<br>
-                        new_path += working_dir;<br>
-                    }<br>
-                    else<br>
-                    {<br>
-                        char current_working_dir[PATH_MAX];<br>
-                        const char *cwd = getcwd(current_working_dir, sizeof(current_working_dir));<br>
-                        if (cwd && cwd[0])<br>
-                            new_path += cwd;<br>
-                    }<br>
-                    const char *curr_path = getenv("PATH");<br>
-                    if (curr_path)<br>
-                    {<br>
-                        if (new_path.size() > empty_path_len)<br>
-                            new_path += ':';<br>
-                        new_path += curr_path;<br>
-                    }<br>
-                    new_path += "\" ";<br>
-                    shell_command.PutCString(new_path.c_str());<br>
-                }<br>
-<br>
-                shell_command.PutCString ("exec");<br>
-<br>
-                // Only Apple supports /usr/bin/arch being able to specify the architecture<br>
-                if (GetArchitecture().IsValid())<br>
-                {<br>
-                    shell_command.Printf(" /usr/bin/arch -arch %s", GetArchitecture().GetArchitectureName());<br>
-                    // Set the resume count to 2:<br>
-                    // 1 - stop in shell<br>
-                    // 2 - stop in /usr/bin/arch<br>
-                    // 3 - then we will stop in our program<br>
-                    SetResumeCount(num_resumes + 1);<br>
-                }<br>
-                else<br>
-                {<br>
-                    // Set the resume count to 1:<br>
-                    // 1 - stop in shell<br>
-                    // 2 - then we will stop in our program<br>
-                    SetResumeCount(num_resumes);<br>
-                }<br>
-            }<br>
-<br>
-            if (first_arg_is_full_shell_command)<br>
-            {<br>
-                // There should only be one argument that is the shell command itself to be used as is<br>
-                if (argv[0] && !argv[1])<br>
-                    shell_command.Printf("%s", argv[0]);<br>
-                else<br>
-                    return false;<br>
-            }<br>
-            else<br>
-            {<br>
-                for (size_t i=0; argv[i] != NULL; ++i)<br>
-                {<br>
-                    const char *arg = Args::GetShellSafeArgument (argv[i], safe_arg);<br>
-                    shell_command.Printf(" %s", arg);<br>
-                }<br>
-            }<br>
-            shell_arguments.AppendArgument (shell_command.GetString().c_str());<br>
-            m_executable.SetFile(shell_executable, false);<br>
-            m_arguments = shell_arguments;<br>
-            return true;<br>
-        }<br>
-        else<br>
-        {<br>
-            error.SetErrorString ("invalid shell path");<br>
-        }<br>
-    }<br>
-    else<br>
-    {<br>
-        error.SetErrorString ("not launching in shell");<br>
-    }<br>
-    return false;<br>
-}<br>
-<br>
-<br>
-bool<br>
-ProcessLaunchInfo::FileAction::Open (int fd, const char *path, bool read, bool write)<br>
-{<br>
-    if ((read || write) && fd >= 0 && path && path[0])<br>
-    {<br>
-        m_action = eFileActionOpen;<br>
-        m_fd = fd;<br>
-        if (read && write)<br>
-            m_arg = O_NOCTTY | O_CREAT | O_RDWR;<br>
-        else if (read)<br>
-            m_arg = O_NOCTTY | O_RDONLY;<br>
-        else<br>
-            m_arg = O_NOCTTY | O_CREAT | O_WRONLY;<br>
-        m_path.assign (path);<br>
-        return true;<br>
-    }<br>
-    else<br>
-    {<br>
-        Clear();<br>
-    }<br>
-    return false;<br>
-}<br>
-<br>
-bool<br>
-ProcessLaunchInfo::FileAction::Close (int fd)<br>
-{<br>
-    Clear();<br>
-    if (fd >= 0)<br>
-    {<br>
-        m_action = eFileActionClose;<br>
-        m_fd = fd;<br>
-    }<br>
-    return m_fd >= 0;<br>
-}<br>
-<br>
-<br>
-bool<br>
-ProcessLaunchInfo::FileAction::Duplicate (int fd, int dup_fd)<br>
-{<br>
-    Clear();<br>
-    if (fd >= 0 && dup_fd >= 0)<br>
-    {<br>
-        m_action = eFileActionDuplicate;<br>
-        m_fd = fd;<br>
-        m_arg = dup_fd;<br>
-    }<br>
-    return m_fd >= 0;<br>
-}<br>
-<br>
-<br>
-<br>
-#ifndef LLDB_DISABLE_POSIX<br>
-bool<br>
-ProcessLaunchInfo::FileAction::AddPosixSpawnFileAction (void *_file_actions,<br>
-                                                        const FileAction *info,<br>
-                                                        Log *log,<br>
-                                                        Error& error)<br>
-{<br>
-    if (info == NULL)<br>
-        return false;<br>
-<br>
-    posix_spawn_file_actions_t *file_actions = reinterpret_cast<posix_spawn_file_actions_t *>(_file_actions);<br>
-<br>
-    switch (info->m_action)<br>
-    {<br>
-        case eFileActionNone:<br>
-            error.Clear();<br>
-            break;<br>
-<br>
-        case eFileActionClose:<br>
-            if (info->m_fd == -1)<br>
-                error.SetErrorString ("invalid fd for posix_spawn_file_actions_addclose(...)");<br>
-            else<br>
-            {<br>
-                error.SetError (::posix_spawn_file_actions_addclose (file_actions, info->m_fd),<br>
-                                eErrorTypePOSIX);<br>
-                if (log && (error.Fail() || log))<br>
-                    error.PutToLog(log, "posix_spawn_file_actions_addclose (action=%p, fd=%i)",<br>
-                                   static_cast<void*>(file_actions), info->m_fd);<br>
-            }<br>
-            break;<br>
-<br>
-        case eFileActionDuplicate:<br>
-            if (info->m_fd == -1)<br>
-                error.SetErrorString ("invalid fd for posix_spawn_file_actions_adddup2(...)");<br>
-            else if (info->m_arg == -1)<br>
-                error.SetErrorString ("invalid duplicate fd for posix_spawn_file_actions_adddup2(...)");<br>
-            else<br>
-            {<br>
-                error.SetError (::posix_spawn_file_actions_adddup2 (file_actions, info->m_fd, info->m_arg),<br>
-                                eErrorTypePOSIX);<br>
-                if (log && (error.Fail() || log))<br>
-                    error.PutToLog(log, "posix_spawn_file_actions_adddup2 (action=%p, fd=%i, dup_fd=%i)",<br>
-                                   static_cast<void*>(file_actions), info->m_fd,<br>
-                                   info->m_arg);<br>
-            }<br>
-            break;<br>
-<br>
-        case eFileActionOpen:<br>
-            if (info->m_fd == -1)<br>
-                error.SetErrorString ("invalid fd in posix_spawn_file_actions_addopen(...)");<br>
-            else<br>
-            {<br>
-                int oflag = info->m_arg;<br>
-<br>
-                mode_t mode = 0;<br>
-<br>
-                if (oflag & O_CREAT)<br>
-                    mode = 0640;<br>
-<br>
-                error.SetError (::posix_spawn_file_actions_addopen (file_actions,<br>
-                                                                    info->m_fd,<br>
-                                                                    info->m_path.c_str(),<br>
-                                                                    oflag,<br>
-                                                                    mode),<br>
-                                eErrorTypePOSIX);<br>
-                if (error.Fail() || log)<br>
-                    error.PutToLog(log,<br>
-                                   "posix_spawn_file_actions_addopen (action=%p, fd=%i, path='%s', oflag=%i, mode=%i)",<br>
-                                   static_cast<void*>(file_actions), info->m_fd,<br>
-                                   info->m_path.c_str(), oflag, mode);<br>
-            }<br>
-            break;<br>
-    }<br>
-    return error.Success();<br>
-}<br>
-#endif<br>
-<br>
 Error<br>
 ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)<br>
 {<br>
<br>
Added: lldb/trunk/source/Target/ProcessInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessInfo.cpp?rev=212005&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessInfo.cpp?rev=212005&view=auto</a><br>

==============================================================================<br>
--- lldb/trunk/source/Target/ProcessInfo.cpp (added)<br>
+++ lldb/trunk/source/Target/ProcessInfo.cpp Sun Jun 29 19:30:53 2014<br>
@@ -0,0 +1,138 @@<br>
+//===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "lldb/Target/ProcessInfo.h"<br>
+<br>
+// C Includes<br>
+#include <limits.h><br>
+<br>
+using namespace lldb;<br>
+using namespace lldb_private;<br>
+<br>
+ProcessInfo::ProcessInfo () :<br>
+    m_executable (),<br>
+    m_arguments (),<br>
+    m_environment (),<br>
+    m_uid (UINT32_MAX),<br>
+    m_gid (UINT32_MAX),<br>
+    m_arch(),<br>
+    m_pid (LLDB_INVALID_PROCESS_ID)<br>
+{<br>
+}<br>
+<br>
+ProcessInfo::ProcessInfo (const char *name, const ArchSpec &arch, lldb::pid_t pid) :<br>
+    m_executable (name, false),<br>
+    m_arguments (),<br>
+    m_environment(),<br>
+    m_uid (UINT32_MAX),<br>
+    m_gid (UINT32_MAX),<br>
+    m_arch (arch),<br>
+    m_pid (pid)<br>
+{<br>
+}<br>
+<br>
+void<br>
+ProcessInfo::Clear ()<br>
+{<br>
+    m_executable.Clear();<br>
+    m_arguments.Clear();<br>
+    m_environment.Clear();<br>
+    m_uid = UINT32_MAX;<br>
+    m_gid = UINT32_MAX;<br>
+    m_arch.Clear();<br>
+    m_pid = LLDB_INVALID_PROCESS_ID;<br>
+}<br>
+<br>
+const char *<br>
+ProcessInfo::GetName() const<br>
+{<br>
+    return m_executable.GetFilename().GetCString();<br>
+}<br>
+<br>
+size_t<br>
+ProcessInfo::GetNameLength() const<br>
+{<br>
+    return m_executable.GetFilename().GetLength();<br>
+}<br>
+<br>
+void<br>
+ProcessInfo::SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg)<br>
+{<br>
+    if (exe_file)<br>
+    {<br>
+        m_executable = exe_file;<br>
+        if (add_exe_file_as_first_arg)<br>
+        {<br>
+            char filename[PATH_MAX];<br>
+            if (exe_file.GetPath(filename, sizeof(filename)))<br>
+                m_arguments.InsertArgumentAtIndex (0, filename);<br>
+        }<br>
+    }<br>
+    else<br>
+    {<br>
+        m_executable.Clear();<br>
+    }<br>
+}<br>
+<br>
+const char *<br>
+ProcessInfo::GetArg0 () const<br>
+{<br>
+    if (m_arg0.empty())<br>
+        return NULL;<br>
+    return m_arg0.c_str();<br>
+}<br>
+<br>
+void<br>
+ProcessInfo::SetArg0 (const char *arg)<br>
+{<br>
+    if (arg && arg[0])<br>
+        m_arg0 = arg;<br>
+    else<br>
+        m_arg0.clear();<br>
+}<br>
+<br>
+void<br>
+ProcessInfo::SetArguments (char const **argv, bool first_arg_is_executable)<br>
+{<br>
+    m_arguments.SetArguments (argv);<br>
+<br>
+    // Is the first argument the executable?<br>
+    if (first_arg_is_executable)<br>
+    {<br>
+        const char *first_arg = m_arguments.GetArgumentAtIndex (0);<br>
+        if (first_arg)<br>
+        {<br>
+            // Yes the first argument is an executable, set it as the executable<br>
+            // in the launch options. Don't resolve the file path as the path<br>
+            // could be a remote platform path<br>
+            const bool resolve = false;<br>
+            m_executable.SetFile(first_arg, resolve);<br>
+        }<br>
+    }<br>
+}<br>
+void<br>
+ProcessInfo::SetArguments (const Args& args, bool first_arg_is_executable)<br>
+{<br>
+    // Copy all arguments<br>
+    m_arguments = args;<br>
+<br>
+    // Is the first argument the executable?<br>
+    if (first_arg_is_executable)<br>
+    {<br>
+        const char *first_arg = m_arguments.GetArgumentAtIndex (0);<br>
+        if (first_arg)<br>
+        {<br>
+            // Yes the first argument is an executable, set it as the executable<br>
+            // in the launch options. Don't resolve the file path as the path<br>
+            // could be a remote platform path<br>
+            const bool resolve = false;<br>
+            m_executable.SetFile(first_arg, resolve);<br>
+        }<br>
+    }<br>
+}<br>
<br>
Added: lldb/trunk/source/Target/ProcessLaunchInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessLaunchInfo.cpp?rev=212005&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessLaunchInfo.cpp?rev=212005&view=auto</a><br>

==============================================================================<br>
--- lldb/trunk/source/Target/ProcessLaunchInfo.cpp (added)<br>
+++ lldb/trunk/source/Target/ProcessLaunchInfo.cpp Sun Jun 29 19:30:53 2014<br>
@@ -0,0 +1,617 @@<br>
+//===-- ProcessLaunchInfo.cpp -----------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "lldb/Target/ProcessLaunchInfo.h"<br>
+<br>
+#ifndef LLDB_DISABLE_POSIX<br>
+#include <spawn.h><br>
+#endif<br>
+<br>
+#include "lldb/Target/Target.h"<br>
+<br>
+using namespace lldb;<br>
+using namespace lldb_private;<br>
+<br>
+//----------------------------------------------------------------------------<br>
+// ProcessLaunchInfo::FileAction member functions<br>
+//----------------------------------------------------------------------------<br>
+<br>
+ProcessLaunchInfo::FileAction::FileAction () :<br>
+    m_action (eFileActionNone),<br>
+    m_fd (-1),<br>
+    m_arg (-1),<br>
+    m_path ()<br>
+{<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::FileAction::Clear()<br>
+{<br>
+    m_action = eFileActionNone;<br>
+    m_fd = -1;<br>
+    m_arg = -1;<br>
+    m_path.clear();<br>
+}<br>
+<br>
+const char *<br>
+ProcessLaunchInfo::FileAction::GetPath () const<br>
+{<br>
+    if (m_path.empty())<br>
+        return NULL;<br>
+    return m_path.c_str();<br>
+}<br>
+<br>
+//----------------------------------------------------------------------------<br>
+// ProcessLaunchInfo member functions<br>
+//----------------------------------------------------------------------------<br>
+<br>
+ProcessLaunchInfo::ProcessLaunchInfo () :<br>
+    ProcessInfo(),<br>
+    m_working_dir (),<br>
+    m_plugin_name (),<br>
+    m_shell (),<br>
+    m_flags (0),<br>
+    m_file_actions (),<br>
+    m_pty (),<br>
+    m_resume_count (0),<br>
+    m_monitor_callback (NULL),<br>
+    m_monitor_callback_baton (NULL),<br>
+    m_monitor_signals (false),<br>
+    m_hijack_listener_sp ()<br>
+{<br>
+}<br>
+<br>
+ProcessLaunchInfo::ProcessLaunchInfo (<br>
+                                      const char *stdin_path,<br>
+                                      const char *stdout_path,<br>
+                                      const char *stderr_path,<br>
+                                      const char *working_directory,<br>
+                                      uint32_t launch_flags) :<br>
+    ProcessInfo(),<br>
+    m_working_dir (),<br>
+    m_plugin_name (),<br>
+    m_shell (),<br>
+    m_flags (launch_flags),<br>
+    m_file_actions (),<br>
+    m_pty (),<br>
+    m_resume_count (0),<br>
+    m_monitor_callback (NULL),<br>
+    m_monitor_callback_baton (NULL),<br>
+    m_monitor_signals (false),<br>
+    m_hijack_listener_sp ()<br>
+{<br>
+    if (stdin_path)<br>
+    {<br>
+        ProcessLaunchInfo::FileAction file_action;<br>
+        const bool read = true;<br>
+        const bool write = false;<br>
+        if (file_action.Open(STDIN_FILENO, stdin_path, read, write))<br>
+            AppendFileAction (file_action);<br>
+    }<br>
+    if (stdout_path)<br>
+    {<br>
+        ProcessLaunchInfo::FileAction file_action;<br>
+        const bool read = false;<br>
+        const bool write = true;<br>
+        if (file_action.Open(STDOUT_FILENO, stdout_path, read, write))<br>
+            AppendFileAction (file_action);<br>
+    }<br>
+    if (stderr_path)<br>
+    {<br>
+        ProcessLaunchInfo::FileAction file_action;<br>
+        const bool read = false;<br>
+        const bool write = true;<br>
+        if (file_action.Open(STDERR_FILENO, stderr_path, read, write))<br>
+            AppendFileAction (file_action);<br>
+    }<br>
+    if (working_directory)<br>
+        SetWorkingDirectory(working_directory);<br>
+}<br>
+<br>
+bool<br>
+ProcessLaunchInfo::AppendCloseFileAction (int fd)<br>
+{<br>
+    FileAction file_action;<br>
+    if (file_action.Close (fd))<br>
+    {<br>
+        AppendFileAction (file_action);<br>
+        return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+ProcessLaunchInfo::AppendDuplicateFileAction (int fd, int dup_fd)<br>
+{<br>
+    FileAction file_action;<br>
+    if (file_action.Duplicate (fd, dup_fd))<br>
+    {<br>
+        AppendFileAction (file_action);<br>
+        return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+ProcessLaunchInfo::AppendOpenFileAction (int fd, const char *path, bool read, bool write)<br>
+{<br>
+    FileAction file_action;<br>
+    if (file_action.Open (fd, path, read, write))<br>
+    {<br>
+        AppendFileAction (file_action);<br>
+        return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+ProcessLaunchInfo::AppendSuppressFileAction (int fd, bool read, bool write)<br>
+{<br>
+    FileAction file_action;<br>
+    if (file_action.Open (fd, "/dev/null", read, write))<br>
+    {<br>
+        AppendFileAction (file_action);<br>
+        return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+const ProcessLaunchInfo::FileAction *<br>
+ProcessLaunchInfo::GetFileActionAtIndex (size_t idx) const<br>
+{<br>
+    if (idx < m_file_actions.size())<br>
+        return &m_file_actions[idx];<br>
+    return NULL;<br>
+}<br>
+<br>
+const ProcessLaunchInfo::FileAction *<br>
+ProcessLaunchInfo::GetFileActionForFD (int fd) const<br>
+{<br>
+    for (size_t idx=0, count=m_file_actions.size(); idx < count; ++idx)<br>
+    {<br>
+        if (m_file_actions[idx].GetFD () == fd)<br>
+            return &m_file_actions[idx];<br>
+    }<br>
+    return NULL;<br>
+}<br>
+<br>
+const char *<br>
+ProcessLaunchInfo::GetWorkingDirectory () const<br>
+{<br>
+    if (m_working_dir.empty())<br>
+        return NULL;<br>
+    return m_working_dir.c_str();<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::SetWorkingDirectory (const char *working_dir)<br>
+{<br>
+    if (working_dir && working_dir[0])<br>
+        m_working_dir.assign (working_dir);<br>
+    else<br>
+        m_working_dir.clear();<br>
+}<br>
+<br>
+const char *<br>
+ProcessLaunchInfo::GetProcessPluginName () const<br>
+{<br>
+    if (m_plugin_name.empty())<br>
+        return NULL;<br>
+    return m_plugin_name.c_str();<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::SetProcessPluginName (const char *plugin)<br>
+{<br>
+    if (plugin && plugin[0])<br>
+        m_plugin_name.assign (plugin);<br>
+    else<br>
+        m_plugin_name.clear();<br>
+}<br>
+<br>
+const char *<br>
+ProcessLaunchInfo::GetShell () const<br>
+{<br>
+    if (m_shell.empty())<br>
+        return NULL;<br>
+    return m_shell.c_str();<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::SetShell (const char * path)<br>
+{<br>
+    if (path && path[0])<br>
+    {<br>
+        m_shell.assign (path);<br>
+        m_flags.Set (lldb::eLaunchFlagLaunchInShell);<br>
+    }<br>
+    else<br>
+    {<br>
+        m_shell.clear();<br>
+        m_flags.Clear (lldb::eLaunchFlagLaunchInShell);<br>
+    }<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::SetLaunchInSeparateProcessGroup (bool separate)<br>
+{<br>
+    if (separate)<br>
+        m_flags.Set(lldb::eLaunchFlagLaunchInSeparateProcessGroup);<br>
+    else<br>
+        m_flags.Clear (lldb::eLaunchFlagLaunchInSeparateProcessGroup);<br>
+<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::Clear ()<br>
+{<br>
+    ProcessInfo::Clear();<br>
+    m_working_dir.clear();<br>
+    m_plugin_name.clear();<br>
+    m_shell.clear();<br>
+    m_flags.Clear();<br>
+    m_file_actions.clear();<br>
+    m_resume_count = 0;<br>
+    m_hijack_listener_sp.reset();<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback,<br>
+                           void *baton,<br>
+                           bool monitor_signals)<br>
+{<br>
+    m_monitor_callback = callback;<br>
+    m_monitor_callback_baton = baton;<br>
+    m_monitor_signals = monitor_signals;<br>
+}<br>
+<br>
+bool<br>
+ProcessLaunchInfo::MonitorProcess () const<br>
+{<br>
+    if (m_monitor_callback && ProcessIDIsValid())<br>
+    {<br>
+        Host::StartMonitoringChildProcess (m_monitor_callback,<br>
+                                           m_monitor_callback_baton,<br>
+                                           GetProcessID(),<br>
+                                           m_monitor_signals);<br>
+        return true;<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::SetDetachOnError (bool enable)<br>
+{<br>
+    if (enable)<br>
+        m_flags.Set(lldb::eLaunchFlagDetachOnError);<br>
+    else<br>
+        m_flags.Clear(lldb::eLaunchFlagDetachOnError);<br>
+}<br>
+<br>
+void<br>
+ProcessLaunchInfo::FinalizeFileActions (Target *target, bool default_to_use_pty)<br>
+{<br>
+    // If nothing for stdin or stdout or stderr was specified, then check the process for any default<br>
+    // settings that were set with "settings set"<br>
+    if (GetFileActionForFD(STDIN_FILENO) == NULL || GetFileActionForFD(STDOUT_FILENO) == NULL ||<br>
+        GetFileActionForFD(STDERR_FILENO) == NULL)<br>
+    {<br>
+        if (m_flags.Test(eLaunchFlagDisableSTDIO))<br>
+        {<br>
+            AppendSuppressFileAction (STDIN_FILENO , true, false);<br>
+            AppendSuppressFileAction (STDOUT_FILENO, false, true);<br>
+            AppendSuppressFileAction (STDERR_FILENO, false, true);<br>
+        }<br>
+        else<br>
+        {<br>
+            // Check for any values that might have gotten set with any of:<br>
+            // (lldb) settings set target.input-path<br>
+            // (lldb) settings set target.output-path<br>
+            // (lldb) settings set target.error-path<br>
+            FileSpec in_path;<br>
+            FileSpec out_path;<br>
+            FileSpec err_path;<br>
+            if (target)<br>
+            {<br>
+                in_path = target->GetStandardInputPath();<br>
+                out_path = target->GetStandardOutputPath();<br>
+                err_path = target->GetStandardErrorPath();<br>
+            }<br>
+<br>
+            char path[PATH_MAX];<br>
+            if (in_path && in_path.GetPath(path, sizeof(path)))<br>
+                AppendOpenFileAction(STDIN_FILENO, path, true, false);<br>
+<br>
+            if (out_path && out_path.GetPath(path, sizeof(path)))<br>
+                AppendOpenFileAction(STDOUT_FILENO, path, false, true);<br>
+<br>
+            if (err_path && err_path.GetPath(path, sizeof(path)))<br>
+                AppendOpenFileAction(STDERR_FILENO, path, false, true);<br>
+<br>
+            if (default_to_use_pty && (!in_path || !out_path || !err_path)) {<br>
+                if (m_pty.OpenFirstAvailableMaster(O_RDWR| O_NOCTTY, NULL, 0)) {<br>
+                    const char *slave_path = m_pty.GetSlaveName(NULL, 0);<br>
+<br>
+                    if (!in_path) {<br>
+                        AppendOpenFileAction(STDIN_FILENO, slave_path, true, false);<br>
+                    }<br>
+<br>
+                    if (!out_path) {<br>
+                        AppendOpenFileAction(STDOUT_FILENO, slave_path, false, true);<br>
+                    }<br>
+<br>
+                    if (!err_path) {<br>
+                        AppendOpenFileAction(STDERR_FILENO, slave_path, false, true);<br>
+                    }<br>
+                }<br>
+            }<br>
+        }<br>
+    }<br>
+}<br>
+<br>
+<br>
+bool<br>
+ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell (Error &error,<br>
+                                                        bool localhost,<br>
+                                                        bool will_debug,<br>
+                                                        bool first_arg_is_full_shell_command,<br>
+                                                        int32_t num_resumes)<br>
+{<br>
+    error.Clear();<br>
+<br>
+    if (GetFlags().Test (eLaunchFlagLaunchInShell))<br>
+    {<br>
+        const char *shell_executable = GetShell();<br>
+        if (shell_executable)<br>
+        {<br>
+            char shell_resolved_path[PATH_MAX];<br>
+<br>
+            if (localhost)<br>
+            {<br>
+                FileSpec shell_filespec (shell_executable, true);<br>
+<br>
+                if (!shell_filespec.Exists())<br>
+                {<br>
+                    // Resolve the path in case we just got "bash", "sh" or "tcsh"<br>
+                    if (!shell_filespec.ResolveExecutableLocation ())<br>
+                    {<br>
+                        error.SetErrorStringWithFormat("invalid shell path '%s'", shell_executable);<br>
+                        return false;<br>
+                    }<br>
+                }<br>
+                shell_filespec.GetPath (shell_resolved_path, sizeof(shell_resolved_path));<br>
+                shell_executable = shell_resolved_path;<br>
+            }<br>
+<br>
+            const char **argv = GetArguments().GetConstArgumentVector ();<br>
+            if (argv == NULL || argv[0] == NULL)<br>
+                return false;<br>
+            Args shell_arguments;<br>
+            std::string safe_arg;<br>
+            shell_arguments.AppendArgument (shell_executable);<br>
+            shell_arguments.AppendArgument ("-c");<br>
+            StreamString shell_command;<br>
+            if (will_debug)<br>
+            {<br>
+                // Add a modified PATH environment variable in case argv[0]<br>
+                // is a relative path<br>
+                const char *argv0 = argv[0];<br>
+                if (argv0 && (argv0[0] != '/' && argv0[0] != '~'))<br>
+                {<br>
+                    // We have a relative path to our executable which may not work if<br>
+                    // we just try to run "a.out" (without it being converted to "./a.out")<br>
+                    const char *working_dir = GetWorkingDirectory();<br>
+                    // Be sure to put quotes around PATH's value in case any paths have spaces...<br>
+                    std::string new_path("PATH=\"");<br>
+                    const size_t empty_path_len = new_path.size();<br>
+<br>
+                    if (working_dir && working_dir[0])<br>
+                    {<br>
+                        new_path += working_dir;<br>
+                    }<br>
+                    else<br>
+                    {<br>
+                        char current_working_dir[PATH_MAX];<br>
+                        const char *cwd = getcwd(current_working_dir, sizeof(current_working_dir));<br>
+                        if (cwd && cwd[0])<br>
+                            new_path += cwd;<br>
+                    }<br>
+                    const char *curr_path = getenv("PATH");<br>
+                    if (curr_path)<br>
+                    {<br>
+                        if (new_path.size() > empty_path_len)<br>
+                            new_path += ':';<br>
+                        new_path += curr_path;<br>
+                    }<br>
+                    new_path += "\" ";<br>
+                    shell_command.PutCString(new_path.c_str());<br>
+                }<br>
+<br>
+                shell_command.PutCString ("exec");<br>
+<br>
+                // Only Apple supports /usr/bin/arch being able to specify the architecture<br>
+                if (GetArchitecture().IsValid())<br>
+                {<br>
+                    shell_command.Printf(" /usr/bin/arch -arch %s", GetArchitecture().GetArchitectureName());<br>
+                    // Set the resume count to 2:<br>
+                    // 1 - stop in shell<br>
+                    // 2 - stop in /usr/bin/arch<br>
+                    // 3 - then we will stop in our program<br>
+                    SetResumeCount(num_resumes + 1);<br>
+                }<br>
+                else<br>
+                {<br>
+                    // Set the resume count to 1:<br>
+                    // 1 - stop in shell<br>
+                    // 2 - then we will stop in our program<br>
+                    SetResumeCount(num_resumes);<br>
+                }<br>
+            }<br>
+<br>
+            if (first_arg_is_full_shell_command)<br>
+            {<br>
+                // There should only be one argument that is the shell command itself to be used as is<br>
+                if (argv[0] && !argv[1])<br>
+                    shell_command.Printf("%s", argv[0]);<br>
+                else<br>
+                    return false;<br>
+            }<br>
+            else<br>
+            {<br>
+                for (size_t i=0; argv[i] != NULL; ++i)<br>
+                {<br>
+                    const char *arg = Args::GetShellSafeArgument (argv[i], safe_arg);<br>
+                    shell_command.Printf(" %s", arg);<br>
+                }<br>
+            }<br>
+            shell_arguments.AppendArgument (shell_command.GetString().c_str());<br>
+            m_executable.SetFile(shell_executable, false);<br>
+            m_arguments = shell_arguments;<br>
+            return true;<br>
+        }<br>
+        else<br>
+        {<br>
+            error.SetErrorString ("invalid shell path");<br>
+        }<br>
+    }<br>
+    else<br>
+    {<br>
+        error.SetErrorString ("not launching in shell");<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+<br>
+bool<br>
+ProcessLaunchInfo::FileAction::Open (int fd, const char *path, bool read, bool write)<br>
+{<br>
+    if ((read || write) && fd >= 0 && path && path[0])<br>
+    {<br>
+        m_action = eFileActionOpen;<br>
+        m_fd = fd;<br>
+        if (read && write)<br>
+            m_arg = O_NOCTTY | O_CREAT | O_RDWR;<br>
+        else if (read)<br>
+            m_arg = O_NOCTTY | O_RDONLY;<br>
+        else<br>
+            m_arg = O_NOCTTY | O_CREAT | O_WRONLY;<br>
+        m_path.assign (path);<br>
+        return true;<br>
+    }<br>
+    else<br>
+    {<br>
+        Clear();<br>
+    }<br>
+    return false;<br>
+}<br>
+<br>
+bool<br>
+ProcessLaunchInfo::FileAction::Close (int fd)<br>
+{<br>
+    Clear();<br>
+    if (fd >= 0)<br>
+    {<br>
+        m_action = eFileActionClose;<br>
+        m_fd = fd;<br>
+    }<br>
+    return m_fd >= 0;<br>
+}<br>
+<br>
+<br>
+bool<br>
+ProcessLaunchInfo::FileAction::Duplicate (int fd, int dup_fd)<br>
+{<br>
+    Clear();<br>
+    if (fd >= 0 && dup_fd >= 0)<br>
+    {<br>
+        m_action = eFileActionDuplicate;<br>
+        m_fd = fd;<br>
+        m_arg = dup_fd;<br>
+    }<br>
+    return m_fd >= 0;<br>
+}<br>
+<br>
+<br>
+<br>
+#ifndef LLDB_DISABLE_POSIX<br>
+bool<br>
+ProcessLaunchInfo::FileAction::AddPosixSpawnFileAction (void *_file_actions,<br>
+                                                        const FileAction *info,<br>
+                                                        Log *log,<br>
+                                                        Error& error)<br>
+{<br>
+    if (info == NULL)<br>
+        return false;<br>
+<br>
+    posix_spawn_file_actions_t *file_actions = reinterpret_cast<posix_spawn_file_actions_t *>(_file_actions);<br>
+<br>
+    switch (info->m_action)<br>
+    {<br>
+        case eFileActionNone:<br>
+            error.Clear();<br>
+            break;<br>
+<br>
+        case eFileActionClose:<br>
+            if (info->m_fd == -1)<br>
+                error.SetErrorString ("invalid fd for posix_spawn_file_actions_addclose(...)");<br>
+            else<br>
+            {<br>
+                error.SetError (::posix_spawn_file_actions_addclose (file_actions, info->m_fd),<br>
+                                eErrorTypePOSIX);<br>
+                if (log && (error.Fail() || log))<br>
+                    error.PutToLog(log, "posix_spawn_file_actions_addclose (action=%p, fd=%i)",<br>
+                                   static_cast<void*>(file_actions), info->m_fd);<br>
+            }<br>
+            break;<br>
+<br>
+        case eFileActionDuplicate:<br>
+            if (info->m_fd == -1)<br>
+                error.SetErrorString ("invalid fd for posix_spawn_file_actions_adddup2(...)");<br>
+            else if (info->m_arg == -1)<br>
+                error.SetErrorString ("invalid duplicate fd for posix_spawn_file_actions_adddup2(...)");<br>
+            else<br>
+            {<br>
+                error.SetError (::posix_spawn_file_actions_adddup2 (file_actions, info->m_fd, info->m_arg),<br>
+                                eErrorTypePOSIX);<br>
+                if (log && (error.Fail() || log))<br>
+                    error.PutToLog(log, "posix_spawn_file_actions_adddup2 (action=%p, fd=%i, dup_fd=%i)",<br>
+                                   static_cast<void*>(file_actions), info->m_fd,<br>
+                                   info->m_arg);<br>
+            }<br>
+            break;<br>
+<br>
+        case eFileActionOpen:<br>
+            if (info->m_fd == -1)<br>
+                error.SetErrorString ("invalid fd in posix_spawn_file_actions_addopen(...)");<br>
+            else<br>
+            {<br>
+                int oflag = info->m_arg;<br>
+<br>
+                mode_t mode = 0;<br>
+<br>
+                if (oflag & O_CREAT)<br>
+                    mode = 0640;<br>
+<br>
+                error.SetError (::posix_spawn_file_actions_addopen (file_actions,<br>
+                                                                    info->m_fd,<br>
+                                                                    info->m_path.c_str(),<br>
+                                                                    oflag,<br>
+                                                                    mode),<br>
+                                eErrorTypePOSIX);<br>
+                if (error.Fail() || log)<br>
+                    error.PutToLog(log,<br>
+                                   "posix_spawn_file_actions_addopen (action=%p, fd=%i, path='%s', oflag=%i, mode=%i)",<br>
+                                   static_cast<void*>(file_actions), info->m_fd,<br>
+                                   info->m_path.c_str(), oflag, mode);<br>
+            }<br>
+            break;<br>
+    }<br>
+    return error.Success();<br>
+}<br>
+#endif<br>
<br>
Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=212005&r1=212004&r2=212005&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=212005&r1=212004&r2=212005&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original)<br>
+++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Sun Jun 29 19:30:53 2014<br>
@@ -658,7 +658,7 @@<br>
                                CLANG_CXX_LANGUAGE_STANDARD = "c++0x";<br>
                                CLANG_CXX_LIBRARY = "libc++";<br>
                                "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist";<br>
-                "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "source/debugserver-macosx-entitlements.plist";<br>
+                               "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "source/debugserver-macosx-entitlements.plist";<br>
                                "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "-";<br>
                                "CODE_SIGN_IDENTITY[sdk=macosx*]" = "";<br>
                                COPY_PHASE_STRIP = YES;<br>
@@ -725,7 +725,7 @@<br>
                                CLANG_CXX_LANGUAGE_STANDARD = "c++0x";<br>
                                CLANG_CXX_LIBRARY = "libc++";<br>
                                "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist";<br>
-                "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "source/debugserver-macosx-entitlements.plist";<br>
+                               "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "source/debugserver-macosx-entitlements.plist";<br>
                                "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "-";<br>
                                "CODE_SIGN_IDENTITY[sdk=macosx*]" = "";<br>
                                COPY_PHASE_STRIP = YES;<br>
@@ -823,7 +823,7 @@<br>
                                CLANG_CXX_LANGUAGE_STANDARD = "c++0x";<br>
                                CLANG_CXX_LIBRARY = "libc++";<br>
                                "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist";<br>
-                "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "source/debugserver-macosx-entitlements.plist";<br>
+                               "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "source/debugserver-macosx-entitlements.plist";<br>
                                "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "-";<br>
                                "CODE_SIGN_IDENTITY[sdk=macosx*]" = "";<br>
                                COPY_PHASE_STRIP = YES;<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">-Todd</div>
</div>