summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Ben Wagner2020-02-06 19:02:33 -0500
committerGravatar Nikias Bassen2022-03-29 12:01:34 +0200
commitfa85bb4fb05caf4f1fb35aef3a6f0de6083b9722 (patch)
treea4e64acc13435ef25765c99955337e7f7a9e9e0c /tools
parentb08be09c0da5ab6a68cc6079bd35d895ba2f8b99 (diff)
downloadlibimobiledevice-fa85bb4fb05caf4f1fb35aef3a6f0de6083b9722.tar.gz
libimobiledevice-fa85bb4fb05caf4f1fb35aef3a6f0de6083b9722.tar.bz2
implement as documented
Diffstat (limited to 'tools')
-rw-r--r--tools/idevicedebug.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c
index 24cc46d..a5559e1 100644
--- a/tools/idevicedebug.c
+++ b/tools/idevicedebug.c
@@ -115,6 +115,9 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client
char* o = NULL;
char* r = *response;
+ /* Documentation of response codes can be found here:
+ https://github.com/llvm/llvm-project/blob/4fe839ef3a51e0ea2e72ea2f8e209790489407a2/lldb/docs/lldb-gdb-remote.txt#L1269 */
+
if (r[0] == 'O') {
/* stdout/stderr */
debugserver_decode_string(r + 1, strlen(r) - 1, &o);
@@ -148,22 +151,8 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client
return dres;
dres = DEBUGSERVER_E_UNKNOWN_ERROR;
- } else if (r[0] == 'E' || r[0] == 'W') {
- /* dogben: 'W' + hex-encoded byte seems to mean "process exited with this status." */
- if (r[0] == 'W' && strlen(r) == 3 && exit_status != NULL) {
- debugserver_decode_string(r + 1, strlen(r) - 1, &o);
- if (o != NULL) {
- printf("Exit status: %u\n", o[0]);
- *exit_status = o[0];
- free(o);
- o = NULL;
- free(*response);
- *response = NULL;
- return dres;
- }
- }
-
- printf("%s: %s\n", (r[0] == 'E' ? "ERROR": "WARNING") , r + 1);
+ } else if (r[0] == 'E') {
+ printf("ERROR: %s\n", r + 1);
free(*response);
*response = NULL;
@@ -177,6 +166,18 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client
log_debug("result: %d", dres);
debugserver_command_free(command);
command = NULL;
+ } else if (r[0] == 'W' || r[0] == 'X') {
+ /* process exited */
+ debugserver_decode_string(r + 1, strlen(r) - 1, &o);
+ if (o != NULL) {
+ printf("Exit %s: %u\n", (r[0] == 'W' ? "status" : "due to signal"), o[0]);
+ *exit_status = o[0] + (r[0] == 'W' ? 0 : 128);
+ free(o);
+ o = NULL;
+ }
+ free(*response);
+ *response = NULL;
+ return dres;
} else if (r && strlen(r) == 0) {
if (!send_reply)
return dres;
@@ -520,7 +521,7 @@ int main(int argc, char *argv[])
dres = debugserver_client_handle_response(debugserver_client, &response, 1, &exit_status);
}
}
- if (exit_status > 0) {
+ if (exit_status >= 0) {
goto cleanup;
}