Author: hanming
Date: Mon Feb 10 13:23:28 2014
New Revision: 201103

URL: http://llvm.org/viewvc/llvm-project?rev=201103&view=rev
Log:
<rdar://problem/15996848>

Made sure we pass along the file action paths for stdin/stdout/stderr to the 
XPC service.
[Reviewed by Greg Clayton]

Modified:
    lldb/trunk/source/Host/macosx/Host.mm
    lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.h
    lldb/trunk/source/Host/macosx/launcherXPCService/main.mm

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=201103&r1=201102&r2=201103&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Mon Feb 10 13:23:28 2014
@@ -1499,6 +1499,21 @@ LaunchProcessXPC (const char *exe_path,
     // Posix spawn stuff.
     xpc_dictionary_set_int64(message, LauncherXPCServiceCPUTypeKey, 
launch_info.GetArchitecture().GetMachOCPUType());
     xpc_dictionary_set_int64(message, LauncherXPCServicePosixspawnFlagsKey, 
Host::GetPosixspawnFlags(launch_info));
+    const ProcessLaunchInfo::FileAction *file_action = 
launch_info.GetFileActionForFD(STDIN_FILENO);
+    if (file_action && file_action->GetPath())
+    {
+        xpc_dictionary_set_string(message, LauncherXPCServiceStdInPathKeyKey, 
file_action->GetPath());
+    }
+    file_action = launch_info.GetFileActionForFD(STDOUT_FILENO);
+    if (file_action && file_action->GetPath())
+    {
+        xpc_dictionary_set_string(message, LauncherXPCServiceStdOutPathKeyKey, 
file_action->GetPath());
+    }
+    file_action = launch_info.GetFileActionForFD(STDERR_FILENO);
+    if (file_action && file_action->GetPath())
+    {
+        xpc_dictionary_set_string(message, LauncherXPCServiceStdErrPathKeyKey, 
file_action->GetPath());
+    }
     
     xpc_object_t reply = xpc_connection_send_message_with_reply_sync(conn, 
message);
     xpc_type_t returnType = xpc_get_type(reply);

Modified: lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.h?rev=201103&r1=201102&r2=201103&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.h 
(original)
+++ lldb/trunk/source/Host/macosx/launcherXPCService/LauncherXPCService.h Mon 
Feb 10 13:23:28 2014
@@ -9,6 +9,9 @@
 #define LauncherXPCServiceEnvPrefxKey           "env"
 #define LauncherXPCServiceCPUTypeKey            "cpuType"
 #define LauncherXPCServicePosixspawnFlagsKey    "posixspawnFlags"
+#define LauncherXPCServiceStdInPathKeyKey       "stdInPath"
+#define LauncherXPCServiceStdOutPathKeyKey      "stdOutPath"
+#define LauncherXPCServiceStdErrPathKeyKey      "stdErrPath"
 #define LauncherXPCServiceChildPIDKey           "childPID"
 #define LauncherXPCServiceErrorTypeKey          "errorType"
 #define LauncherXPCServiceCodeTypeKey           "errorCode"

Modified: lldb/trunk/source/Host/macosx/launcherXPCService/main.mm
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/launcherXPCService/main.mm?rev=201103&r1=201102&r2=201103&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/launcherXPCService/main.mm (original)
+++ lldb/trunk/source/Host/macosx/launcherXPCService/main.mm Mon Feb 10 
13:23:28 2014
@@ -52,17 +52,44 @@ int _setup_posixspawn_attributes_file_ac
     if (errorCode)
         return errorCode;
     
-    // Setup any file actions. Here we are emulating what debugserver would do 
normally in Host.mm since the XPC service meant only for debugserver.
+    // Setup any file actions.
     errorCode = posix_spawn_file_actions_init(file_actions);
     if (errorCode)
         return errorCode;
-    errorCode = posix_spawn_file_actions_addclose(file_actions, STDIN_FILENO);
+    
+    const char *path = xpc_dictionary_get_string(message, 
LauncherXPCServiceStdInPathKeyKey);
+    if (path)
+    {
+        errorCode = posix_spawn_file_actions_addopen(file_actions, 
STDIN_FILENO, path, O_NOCTTY | O_RDONLY, 0);
+    }
+    else
+    {
+        errorCode = posix_spawn_file_actions_addclose(file_actions, 
STDIN_FILENO);
+    }
     if (errorCode)
         return errorCode;
-    errorCode = posix_spawn_file_actions_addclose(file_actions, STDOUT_FILENO);
+    
+    path = xpc_dictionary_get_string(message, 
LauncherXPCServiceStdOutPathKeyKey);
+    if (path)
+    {
+        errorCode = posix_spawn_file_actions_addopen(file_actions, 
STDOUT_FILENO, path, O_NOCTTY | O_CREAT | O_WRONLY, 0640);
+    }
+    else
+    {
+        errorCode = posix_spawn_file_actions_addclose(file_actions, 
STDOUT_FILENO);
+    }
     if (errorCode)
         return errorCode;
-    errorCode = posix_spawn_file_actions_addclose(file_actions, STDERR_FILENO);
+    
+    path = xpc_dictionary_get_string(message, 
LauncherXPCServiceStdErrPathKeyKey);
+    if (path)
+    {
+        errorCode = posix_spawn_file_actions_addopen(file_actions, 
STDERR_FILENO, path, O_NOCTTY | O_CREAT | O_RDWR, 0640);
+    }
+    else
+    {
+        errorCode = posix_spawn_file_actions_addclose(file_actions, 
STDERR_FILENO);
+    }
     
     return errorCode;
 }


_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to