diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/idevicedebug.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c index ae6dd02..67ef938 100644 --- a/tools/idevicedebug.c +++ b/tools/idevicedebug.c | |||
| @@ -119,8 +119,9 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client | |||
| 119 | char* o = NULL; | 119 | char* o = NULL; |
| 120 | char* r = *response; | 120 | char* r = *response; |
| 121 | 121 | ||
| 122 | /* Documentation of response codes can be found here: | 122 | /* Documentation of response codes can be found here: |
| 123 | https://github.com/llvm/llvm-project/blob/4fe839ef3a51e0ea2e72ea2f8e209790489407a2/lldb/docs/lldb-gdb-remote.txt#L1269 */ | 123 | https://github.com/llvm/llvm-project/blob/4fe839ef3a51e0ea2e72ea2f8e209790489407a2/lldb/docs/lldb-gdb-remote.txt#L1269 |
| 124 | */ | ||
| 124 | 125 | ||
| 125 | if (r[0] == 'O') { | 126 | if (r[0] == 'O') { |
| 126 | /* stdout/stderr */ | 127 | /* stdout/stderr */ |
| @@ -130,8 +131,11 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client | |||
| 130 | } else if (r[0] == 'T') { | 131 | } else if (r[0] == 'T') { |
| 131 | /* thread stopped information */ | 132 | /* thread stopped information */ |
| 132 | log_debug("Thread stopped. Details:\n%s", r + 1); | 133 | log_debug("Thread stopped. Details:\n%s", r + 1); |
| 133 | if (exit_status != NULL) { | 134 | if (exit_status != NULL) { |
| 134 | /* "Thread stopped" seems to happen when assert() fails. Use bash convention where signals cause an exit status of 128 + signal */ | 135 | /* "Thread stopped" seems to happen when assert() fails. |
| 136 | Use bash convention where signals cause an exit | ||
| 137 | status of 128 + signal | ||
| 138 | */ | ||
| 135 | *exit_status = 128 + SIGABRT; | 139 | *exit_status = 128 + SIGABRT; |
| 136 | } | 140 | } |
| 137 | /* Break out of the loop. */ | 141 | /* Break out of the loop. */ |
| @@ -143,13 +147,15 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client | |||
| 143 | debugserver_decode_string(r + 1, strlen(r) - 1, &o); | 147 | debugserver_decode_string(r + 1, strlen(r) - 1, &o); |
| 144 | if (o != NULL) { | 148 | if (o != NULL) { |
| 145 | printf("Exit %s: %u\n", (r[0] == 'W' ? "status" : "due to signal"), o[0]); | 149 | printf("Exit %s: %u\n", (r[0] == 'W' ? "status" : "due to signal"), o[0]); |
| 146 | if (exit_status != NULL) { | 150 | if (exit_status != NULL) { |
| 147 | /* Use bash convention where signals cause an exit status of 128 + signal */ | 151 | /* Use bash convention where signals cause an |
| 148 | *exit_status = o[0] + (r[0] == 'W' ? 0 : 128); | 152 | exit status of 128 + signal |
| 149 | } | 153 | */ |
| 154 | *exit_status = o[0] + (r[0] == 'W' ? 0 : 128); | ||
| 155 | } | ||
| 150 | } else { | 156 | } else { |
| 151 | debug_info("Unable to decode exit status from %s", r); | 157 | debug_info("Unable to decode exit status from %s", r); |
| 152 | dres = DEBUGSERVER_E_UNKNOWN_ERROR; | 158 | dres = DEBUGSERVER_E_UNKNOWN_ERROR; |
| 153 | } | 159 | } |
| 154 | } else if (r && strlen(r) == 0) { | 160 | } else if (r && strlen(r) == 0) { |
| 155 | log_debug("empty response"); | 161 | log_debug("empty response"); |
| @@ -157,13 +163,13 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client | |||
| 157 | log_debug("ERROR: unhandled response '%s'", r); | 163 | log_debug("ERROR: unhandled response '%s'", r); |
| 158 | } | 164 | } |
| 159 | 165 | ||
| 160 | if (o != NULL) { | 166 | if (o != NULL) { |
| 161 | free(o); | 167 | free(o); |
| 162 | o = NULL; | 168 | o = NULL; |
| 163 | } | 169 | } |
| 164 | 170 | ||
| 165 | free(*response); | 171 | free(*response); |
| 166 | *response = NULL; | 172 | *response = NULL; |
| 167 | return dres; | 173 | return dres; |
| 168 | } | 174 | } |
| 169 | 175 | ||
| @@ -351,8 +357,8 @@ int main(int argc, char *argv[]) | |||
| 351 | goto cleanup; | 357 | goto cleanup; |
| 352 | } | 358 | } |
| 353 | 359 | ||
| 354 | /* set receive params */ | 360 | /* set receive params */ |
| 355 | if (debugserver_client_set_receive_params(debugserver_client, cancel_receive, 250) != DEBUGSERVER_E_SUCCESS) { | 361 | if (debugserver_client_set_receive_params(debugserver_client, cancel_receive, 250) != DEBUGSERVER_E_SUCCESS) { |
| 356 | fprintf(stderr, "Error in debugserver_client_set_receive_params\n"); | 362 | fprintf(stderr, "Error in debugserver_client_set_receive_params\n"); |
| 357 | goto cleanup; | 363 | goto cleanup; |
| 358 | } | 364 | } |
| @@ -494,7 +500,7 @@ int main(int argc, char *argv[]) | |||
| 494 | if (strncmp(response, "OK", 2)) { | 500 | if (strncmp(response, "OK", 2)) { |
| 495 | dres = debugserver_client_handle_response(debugserver_client, &response, &res); | 501 | dres = debugserver_client_handle_response(debugserver_client, &response, &res); |
| 496 | if (dres != DEBUGSERVER_E_SUCCESS) { | 502 | if (dres != DEBUGSERVER_E_SUCCESS) { |
| 497 | debug_info("failed to process response; error %d; %s", dres, response); | 503 | log_debug("failed to process response; error %d; %s", dres, response); |
| 498 | break; | 504 | break; |
| 499 | } | 505 | } |
| 500 | } | 506 | } |
| @@ -521,9 +527,9 @@ int main(int argc, char *argv[]) | |||
| 521 | response = NULL; | 527 | response = NULL; |
| 522 | } | 528 | } |
| 523 | 529 | ||
| 524 | if (res < 0) { | 530 | if (res < 0) { |
| 525 | res = (dres == DEBUGSERVER_E_SUCCESS) ? 0: -1; | 531 | res = (dres == DEBUGSERVER_E_SUCCESS) ? 0: -1; |
| 526 | } | 532 | } |
| 527 | break; | 533 | break; |
| 528 | } | 534 | } |
| 529 | 535 | ||
