Skip to content

add --nolldb (-N): start debugserver without lldb #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ If you are *not* using a node version manager like [nvm](https://github.com/crea
-t, --timeout <timeout> number of seconds to wait for a device to be connected
-u, --unbuffered don't buffer stdout
-n, --nostart do not start the app when debugging
-N, --nolldb start debugserver only. do not run lldb
-I, --noninteractive start in non interactive mode (quit when app crashes or exits)
-L, --justlaunch just launch the app and exit lldb
-v, --verbose enable verbose output
Expand Down Expand Up @@ -109,6 +110,9 @@ The commands below assume that you have an app called `my.app` with bundle id `b
// deploy and launch your app to a connected device, quit when app crashes or exits
ios-deploy --noninteractive --debug --bundle my.app

// Debug your pre-installed app with an external debugger (e.g. lldb or IDA Pro)
ios-deploy --noinstall --nolldb --port 6666 --bundle my.app

// Upload a file to your app's Documents folder
ios-deploy --bundle_id 'bundle.id' --upload test.txt --to Documents/test.txt

Expand Down
34 changes: 29 additions & 5 deletions src/ios-deploy/ios-deploy.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
mach_error_t AMDeviceLookupApplications(AMDeviceRef device, CFDictionaryRef options, CFDictionaryRef *result);
int AMDeviceGetInterfaceType(struct am_device *device);

bool found_device = false, debug = false, verbose = false, unbuffered = false, nostart = false, detect_only = false, install = true, uninstall = false, no_wifi = false;
bool found_device = false, debug = false, verbose = false, unbuffered = false, nostart = false, debugserver_only = false, detect_only = false, install = true, uninstall = false, no_wifi = false;
bool command_only = false;
char *command = NULL;
char const*target_filename = NULL;
Expand Down Expand Up @@ -932,7 +932,8 @@ void setup_lldb(AMDeviceRef device, CFURLRef url) {

mount_developer_image(device); // put debugserver on the device
start_remote_debug_server(device); // start debugserver
write_lldb_prep_cmds(device, url); // dump the necessary lldb commands into a file
if (!debugserver_only)
write_lldb_prep_cmds(device, url); // dump the necessary lldb commands into a file

CFRelease(url);

Expand Down Expand Up @@ -1033,6 +1034,20 @@ void launch_debugger_and_exit(AMDeviceRef device, CFURLRef url) {
}
}

void launch_debugserver_only(AMDeviceRef device, CFURLRef url)
{
CFRetain(url);
setup_lldb(device,url);

CFStringRef bundle_identifier = copy_disk_app_identifier(url);
CFURLRef device_app_url = copy_device_app_url(device, bundle_identifier);
CFStringRef device_app_path = CFURLCopyFileSystemPath(device_app_url, kCFURLPOSIXPathStyle);
CFRelease(url);

NSLogOut(@"debugserver port: %d", port);
NSLogOut(@"App path: %@", device_app_path);
}

CFStringRef get_bundle_id(CFURLRef app_url)
{
if (app_url == NULL)
Expand Down Expand Up @@ -1642,10 +1657,13 @@ void handle_device(AMDeviceRef device) {
if (!debug)
exit(0); // no debug phase

if (justlaunch)
if (justlaunch) {
launch_debugger_and_exit(device, url);
else
} else if (debugserver_only) {
launch_debugserver_only(device, url);
} else {
launch_debugger(device, url);
}
}

void device_callback(struct am_device_notification_callback_info *info, void *arg) {
Expand Down Expand Up @@ -1716,6 +1734,7 @@ void usage(const char* app) {
@" -t, --timeout <timeout> number of seconds to wait for a device to be connected\n"
@" -u, --unbuffered don't buffer stdout\n"
@" -n, --nostart do not start the app when debugging\n"
@" -N, --nolldb start debugserver only. do not run lldb\n"
@" -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n"
@" -L, --justlaunch just launch the app and exit lldb\n"
@" -v, --verbose enable verbose output\n"
Expand Down Expand Up @@ -1760,6 +1779,7 @@ int main(int argc, char *argv[]) {
{ "timeout", required_argument, NULL, 't' },
{ "unbuffered", no_argument, NULL, 'u' },
{ "nostart", no_argument, NULL, 'n' },
{ "nolldb", no_argument, NULL, 'N' },
{ "noninteractive", no_argument, NULL, 'I' },
{ "justlaunch", no_argument, NULL, 'L' },
{ "detect", no_argument, NULL, 'c' },
Expand All @@ -1782,7 +1802,7 @@ int main(int argc, char *argv[]) {
};
char ch;

while ((ch = getopt_long(argc, argv, "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::B::W", longopts, NULL)) != -1)
while ((ch = getopt_long(argc, argv, "VmcdvunNrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::B::W", longopts, NULL)) != -1)
{
switch (ch) {
case 'm':
Expand Down Expand Up @@ -1813,6 +1833,10 @@ int main(int argc, char *argv[]) {
case 'n':
nostart = 1;
break;
case 'N':
debugserver_only = true;
debug = true;
break;
case 'I':
interactive = false;
debug = 1;
Expand Down