Change #ifdef markers around lockdown and SpringBoard
calls to dpeend on WITH_SPRINGBOARD and WITH_LOCKDOWN
instead of __arm__. Add an RNBSocket::useFD method.
llvm-svn: 151119
diff --git a/lldb/tools/debugserver/source/DNBDefs.h b/lldb/tools/debugserver/source/DNBDefs.h
index 8792632..fce2cac 100644
--- a/lldb/tools/debugserver/source/DNBDefs.h
+++ b/lldb/tools/debugserver/source/DNBDefs.h
@@ -98,7 +98,7 @@
eLaunchFlavorDefault = 0,
eLaunchFlavorPosixSpawn,
eLaunchFlavorForkExec,
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
eLaunchFlavorSpringBoard,
#endif
} nub_launch_flavor_t;
diff --git a/lldb/tools/debugserver/source/DNBError.cpp b/lldb/tools/debugserver/source/DNBError.cpp
index 8f6294b..84727e7 100644
--- a/lldb/tools/debugserver/source/DNBError.cpp
+++ b/lldb/tools/debugserver/source/DNBError.cpp
@@ -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);
diff --git a/lldb/tools/debugserver/source/DNBError.h b/lldb/tools/debugserver/source/DNBError.h
index 10c6638..78b2c8b 100644
--- a/lldb/tools/debugserver/source/DNBError.h
+++ b/lldb/tools/debugserver/source/DNBError.h
@@ -28,7 +28,7 @@
Generic = 0,
MachKernel,
POSIX
-#if defined (__arm__)
+#ifdef WITH_SPRINGBOARD
, SpringBoard
#endif
} FlavorType;
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
index 264c736..d0d4c8d 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
@@ -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
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
index d52735a..af9fb69 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -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
diff --git a/lldb/tools/debugserver/source/MacOSX/MachTask.cpp b/lldb/tools/debugserver/source/MacOSX/MachTask.cpp
index 88f3f46..49605a9 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachTask.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachTask.cpp
@@ -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;
diff --git a/lldb/tools/debugserver/source/RNBDefs.h b/lldb/tools/debugserver/source/RNBDefs.h
index f603d3d..bf35497 100644
--- a/lldb/tools/debugserver/source/RNBDefs.h
+++ b/lldb/tools/debugserver/source/RNBDefs.h
@@ -42,7 +42,7 @@
#elif defined (__arm__)
-#define RNB_ARCH "armv6"
+#define RNB_ARCH "armv7"
#else
diff --git a/lldb/tools/debugserver/source/RNBServices.cpp b/lldb/tools/debugserver/source/RNBServices.cpp
index 846c469..5e793db 100644
--- a/lldb/tools/debugserver/source/RNBServices.cpp
+++ b/lldb/tools/debugserver/source/RNBServices.cpp
@@ -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;
diff --git a/lldb/tools/debugserver/source/RNBSocket.cpp b/lldb/tools/debugserver/source/RNBSocket.cpp
index 5bc2780..744f9ea 100644
--- a/lldb/tools/debugserver/source/RNBSocket.cpp
+++ b/lldb/tools/debugserver/source/RNBSocket.cpp
@@ -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;
diff --git a/lldb/tools/debugserver/source/RNBSocket.h b/lldb/tools/debugserver/source/RNBSocket.h
index 5fd6ac2..97fd632 100644
--- a/lldb/tools/debugserver/source/RNBSocket.h
+++ b/lldb/tools/debugserver/source/RNBSocket.h
@@ -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;
};
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp
index 00bd3cd..3274925 100644
--- a/lldb/tools/debugserver/source/debugserver.cpp
+++ b/lldb/tools/debugserver/source/debugserver.cpp
@@ -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)
{