Skip to content

Commit c7d7306

Browse files
committed
add --nolldb (-N): start debugserver without lldb
Comes in hadny when one wishes to attach with an external debugserver client (e.g. a custom lldb or IDA)
1 parent 52018c8 commit c7d7306

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ If you are *not* using a node version manager like [nvm](https://github.com/crea
7474
-t, --timeout <timeout> number of seconds to wait for a device to be connected
7575
-u, --unbuffered don't buffer stdout
7676
-n, --nostart do not start the app when debugging
77+
-N, --nolldb start debugserver only. do not run lldb
7778
-I, --noninteractive start in non interactive mode (quit when app crashes or exits)
7879
-L, --justlaunch just launch the app and exit lldb
7980
-v, --verbose enable verbose output

src/ios-deploy/ios-deploy.m

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
mach_error_t AMDeviceLookupApplications(AMDeviceRef device, CFDictionaryRef options, CFDictionaryRef *result);
7575
int AMDeviceGetInterfaceType(struct am_device *device);
7676

77-
bool found_device = false, debug = false, verbose = false, unbuffered = false, nostart = false, detect_only = false, install = true, uninstall = false, no_wifi = false;
77+
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;
7878
bool command_only = false;
7979
char *command = NULL;
8080
char const*target_filename = NULL;
@@ -932,7 +932,8 @@ void setup_lldb(AMDeviceRef device, CFURLRef url) {
932932

933933
mount_developer_image(device); // put debugserver on the device
934934
start_remote_debug_server(device); // start debugserver
935-
write_lldb_prep_cmds(device, url); // dump the necessary lldb commands into a file
935+
if (!debugserver_only)
936+
write_lldb_prep_cmds(device, url); // dump the necessary lldb commands into a file
936937

937938
CFRelease(url);
938939

@@ -1033,6 +1034,20 @@ void launch_debugger_and_exit(AMDeviceRef device, CFURLRef url) {
10331034
}
10341035
}
10351036

1037+
void launch_debugserver_only(AMDeviceRef device, CFURLRef url)
1038+
{
1039+
CFRetain(url);
1040+
setup_lldb(device,url);
1041+
1042+
CFStringRef bundle_identifier = copy_disk_app_identifier(url);
1043+
CFURLRef device_app_url = copy_device_app_url(device, bundle_identifier);
1044+
CFStringRef device_app_path = CFURLCopyFileSystemPath(device_app_url, kCFURLPOSIXPathStyle);
1045+
CFRelease(url);
1046+
1047+
NSLogOut(@"debugserver port: %d", port);
1048+
NSLogOut(@"App path: %@", device_app_path);
1049+
}
1050+
10361051
CFStringRef get_bundle_id(CFURLRef app_url)
10371052
{
10381053
if (app_url == NULL)
@@ -1642,10 +1657,13 @@ void handle_device(AMDeviceRef device) {
16421657
if (!debug)
16431658
exit(0); // no debug phase
16441659

1645-
if (justlaunch)
1660+
if (justlaunch) {
16461661
launch_debugger_and_exit(device, url);
1647-
else
1662+
} else if (debugserver_only) {
1663+
launch_debugserver_only(device, url);
1664+
} else {
16481665
launch_debugger(device, url);
1666+
}
16491667
}
16501668

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

1785-
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)
1805+
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)
17861806
{
17871807
switch (ch) {
17881808
case 'm':
@@ -1813,6 +1833,10 @@ int main(int argc, char *argv[]) {
18131833
case 'n':
18141834
nostart = 1;
18151835
break;
1836+
case 'N':
1837+
debugserver_only = true;
1838+
debug = true;
1839+
break;
18161840
case 'I':
18171841
interactive = false;
18181842
debug = 1;

0 commit comments

Comments
 (0)