Upstreaming the apple internal changes that accumulated during the
previous release.  Most of the diffs are duplication in the xcode
project file caused by adding a "debugserver-mini" target.  Jim
Ingham added support for a new SPI needed to request app launches
on iOS.  Greg Clayton added code to indicate the platform of the
binary (macosx, ios, watchos, tvos) based on Mach-O load commands.
Jason Molenda added code so debugserver will identify when it is
running on a tvos/watchos device to lldb.

llvm-svn: 251091
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp
index afd5b00..33d39af 100644
--- a/lldb/tools/debugserver/source/debugserver.cpp
+++ b/lldb/tools/debugserver/source/debugserver.cpp
@@ -202,7 +202,13 @@
         // Our default launch method is posix spawn
         launch_flavor = eLaunchFlavorPosixSpawn;
 
-#if defined WITH_BKS
+#if defined WITH_FBS
+        // Check if we have an app bundle, if so launch using BackBoard Services.
+        if (strstr(inferior_argv[0], ".app"))
+        {
+            launch_flavor = eLaunchFlavorFBS;
+        }
+#elif defined WITH_BKS
         // Check if we have an app bundle, if so launch using BackBoard Services.
         if (strstr(inferior_argv[0], ".app"))
         {
@@ -1094,6 +1100,10 @@
                     else if (strcasestr(optarg, "backboard") == optarg)
                         g_launch_flavor = eLaunchFlavorBKS;
 #endif
+#ifdef WITH_FBS
+                    else if (strcasestr(optarg, "frontboard") == optarg)
+                        g_launch_flavor = eLaunchFlavorFBS;
+#endif
 
                     else
                     {
@@ -1108,6 +1118,9 @@
 #ifdef WITH_BKS
                         RNBLogSTDERR ("  backboard  Launch the executable through BackBoard Services.\n");
 #endif
+#ifdef WITH_FBS
+                        RNBLogSTDERR ("  frontboard  Launch the executable through FrontBoard Services.\n");
+#endif
                         exit (5);
                     }
                 }
@@ -1484,7 +1497,13 @@
                         // Our default launch method is posix spawn
                         launch_flavor = eLaunchFlavorPosixSpawn;
 
-#if defined WITH_BKS
+#if defined WITH_FBS
+                        // Check if we have an app bundle, if so launch using SpringBoard.
+                        if (waitfor_pid_name.find (".app") != std::string::npos)
+                        {
+                            launch_flavor = eLaunchFlavorFBS;
+                        }
+#elif defined WITH_BKS
                         // Check if we have an app bundle, if so launch using SpringBoard.
                         if (waitfor_pid_name.find (".app") != std::string::npos)
                         {