Moved many of the "settings" that used to be in "target.process.*" to just
be in the target. All of the environment, args, stdin/out/err files, etc have
all been moved. Also re-enabled the ability to launch a process in a separate
terminal on MacOSX.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144061 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index 7c7762c..e2136d3 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -374,17 +374,21 @@
             Error error;
             const uint32_t argc = args.GetArgumentCount();
             Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
-            if (target)
+            if (target == NULL)
             {
-                Module *exe_module = target->GetExecutableModulePointer();
-                if (exe_module)
-                {
-                    m_options.launch_info.GetExecutableFile () = exe_module->GetFileSpec();
-                    char exe_path[PATH_MAX];
-                    if (m_options.launch_info.GetExecutableFile ().GetPath (exe_path, sizeof(exe_path)))
-                        m_options.launch_info.GetArguments().AppendArgument (exe_path);
-                    m_options.launch_info.GetArchitecture() = exe_module->GetArchitecture();
-                }
+                result.AppendError ("invalid target, create a debug target using the 'target create' command");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
+
+            Module *exe_module = target->GetExecutableModulePointer();
+            if (exe_module)
+            {
+                m_options.launch_info.GetExecutableFile () = exe_module->GetFileSpec();
+                char exe_path[PATH_MAX];
+                if (m_options.launch_info.GetExecutableFile ().GetPath (exe_path, sizeof(exe_path)))
+                    m_options.launch_info.GetArguments().AppendArgument (exe_path);
+                m_options.launch_info.GetArchitecture() = exe_module->GetArchitecture();
             }
 
             if (argc > 0)
@@ -412,21 +416,9 @@
 
                 if (argc == 0)
                 {
-                    lldb::UserSettingsControllerSP process_usc_sp (Process::GetSettingsController ());
-                    if (process_usc_sp)
-                    {
-                        SettableVariableType type;
-                        StringList settings_args (process_usc_sp->GetVariable ("process.run-args", 
-                                                                               type,
-                                                                               m_interpreter.GetDebugger().GetInstanceName().GetCString(),
-                                                                               error));
-                        if (error.Success())
-                        {
-                            const size_t num_settings_args = settings_args.GetSize();
-                            for (size_t i=0; i<num_settings_args; ++i)
-                                m_options.launch_info.GetArguments().AppendArgument (settings_args.GetStringAtIndex(i));
-                        }
-                    }
+                    const Args &target_settings_args = target->GetRunArguments();
+                    if (target_settings_args.GetArgumentCount())
+                        m_options.launch_info.GetArguments() = target_settings_args;
                 }
 
                 ProcessSP process_sp (platform_sp->DebugProcess (m_options.launch_info, 
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 2c8a0dd..ae6984e 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -151,7 +151,9 @@
     bool
     Execute (Args& launch_args, CommandReturnObject &result)
     {
-        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        Debugger &debugger = m_interpreter.GetDebugger();
+        Target *target = debugger.GetSelectedTarget().get();
+        Error error;
 
         if (target == NULL)
         {
@@ -159,7 +161,6 @@
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
-
         // If our listener is NULL, users aren't allows to launch
         char filename[PATH_MAX];
         const Module *exe_module = target->GetExecutableModulePointer();
@@ -197,25 +198,102 @@
                 }
                 else
                 {
-                    Error error (process->Destroy());
-                    if (error.Success())
+                    Error destroy_error (process->Destroy());
+                    if (destroy_error.Success())
                     {
                         result.SetStatus (eReturnStatusSuccessFinishResult);
                     }
                     else
                     {
-                        result.AppendErrorWithFormat ("Failed to kill process: %s\n", error.AsCString());
+                        result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
                         result.SetStatus (eReturnStatusFailed);
                     }
                 }
             }
         }
         
-        if (state != eStateConnected)
+        if (launch_args.GetArgumentCount() > 0)
+        {
+            m_options.launch_info.GetArguments().AppendArguments (launch_args);
+        }
+
+        
+        if (state == eStateConnected)
+        {
+            if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
+            {
+                result.AppendWarning("can't launch in tty when launching through a remote connection");
+                m_options.launch_info.GetFlags().Clear (eLaunchFlagLaunchInTTY);
+            }
+        }
+        else
         {
             const char *plugin_name = m_options.launch_info.GetProcessPluginName();
 
-            process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name).get();
+            if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
+            {
+                process = target->GetPlatform()->DebugProcess (m_options.launch_info, 
+                                                               debugger,
+                                                               target,
+                                                               debugger.GetListener(),
+                                                               error).get();
+            }
+            else
+            {
+                process = target->CreateProcess (debugger.GetListener(), plugin_name).get();
+        
+                if (launch_args.GetArgumentCount() == 0)
+                {
+                    const Args &process_args = target->GetRunArguments();
+                    if (process_args.GetArgumentCount() > 0)
+                        m_options.launch_info.GetArguments().AppendArguments (process_args);
+                }
+
+                Args environment;
+                target->GetEnvironmentAsArgs (environment);
+                m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
+                
+                if (target->GetDisableASLR())
+                    m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
+
+                if (m_options.launch_info.GetNumFileActions() == 0)
+                {
+                    // Only use the settings value if the user hasn't specified any options that would override it.
+                    if (target->GetDisableSTDIO())
+                        m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO);
+                    
+                    const char *path;
+                    path = target->GetStandardErrorPath();
+                    if (path)
+                    {
+                        ProcessLaunchInfo::FileAction file_action;
+                        const bool read = true;
+                        const bool write = true;
+                        if (file_action.Open(STDERR_FILENO, path, read, write))
+                            m_options.launch_info.AppendFileAction (file_action);
+                    }
+                    path = target->GetStandardInputPath();
+                    if (path)
+                    {
+                        ProcessLaunchInfo::FileAction file_action;
+                        const bool read = true;
+                        const bool write = false;
+                        if (file_action.Open(STDIN_FILENO, path, read, write))
+                            m_options.launch_info.AppendFileAction (file_action);
+                    }
+
+                    path = target->GetStandardOutputPath();
+                    if (path)
+                    {
+                        ProcessLaunchInfo::FileAction file_action;
+                        const bool read = false;
+                        const bool write = true;
+                        if (file_action.Open(STDOUT_FILENO, path, read, write))
+                            m_options.launch_info.AppendFileAction (file_action);
+                    }
+                }
+                error = process->Launch (m_options.launch_info);
+            }
             if (process == NULL)
             {
                 result.AppendErrorWithFormat ("Failed to find a process plugin for executable.\n");
@@ -223,76 +301,7 @@
                 return false;
             }
         }
-
-        if (launch_args.GetArgumentCount() > 0)
-        {
-            m_options.launch_info.GetArguments().AppendArguments (launch_args);
-        }
-        else
-        {
-            const Args &process_args = process->GetRunArguments();
-            if (process_args.GetArgumentCount() > 0)
-                m_options.launch_info.GetArguments().AppendArguments (process_args);
-        }
-        
-
-        if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
-        {
-            if (state == eStateConnected)
-            {
-                result.AppendWarning("launch in tty option is ignored when launching through a remote connection");
-                m_options.launch_info.GetFlags().Clear (eLaunchFlagLaunchInTTY);
-            }
-        }
-
-        Args environment;
-        process->GetEnvironmentAsArgs (environment);
-        m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
-        
-        if (process->GetDisableASLR())
-            m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
-
-        if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY) == false &&
-            m_options.launch_info.GetNumFileActions() == 0)
-        {
-            // Only use the settings value if the user hasn't specified any options that would override it.
-            if (process->GetDisableSTDIO())
-                m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO);
-            
-            const char *path;
-            path = process->GetStandardErrorPath();
-            if (path)
-            {
-                ProcessLaunchInfo::FileAction file_action;
-                const bool read = true;
-                const bool write = true;
-                if (file_action.Open(STDERR_FILENO, path, read, write))
-                    m_options.launch_info.AppendFileAction (file_action);
-            }
-            path = process->GetStandardInputPath();
-            if (path)
-            {
-                ProcessLaunchInfo::FileAction file_action;
-                const bool read = true;
-                const bool write = false;
-                if (file_action.Open(STDIN_FILENO, path, read, write))
-                    m_options.launch_info.AppendFileAction (file_action);
-            }
-
-            path = process->GetStandardOutputPath();
-            if (path)
-            {
-                ProcessLaunchInfo::FileAction file_action;
-                const bool read = false;
-                const bool write = true;
-                if (file_action.Open(STDOUT_FILENO, path, read, write))
-                    m_options.launch_info.AppendFileAction (file_action);
-            }
-        }
-        Error error;
-
-        error = process->Launch (m_options.launch_info);
-                     
+             
         if (error.Success())
         {
             const char *archname = exe_module->GetArchitecture().GetArchitectureName();
diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp
index 2421af5..63f5048 100644
--- a/source/Commands/CommandObjectSettings.cpp
+++ b/source/Commands/CommandObjectSettings.cpp
@@ -83,14 +83,14 @@
 "When setting a dictionary or array variable, you can set multiple entries \n\
 at once by giving the values to the set command.  For example: \n\
 \n\
-(lldb) settings set target.process.run-args value1  value2 value3 \n\
-(lldb) settings set target.process.env-vars [\"MYPATH\"]=~/.:/usr/bin  [\"SOME_ENV_VAR\"]=12345 \n\
+(lldb) settings set target.run-args value1  value2 value3 \n\
+(lldb) settings set target.env-vars [\"MYPATH\"]=~/.:/usr/bin  [\"SOME_ENV_VAR\"]=12345 \n\
 \n\
-(lldb) settings show target.process.run-args \n\
+(lldb) settings show target.run-args \n\
   [0]: 'value1' \n\
   [1]: 'value2' \n\
   [3]: 'value3' \n\
-(lldb) settings show target.process.env-vars \n\
+(lldb) settings show target.env-vars \n\
   'MYPATH=~/.:/usr/bin'\n\
   'SOME_ENV_VAR=12345' \n\
 \n\