[Lldb-commits] [lldb] r169787 - /lldb/trunk/source/Host/macosx/Host.mm

Han Ming Ong hanming at apple.com
Mon Dec 10 15:02:33 PST 2012


Author: hanming
Date: Mon Dec 10 17:02:33 2012
New Revision: 169787

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

When there is XPC connection error, we will report it now.

Modified:
    lldb/trunk/source/Host/macosx/Host.mm

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=169787&r1=169786&r2=169787&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Mon Dec 10 17:02:33 2012
@@ -1377,7 +1377,7 @@
         return error;
     
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
-        
+    
     uid_t requested_uid = launch_info.GetUserID();
     const char *xpc_service  = nil;
     bool send_auth = false;
@@ -1394,7 +1394,7 @@
         }
         else
         {
-            error.SetError(4, eErrorTypeGeneric);
+            error.SetError(3, eErrorTypeGeneric);
             error.SetErrorStringWithFormat("Launching root via XPC needs to externalize authorization reference.");
             if (log)
             {
@@ -1406,7 +1406,7 @@
     }
     else
     {
-        error.SetError(3, eErrorTypeGeneric);
+        error.SetError(4, eErrorTypeGeneric);
         error.SetErrorStringWithFormat("Launching via XPC is only currently available for either the login user or root.");
         if (log)
         {
@@ -1422,7 +1422,7 @@
         
         if (type == XPC_TYPE_ERROR) {
             if (event == XPC_ERROR_CONNECTION_INTERRUPTED) {
-                // The service has either canceled itself, crashed, or been terminated. 
+                // The service has either canceled itself, crashed, or been terminated.
                 // The XPC connection is still valid and sending a message to it will re-launch the service.
                 // If the service is state-full, this is the time to initialize the new service.
                 return;
@@ -1435,12 +1435,12 @@
                 // printf("Unexpected error from service: %s", xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION));
             }
             
-        } else {			
+        } else {
             // printf("Received unexpected event in handler");
         }
     });
     
-        xpc_connection_set_finalizer_f (conn, xpc_finalizer_t(xpc_release));
+    xpc_connection_set_finalizer_f (conn, xpc_finalizer_t(xpc_release));
 	xpc_connection_resume (conn);
     xpc_object_t message = xpc_dictionary_create (nil, nil, 0);
     
@@ -1457,24 +1457,36 @@
     xpc_dictionary_set_int64(message, LauncherXPCServicePosixspawnFlagsKey, GetPosixspawnFlags(launch_info));
     
     xpc_object_t reply = xpc_connection_send_message_with_reply_sync(conn, message);
-    
-    pid = xpc_dictionary_get_int64(reply, LauncherXPCServiceChildPIDKey);
-    if (pid == 0)
+    xpc_type_t returnType = xpc_get_type(reply);
+    if (returnType == XPC_TYPE_DICTIONARY)
     {
-        int errorType = xpc_dictionary_get_int64(reply, LauncherXPCServiceErrorTypeKey);
-        int errorCode = xpc_dictionary_get_int64(reply, LauncherXPCServiceCodeTypeKey);
-        
-        error.SetError(errorCode, eErrorTypeGeneric);
-        error.SetErrorStringWithFormat("Problems with launching via XPC. Error type : %i, code : %i", errorType, errorCode);
-        if (log)
+        pid = xpc_dictionary_get_int64(reply, LauncherXPCServiceChildPIDKey);
+        if (pid == 0)
         {
-            error.PutToLog(log.get(), "%s", error.AsCString());
+            int errorType = xpc_dictionary_get_int64(reply, LauncherXPCServiceErrorTypeKey);
+            int errorCode = xpc_dictionary_get_int64(reply, LauncherXPCServiceCodeTypeKey);
+            
+            error.SetError(errorCode, eErrorTypeGeneric);
+            error.SetErrorStringWithFormat("Problems with launching via XPC. Error type : %i, code : %i", errorType, errorCode);
+            if (log)
+            {
+                error.PutToLog(log.get(), "%s", error.AsCString());
+            }
+            
+            if (authorizationRef)
+            {
+                AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
+                authorizationRef = NULL;
+            }
         }
-        
-        if (authorizationRef)
+    }
+    else if (returnType == XPC_TYPE_ERROR)
+    {
+        error.SetError(5, eErrorTypeGeneric);
+        error.SetErrorStringWithFormat("Problems with launching via XPC. XPC error : %s", xpc_dictionary_get_string(reply, XPC_ERROR_KEY_DESCRIPTION));
+        if (log)
         {
-            AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
-            authorizationRef = NULL;
+            error.PutToLog(log.get(), "%s", error.AsCString());
         }
     }
     
@@ -1658,6 +1670,7 @@
 static bool
 ShouldLaunchUsingXPC(const char *exe_path, ProcessLaunchInfo &launch_info)
 {
+    return true;
     bool result = false;
 
 #if !NO_XPC_SERVICES    





More information about the lldb-commits mailing list