diff options
| author | 2020-10-22 12:03:56 +0200 | |
|---|---|---|
| committer | 2020-12-10 00:38:33 +0100 | |
| commit | fad6a83086d39d4f6ee6cab8276238a71cd165ff (patch) | |
| tree | 0278e398a60f32a04d6618239f33aef37e91a6d3 /tools/idevicedebug.c | |
| parent | f856a65a23be48bdda0a0ec2a0ef0b687402afce (diff) | |
| download | libimobiledevice-fad6a83086d39d4f6ee6cab8276238a71cd165ff.tar.gz libimobiledevice-fad6a83086d39d4f6ee6cab8276238a71cd165ff.tar.bz2 | |
idevicedebug: Add --detach option to start an app and exit idevicedebug without killing the app
Diffstat (limited to 'tools/idevicedebug.c')
| -rw-r--r-- | tools/idevicedebug.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c index 83a70a4..74ce069 100644 --- a/tools/idevicedebug.c +++ b/tools/idevicedebug.c | |||
| @@ -197,6 +197,7 @@ static void print_usage(int argc, char **argv) | |||
| 197 | printf("The following OPTIONS are accepted:\n"); | 197 | printf("The following OPTIONS are accepted:\n"); |
| 198 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); | 198 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); |
| 199 | printf(" -n, --network\t\tconnect to network device\n"); | 199 | printf(" -n, --network\t\tconnect to network device\n"); |
| 200 | printf(" --detach\t\tdetach from app after launch, keeping it running\n"); | ||
| 200 | printf(" -e, --env NAME=VALUE\tset environment variable NAME to VALUE\n"); | 201 | printf(" -e, --env NAME=VALUE\tset environment variable NAME to VALUE\n"); |
| 201 | printf(" -d, --debug\t\tenable communication debugging\n"); | 202 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 202 | printf(" -h, --help\t\tprints usage information\n"); | 203 | printf(" -h, --help\t\tprints usage information\n"); |
| @@ -217,6 +218,7 @@ int main(int argc, char *argv[]) | |||
| 217 | int cmd = CMD_NONE; | 218 | int cmd = CMD_NONE; |
| 218 | const char* udid = NULL; | 219 | const char* udid = NULL; |
| 219 | int use_network = 0; | 220 | int use_network = 0; |
| 221 | int detach_after_start = 0; | ||
| 220 | const char* bundle_identifier = NULL; | 222 | const char* bundle_identifier = NULL; |
| 221 | char* path = NULL; | 223 | char* path = NULL; |
| 222 | char* working_directory = NULL; | 224 | char* working_directory = NULL; |
| @@ -254,6 +256,9 @@ int main(int argc, char *argv[]) | |||
| 254 | } else if (!strcmp(argv[i], "-n") || !strcmp(argv[i], "--network")) { | 256 | } else if (!strcmp(argv[i], "-n") || !strcmp(argv[i], "--network")) { |
| 255 | use_network = 1; | 257 | use_network = 1; |
| 256 | continue; | 258 | continue; |
| 259 | } else if (!strcmp(argv[i], "--detach")) { | ||
| 260 | detach_after_start = 1; | ||
| 261 | continue; | ||
| 257 | } else if (!strcmp(argv[i], "-e") || !strcmp(argv[i], "--env")) { | 262 | } else if (!strcmp(argv[i], "-e") || !strcmp(argv[i], "--env")) { |
| 258 | i++; | 263 | i++; |
| 259 | if (!argv[i] || (strlen(argv[i]) <= 1) || strchr(argv[i], '=') == NULL) { | 264 | if (!argv[i] || (strlen(argv[i]) <= 1) || strchr(argv[i], '=') == NULL) { |
| @@ -447,6 +452,17 @@ int main(int argc, char *argv[]) | |||
| 447 | response = NULL; | 452 | response = NULL; |
| 448 | } | 453 | } |
| 449 | 454 | ||
| 455 | if (detach_after_start) { | ||
| 456 | log_debug("Detaching from app"); | ||
| 457 | debugserver_command_new("D", 0, NULL, &command); | ||
| 458 | dres = debugserver_client_send_command(debugserver_client, command, &response, NULL); | ||
| 459 | debugserver_command_free(command); | ||
| 460 | command = NULL; | ||
| 461 | |||
| 462 | res = (dres == DEBUGSERVER_E_SUCCESS) ? 0: -1; | ||
| 463 | break; | ||
| 464 | } | ||
| 465 | |||
| 450 | /* set thread */ | 466 | /* set thread */ |
| 451 | log_debug("Setting thread..."); | 467 | log_debug("Setting thread..."); |
| 452 | debugserver_command_new("Hc0", 0, NULL, &command); | 468 | debugserver_command_new("Hc0", 0, NULL, &command); |
