From fad6a83086d39d4f6ee6cab8276238a71cd165ff Mon Sep 17 00:00:00 2001 From: Jan Peter Stotz Date: Thu, 22 Oct 2020 12:03:56 +0200 Subject: idevicedebug: Add --detach option to start an app and exit idevicedebug without killing the app --- tools/idevicedebug.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tools/idevicedebug.c') 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) printf("The following OPTIONS are accepted:\n"); printf(" -u, --udid UDID\ttarget specific device by UDID\n"); printf(" -n, --network\t\tconnect to network device\n"); + printf(" --detach\t\tdetach from app after launch, keeping it running\n"); printf(" -e, --env NAME=VALUE\tset environment variable NAME to VALUE\n"); printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -h, --help\t\tprints usage information\n"); @@ -217,6 +218,7 @@ int main(int argc, char *argv[]) int cmd = CMD_NONE; const char* udid = NULL; int use_network = 0; + int detach_after_start = 0; const char* bundle_identifier = NULL; char* path = NULL; char* working_directory = NULL; @@ -254,6 +256,9 @@ int main(int argc, char *argv[]) } else if (!strcmp(argv[i], "-n") || !strcmp(argv[i], "--network")) { use_network = 1; continue; + } else if (!strcmp(argv[i], "--detach")) { + detach_after_start = 1; + continue; } else if (!strcmp(argv[i], "-e") || !strcmp(argv[i], "--env")) { i++; if (!argv[i] || (strlen(argv[i]) <= 1) || strchr(argv[i], '=') == NULL) { @@ -447,6 +452,17 @@ int main(int argc, char *argv[]) response = NULL; } + if (detach_after_start) { + log_debug("Detaching from app"); + debugserver_command_new("D", 0, NULL, &command); + dres = debugserver_client_send_command(debugserver_client, command, &response, NULL); + debugserver_command_free(command); + command = NULL; + + res = (dres == DEBUGSERVER_E_SUCCESS) ? 0: -1; + break; + } + /* set thread */ log_debug("Setting thread..."); debugserver_command_new("Hc0", 0, NULL, &command); -- cgit v1.1-32-gdbae