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
This commit is contained in:
Jason Molenda 2012-02-22 02:18:59 +00:00
parent a1bed4cd96
commit 42999a48f9
12 changed files with 74 additions and 36 deletions

View File

@ -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,

View File

@ -98,7 +98,7 @@ typedef enum
eLaunchFlavorDefault = 0,
eLaunchFlavorPosixSpawn,
eLaunchFlavorForkExec,
#if defined (__arm__)
#ifdef WITH_SPRINGBOARD
eLaunchFlavorSpringBoard,
#endif
} nub_launch_flavor_t;

View File

@ -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 @@ DNBError::AsString() const
s = ::strerror (m_err);
break;
#if defined (__arm__)
#ifdef WITH_SPRINGBOARD
case SpringBoard:
{
CFStringRef statusStr = SBSApplicationLaunchingErrorString (m_err);

View File

@ -28,7 +28,7 @@ public:
Generic = 0,
MachKernel,
POSIX
#if defined (__arm__)
#ifdef WITH_SPRINGBOARD
, SpringBoard
#endif
} FlavorType;

View File

@ -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 @@ IsSBProcess (nub_process_t pid)
return false;
}
#endif
#if 0
@ -1328,7 +1326,7 @@ MachProcess::AttachForDebug (pid_t pid, char *err_str, size_t err_len)
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 @@ MachProcess::AttachForDebug (pid_t pid, char *err_str, size_t err_len)
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 @@ MachProcess::CheckForProcess (const void *attach_token)
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 @@ MachProcess::CheckForProcess (const void *attach_token)
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 @@ MachProcess::LaunchForDebug
launch_err);
break;
#if defined (__arm__)
#ifdef WITH_SPRINGBOARD
case eLaunchFlavorSpringBoard:
{
@ -1898,7 +1896,7 @@ MachProcess::ForkChildForPTraceDebugging
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 @@ MachProcess::SBForkChildForPTraceDebugging (const char *app_bundle_path, char co
return INVALID_NUB_PROCESS;
}
#endif // #if defined (__arm__)
#endif // #ifdef WITH_SPRINGBOARD

View File

@ -77,7 +77,7 @@ public:
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

View File

@ -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 @@ MachTask::ExceptionThread (void *arg)
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 @@ MachTask::ExceptionThread (void *arg)
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 @@ MachTask::ExceptionThread (void *arg)
continue;
}
#if defined (__arm__)
#ifdef WITH_SPRINGBOARD
if (watchdog.get())
{
watchdog_elapsed += periodic_timeout;
@ -583,7 +583,7 @@ MachTask::ExceptionThread (void *arg)
}
}
#if defined (__arm__)
#ifdef WITH_SPRINGBOARD
if (watchdog.get())
{
// TODO: change SBSWatchdogAssertionRelease to SBSWatchdogAssertionCancel when we
@ -593,7 +593,7 @@ MachTask::ExceptionThread (void *arg)
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;

View File

@ -42,7 +42,7 @@ extern "C" const double debugserverVersionNumber;
#elif defined (__arm__)
#define RNB_ARCH "armv6"
#define RNB_ARCH "armv7"
#else

View File

@ -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 @@ ListApplications(std::string& plist, bool opt_runningApps, bool opt_debuggable)
bool
IsSBProcess (nub_process_t pid)
{
#if defined (__arm__)
#ifdef WITH_SPRINGBOARD
bool opt_runningApps = true;
bool opt_debuggable = false;

View File

@ -22,7 +22,7 @@
#include "DNBLog.h"
#include "DNBError.h"
#if defined (__arm__)
#ifdef WITH_LOCKDOWN
#include "lockdown.h"
#endif
@ -169,7 +169,19 @@ RNBSocket::Connect (const char *host, uint16_t port)
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 @@ RNBSocket::SetSocketOption(int fd, int level, int option_name, int option_value)
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 @@ RNBSocket::Write (const void *buffer, size_t length)
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;

View File

@ -27,7 +27,9 @@ public:
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 @@ public:
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 @@ protected:
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;
};

View File

@ -192,7 +192,7 @@ RNBRunLoopLaunchInferior (RNBRemote *remote, const char *stdin_path, const char
// 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 @@ main (int argc, char *argv[])
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 @@ main (int argc, char *argv[])
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 @@ main (int argc, char *argv[])
switch (mode)
{
case eRNBRunLoopModeGetStartModeFromRemoteProtocol:
#if defined (__arm__)
#ifdef WITH_LOCKDOWN
if (g_lockdown_opt)
{
if (!remote->Comm().IsConnected())
@ -1308,7 +1308,7 @@ main (int argc, char *argv[])
// 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)
{