[Lldb-commits] [lldb] r318496 - Recognize another magic token sent in the LaunchInfo's EventData.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 16 17:22:34 PST 2017


Author: jingham
Date: Thu Nov 16 17:22:34 2017
New Revision: 318496

URL: http://llvm.org/viewvc/llvm-project?rev=318496&view=rev
Log:
Recognize another magic token sent in the LaunchInfo's EventData.

<rdar://problem/32505028>

Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=318496&r1=318495&r2=318496&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Thu Nov 16 17:22:34 2017
@@ -45,6 +45,26 @@
 #include "CFBundle.h"
 #include "CFString.h"
 
+static void SplitEventData(const char *data, std::vector<std::string> &elements)
+{
+  elements.clear();
+  if (!data)
+    return;
+
+  const char *start = data;
+
+  while (*start != '\0') {
+    const char *token = strchr(start, ':');
+    if (!token) {
+      elements.push_back(std::string(start));
+      return;
+    }
+    if (token != start)
+      elements.push_back(std::string(start, token - start));
+    start = ++token;
+  }
+}
+
 #ifdef WITH_SPRINGBOARD
 
 #include <CoreFoundation/CoreFoundation.h>
@@ -112,7 +132,9 @@ static bool CallBoardSystemServiceOpenAp
   if (!cstr)
     cstr = "<Unknown Bundle ID>";
 
-  DNBLog("About to launch process for bundle ID: %s", cstr);
+  NSString *description = [options description];
+  DNBLog("About to launch process for bundle ID: %s - options:\n%s", cstr,
+    [description UTF8String]);
   [system_service
       openApplication:bundleIDNSStr
               options:options
@@ -222,21 +244,31 @@ static void SetBKSError(NSInteger error_
 static bool BKSAddEventDataToOptions(NSMutableDictionary *options,
                                      const char *event_data,
                                      DNBError &option_error) {
-  if (strcmp(event_data, "BackgroundContentFetching") == 0) {
-    DNBLog("Setting ActivateForEvent key in options dictionary.");
-    NSDictionary *event_details = [NSDictionary dictionary];
-    NSDictionary *event_dictionary = [NSDictionary
-        dictionaryWithObject:event_details
-                      forKey:
-                          BKSActivateForEventOptionTypeBackgroundContentFetching];
-    [options setObject:event_dictionary
-                forKey:BKSOpenApplicationOptionKeyActivateForEvent];
-    return true;
-  } else {
-    DNBLogError("Unrecognized event type: %s.  Ignoring.", event_data);
-    option_error.SetErrorString("Unrecognized event data.");
-    return false;
+  std::vector<std::string> values;
+  SplitEventData(event_data, values);
+  bool found_one = false;
+  for (std::string value : values)
+  {
+      if (value.compare("BackgroundContentFetching") == 0) {
+        DNBLog("Setting ActivateForEvent key in options dictionary.");
+        NSDictionary *event_details = [NSDictionary dictionary];
+        NSDictionary *event_dictionary = [NSDictionary
+            dictionaryWithObject:event_details
+                          forKey:
+                              BKSActivateForEventOptionTypeBackgroundContentFetching];
+        [options setObject:event_dictionary
+                    forKey:BKSOpenApplicationOptionKeyActivateForEvent];
+        found_one = true;
+      } else if (value.compare("ActivateSuspended") == 0) {
+        DNBLog("Setting ActivateSuspended key in options dictionary.");
+        [options setObject:@YES forKey: BKSOpenApplicationOptionKeyActivateSuspended];
+        found_one = true;
+      } else {
+        DNBLogError("Unrecognized event type: %s.  Ignoring.", value.c_str());
+        option_error.SetErrorString("Unrecognized event data");
+      }
   }
+  return found_one;
 }
 
 static NSMutableDictionary *BKSCreateOptionsDictionary(
@@ -322,21 +354,31 @@ static void SetFBSError(NSInteger error_
 static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
                                      const char *event_data,
                                      DNBError &option_error) {
-  if (strcmp(event_data, "BackgroundContentFetching") == 0) {
-    DNBLog("Setting ActivateForEvent key in options dictionary.");
-    NSDictionary *event_details = [NSDictionary dictionary];
-    NSDictionary *event_dictionary = [NSDictionary
-        dictionaryWithObject:event_details
-                      forKey:
-                          FBSActivateForEventOptionTypeBackgroundContentFetching];
-    [options setObject:event_dictionary
-                forKey:FBSOpenApplicationOptionKeyActivateForEvent];
-    return true;
-  } else {
-    DNBLogError("Unrecognized event type: %s.  Ignoring.", event_data);
-    option_error.SetErrorString("Unrecognized event data.");
-    return false;
+  std::vector<std::string> values;
+  SplitEventData(event_data, values);
+  bool found_one = false;
+  for (std::string value : values)
+  {
+      if (value.compare("BackgroundContentFetching") == 0) {
+        DNBLog("Setting ActivateForEvent key in options dictionary.");
+        NSDictionary *event_details = [NSDictionary dictionary];
+        NSDictionary *event_dictionary = [NSDictionary
+            dictionaryWithObject:event_details
+                          forKey:
+                              FBSActivateForEventOptionTypeBackgroundContentFetching];
+        [options setObject:event_dictionary
+                    forKey:FBSOpenApplicationOptionKeyActivateForEvent];
+        found_one = true;
+      } else if (value.compare("ActivateSuspended") == 0) {
+        DNBLog("Setting ActivateSuspended key in options dictionary.");
+        [options setObject:@YES forKey: FBSOpenApplicationOptionKeyActivateSuspended];
+        found_one = true;
+      } else {
+        DNBLogError("Unrecognized event type: %s.  Ignoring.", value.c_str());
+        option_error.SetErrorString("Unrecognized event data.");
+      }
   }
+  return found_one;
 }
 
 static NSMutableDictionary *




More information about the lldb-commits mailing list