[Lldb-commits] [lldb] r151119 - in /lldb/trunk/tools/debugserver: debugserver.xcodeproj/project.pbxproj source/DNBDefs.h source/DNBError.cpp source/DNBError.h source/MacOSX/MachProcess.cpp source/MacOSX/MachProcess.h source/MacOSX/MachTask.cpp source/RNBDefs.h source/RNBServices.cpp source/RNBSocket.cpp source/RNBSocket.h source/debugserver.cpp

Jason Molenda jmolenda at apple.com
Tue Feb 21 18:19:00 PST 2012


Author: jmolenda
Date: Tue Feb 21 20:18:59 2012
New Revision: 151119

URL: http://llvm.org/viewvc/llvm-project?rev=151119&view=rev
Log:
Change #ifdef markers around lockdown and SpringBoard
calls to dpeend on WITH_SPRINGBOARD and WITH_LOCKDOWN
instead of __arm__.  Add an RNBSocket::useFD method.


Modified:
    lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
    lldb/trunk/tools/debugserver/source/DNBDefs.h
    lldb/trunk/tools/debugserver/source/DNBError.cpp
    lldb/trunk/tools/debugserver/source/DNBError.h
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
    lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp
    lldb/trunk/tools/debugserver/source/RNBDefs.h
    lldb/trunk/tools/debugserver/source/RNBServices.cpp
    lldb/trunk/tools/debugserver/source/RNBSocket.cpp
    lldb/trunk/tools/debugserver/source/RNBSocket.h
    lldb/trunk/tools/debugserver/source/debugserver.cpp

Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Feb 21 20:18:59 2012
@@ -383,7 +383,7 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
-				LastUpgradeCheck = 0420;
+				LastUpgradeCheck = 0430;
 			};
 			buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */;
 			compatibilityVersion = "Xcode 3.2";
@@ -563,6 +563,12 @@
 				INSTALL_PATH = /usr/bin;
 				LLDB_DEBUGSERVER = 1;
 				OTHER_CFLAGS = "-Wparentheses";
+				"OTHER_CFLAGS[sdk=iphoneos*][arch=*]" = (
+					"-Wparentheses",
+					"-DWITH_LOCKDOWN",
+					"-DWITH_SPRINGBOARD",
+				);
+				"OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*][arch=*]" = "$(OTHER_CFLAGS)";
 				OTHER_LDFLAGS = (
 					"-sectcreate",
 					__TEXT,
@@ -603,6 +609,12 @@
 				INSTALL_PATH = /usr/bin;
 				LLDB_DEBUGSERVER = 1;
 				OTHER_CFLAGS = "-Wparentheses";
+				"OTHER_CFLAGS[sdk=iphoneos*][arch=*]" = (
+					"-Wparentheses",
+					"-DWITH_LOCKDOWN",
+					"-DWITH_SPRINGBOARD",
+				);
+				"OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*][arch=*]" = "$(OTHER_CFLAGS)";
 				OTHER_LDFLAGS = (
 					"-sectcreate",
 					__TEXT,
@@ -642,6 +654,12 @@
 				INSTALL_PATH = /usr/bin;
 				LLDB_DEBUGSERVER = 1;
 				OTHER_CFLAGS = "-Wparentheses";
+				"OTHER_CFLAGS[sdk=iphoneos*][arch=*]" = (
+					"-Wparentheses",
+					"-DWITH_LOCKDOWN",
+					"-DWITH_SPRINGBOARD",
+				);
+				"OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*][arch=*]" = "$(OTHER_CFLAGS)";
 				OTHER_LDFLAGS = (
 					"-sectcreate",
 					__TEXT,

Modified: lldb/trunk/tools/debugserver/source/DNBDefs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDefs.h?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBDefs.h (original)
+++ lldb/trunk/tools/debugserver/source/DNBDefs.h Tue Feb 21 20:18:59 2012
@@ -98,7 +98,7 @@
     eLaunchFlavorDefault = 0,
     eLaunchFlavorPosixSpawn,
     eLaunchFlavorForkExec,
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     eLaunchFlavorSpringBoard,
 #endif
 } nub_launch_flavor_t;

Modified: lldb/trunk/tools/debugserver/source/DNBError.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBError.cpp?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBError.cpp (original)
+++ lldb/trunk/tools/debugserver/source/DNBError.cpp Tue Feb 21 20:18:59 2012
@@ -16,7 +16,7 @@
 #include "DNBLog.h"
 #include "PThreadMutex.h"
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
 #include <SpringBoardServices/SpringBoardServer.h>
 #endif
 
@@ -39,7 +39,7 @@
             s = ::strerror (m_err);
             break;
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
         case SpringBoard:
             {
                 CFStringRef statusStr = SBSApplicationLaunchingErrorString (m_err);

Modified: lldb/trunk/tools/debugserver/source/DNBError.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBError.h?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBError.h (original)
+++ lldb/trunk/tools/debugserver/source/DNBError.h Tue Feb 21 20:18:59 2012
@@ -28,7 +28,7 @@
         Generic = 0,
         MachKernel,
         POSIX
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
         , SpringBoard
 #endif
     } FlavorType;

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Tue Feb 21 20:18:59 2012
@@ -40,13 +40,12 @@
 
 static CFStringRef CopyBundleIDForPath (const char *app_buncle_path, DNBError &err_str);
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <SpringBoardServices/SpringBoardServer.h>
 #include <SpringBoardServices/SBSWatchdogAssertion.h>
 
-
 static bool
 IsSBProcess (nub_process_t pid)
 {
@@ -74,7 +73,6 @@
     return false;
 }
 
-
 #endif
 
 #if 0
@@ -1328,7 +1326,7 @@
         SetState(eStateAttaching);
         m_pid = pid;
         // Let ourselves know we are going to be using SBS if the correct flag bit is set...
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
         if (IsSBProcess(pid))
             m_flags |= eMachProcessFlagsUsingSBS;
 #endif
@@ -1377,7 +1375,7 @@
 const void *
 MachProcess::PrepareForAttach (const char *path, nub_launch_flavor_t launch_flavor, bool waitfor, DNBError &err_str)
 {
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     // Tell SpringBoard to halt the next launch of this application on startup.
 
     if (!waitfor)
@@ -1444,7 +1442,7 @@
     if (attach_token == NULL)
         return INVALID_NUB_PROCESS;
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     CFStringRef bundleIDCFStr = (CFStringRef) attach_token;
     Boolean got_it;
     nub_process_t attach_pid;
@@ -1465,7 +1463,7 @@
 void
 MachProcess::CleanupAfterAttach (const void *attach_token, bool success, DNBError &err_str)
 {
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     if (attach_token == NULL)
         return;
 
@@ -1540,7 +1538,7 @@
                                                                 launch_err);
         break;
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
 
     case eLaunchFlavorSpringBoard:
         {
@@ -1898,7 +1896,7 @@
     return pid;
 }
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
 
 pid_t
 MachProcess::SBLaunchForDebug (const char *path, char const *argv[], char const *envp[], bool no_stdio, DNBError &launch_err)
@@ -2151,6 +2149,6 @@
     return INVALID_NUB_PROCESS;
 }
 
-#endif // #if defined (__arm__)
+#endif // #ifdef WITH_SPRINGBOARD
 
 

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Tue Feb 21 20:18:59 2012
@@ -77,7 +77,7 @@
     static const void *     PrepareForAttach (const char *path, nub_launch_flavor_t launch_flavor, bool waitfor, DNBError &err_str);
     static void             CleanupAfterAttach (const void *attach_token, bool success, DNBError &err_str);
     static nub_process_t    CheckForProcess (const void *attach_token);
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     pid_t                   SBLaunchForDebug (const char *app_bundle_path, char const *argv[], char const *envp[], bool no_stdio, DNBError &launch_err);
     static pid_t            SBForkChildForPTraceDebugging (const char *path, char const *argv[], char const *envp[], bool no_stdio, MachProcess* process, DNBError &launch_err);
 #endif

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp Tue Feb 21 20:18:59 2012
@@ -33,7 +33,7 @@
 #include "DNBDataRef.h"
 #include "stack_logging.h"
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <SpringBoardServices/SpringBoardServer.h>
@@ -444,7 +444,7 @@
     task_t task = mach_task->TaskPort();
     mach_msg_timeout_t periodic_timeout = 0;
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     mach_msg_timeout_t watchdog_elapsed = 0;
     mach_msg_timeout_t watchdog_timeout = 60 * 1000;
     pid_t pid = mach_proc->ProcessID();
@@ -474,7 +474,7 @@
         if (periodic_timeout == 0 || periodic_timeout > watchdog_timeout)
             periodic_timeout = watchdog_timeout;
     }
-#endif  // #if defined (__arm__)
+#endif  // #ifdef WITH_SPRINGBOARD
 
     while (mach_task->ExceptionPortIsValid())
     {
@@ -555,7 +555,7 @@
                 continue;
             }
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
             if (watchdog.get())
             {
                 watchdog_elapsed += periodic_timeout;
@@ -583,7 +583,7 @@
         }
     }
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     if (watchdog.get())
     {
         // TODO: change SBSWatchdogAssertionRelease to SBSWatchdogAssertionCancel when we
@@ -593,7 +593,7 @@
         DNBLogThreadedIf(LOG_TASK, "::SBSWatchdogAssertionRelease(%p)", watchdog.get());
         ::SBSWatchdogAssertionRelease (watchdog.get());
     }
-#endif  // #if defined (__arm__)
+#endif  // #ifdef WITH_SPRINGBOARD
 
     DNBLogThreadedIf(LOG_EXCEPTIONS, "MachTask::%s (%p): thread exiting...", __FUNCTION__, arg);
     return NULL;

Modified: lldb/trunk/tools/debugserver/source/RNBDefs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBDefs.h?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBDefs.h (original)
+++ lldb/trunk/tools/debugserver/source/RNBDefs.h Tue Feb 21 20:18:59 2012
@@ -42,7 +42,7 @@
 
 #elif defined (__arm__)
 
-#define RNB_ARCH    "armv6"
+#define RNB_ARCH    "armv7"
 
 #else
 

Modified: lldb/trunk/tools/debugserver/source/RNBServices.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBServices.cpp?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBServices.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBServices.cpp Tue Feb 21 20:18:59 2012
@@ -18,14 +18,14 @@
 #import "DNBLog.h"
 #include "MacOSX/CFUtils.h"
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
 #import <SpringBoardServices/SpringBoardServices.h>
 #endif
 
 int
 ListApplications(std::string& plist, bool opt_runningApps, bool opt_debuggable)
 {
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     int result = -1;
 
     CFAllocatorRef alloc = kCFAllocatorDefault;
@@ -118,7 +118,7 @@
 bool
 IsSBProcess (nub_process_t pid)
 {
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
     bool opt_runningApps = true;
     bool opt_debuggable = false;
 

Modified: lldb/trunk/tools/debugserver/source/RNBSocket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBSocket.cpp?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBSocket.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBSocket.cpp Tue Feb 21 20:18:59 2012
@@ -22,7 +22,7 @@
 #include "DNBLog.h"
 #include "DNBError.h"
 
-#if defined (__arm__)
+#ifdef WITH_LOCKDOWN
 #include "lockdown.h"
 #endif
 
@@ -169,7 +169,19 @@
     return rnb_success;
 }
 
-#if defined (__arm__)
+rnb_err_t
+RNBSocket::useFD(int fd)
+{
+       if (fd < 0) {
+               DNBLogThreadedIf(LOG_RNB_COMM, "Bad file descriptor passed in.");
+               return rnb_err;
+       }
+       
+       m_fd = fd;
+       return rnb_success;
+}
+
+#ifdef WITH_LOCKDOWN
 rnb_err_t
 RNBSocket::ConnectToService()
 {
@@ -222,8 +234,10 @@
 rnb_err_t
 RNBSocket::Disconnect (bool save_errno)
 {
+#ifdef WITH_LOCKDOWN
     if (m_fd_from_lockdown)
         m_fd_from_lockdown = false;
+#endif
     return ClosePort (m_fd, save_errno);
 }
 
@@ -278,12 +292,12 @@
         return rnb_err;
 
     DNBError err;
-    int bytessent = send (m_fd, buffer, length, 0);
+    int bytessent = write (m_fd, buffer, length);
     if (bytessent < 0)
         err.SetError(errno, DNBError::POSIX);
 
     if (err.Fail() || DNBLogCheckLogBit(LOG_RNB_COMM))
-        err.LogThreaded("::send ( socket = %i, buffer = %p, length = %zu, flags = 0 ) => %i", m_fd, buffer, length, bytessent);
+        err.LogThreaded("::write ( socket = %i, buffer = %p, length = %zu) => %i", m_fd, buffer, length, bytessent);
 
     if (bytessent < 0)
         return rnb_err;

Modified: lldb/trunk/tools/debugserver/source/RNBSocket.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBSocket.h?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBSocket.h (original)
+++ lldb/trunk/tools/debugserver/source/RNBSocket.h Tue Feb 21 20:18:59 2012
@@ -27,7 +27,9 @@
 
     RNBSocket () :
         m_fd (-1),
+#ifdef WITH_LOCKDOWN
         m_fd_from_lockdown (false),
+#endif
         m_timer (true)      // Make a thread safe timer
     {
     }
@@ -39,7 +41,9 @@
     rnb_err_t Listen (in_port_t port, PortBoundCallback callback, const void *callback_baton);
     rnb_err_t Connect (const char *host, uint16_t port);
 
-#if defined (__arm__)
+    rnb_err_t useFD(int fd);
+
+#ifdef WITH_LOCKDOWN
     rnb_err_t ConnectToService();
 #endif
     rnb_err_t OpenFile (const char *path);
@@ -60,7 +64,11 @@
     rnb_err_t ClosePort (int& fd, bool save_errno);
 
     int m_fd;    // Socket we use to communicate once conn established
+
+#ifdef WITH_LOCKDOWN
     bool m_fd_from_lockdown;
+#endif
+
     DNBTimer m_timer;
 };
 

Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=151119&r1=151118&r2=151119&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/debugserver.cpp (original)
+++ lldb/trunk/tools/debugserver/source/debugserver.cpp Tue Feb 21 20:18:59 2012
@@ -192,7 +192,7 @@
         // Our default launch method is posix spawn
         launch_flavor = eLaunchFlavorPosixSpawn;
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
         // Check if we have an app bundle, if so launch using SpringBoard.
         if (strstr(inferior_argv[0], ".app"))
         {
@@ -955,7 +955,7 @@
                         g_launch_flavor = eLaunchFlavorPosixSpawn;
                     else if (strcasestr(optarg, "fork") == optarg)
                         g_launch_flavor = eLaunchFlavorForkExec;
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
                     else if (strcasestr(optarg, "spring") == optarg)
                         g_launch_flavor = eLaunchFlavorSpringBoard;
 #endif
@@ -966,7 +966,7 @@
                         RNBLogSTDERR ("  auto    Auto-detect the best launch method to use.\n");
                         RNBLogSTDERR ("  posix   Launch the executable using posix_spawn.\n");
                         RNBLogSTDERR ("  fork    Launch the executable using fork and exec.\n");
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
                         RNBLogSTDERR ("  spring  Launch the executable through Springboard.\n");
 #endif
                         exit (5);
@@ -1234,7 +1234,7 @@
         switch (mode)
         {
             case eRNBRunLoopModeGetStartModeFromRemoteProtocol:
-#if defined (__arm__)
+#ifdef WITH_LOCKDOWN
                 if (g_lockdown_opt)
                 {
                     if (!remote->Comm().IsConnected())
@@ -1308,7 +1308,7 @@
                         // Our default launch method is posix spawn
                         launch_flavor = eLaunchFlavorPosixSpawn;
 
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
                         // Check if we have an app bundle, if so launch using SpringBoard.
                         if (waitfor_pid_name.find (".app") != std::string::npos)
                         {





More information about the lldb-commits mailing list