summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/idevicecrashreport.13
-rw-r--r--tools/idevicecrashreport.c21
2 files changed, 21 insertions, 3 deletions
diff --git a/docs/idevicecrashreport.1 b/docs/idevicecrashreport.1
index aba806a..6acd6e9 100644
--- a/docs/idevicecrashreport.1
+++ b/docs/idevicecrashreport.1
@@ -30,6 +30,9 @@ copy but do not remove crash reports from device.
30.B \-d, \-\-debug 30.B \-d, \-\-debug
31enable communication debugging. 31enable communication debugging.
32.TP 32.TP
33.B \-f, \-\-filter NAME
34filter crash reports by NAME (case sensitive)
35.TP
33.B \-h, \-\-help 36.B \-h, \-\-help
34prints usage information. 37prints usage information.
35.TP 38.TP
diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c
index 7df8dd9..ba54ebc 100644
--- a/tools/idevicecrashreport.c
+++ b/tools/idevicecrashreport.c
@@ -103,7 +103,7 @@ static int extract_raw_crash_report(const char* filename)
103 return res; 103 return res;
104} 104}
105 105
106static int afc_client_copy_and_remove_crash_reports(afc_client_t afc, const char* device_directory, const char* host_directory) 106static int afc_client_copy_and_remove_crash_reports(afc_client_t afc, const char* device_directory, const char* host_directory, const char* filename_filter)
107{ 107{
108 afc_error_t afc_error; 108 afc_error_t afc_error;
109 int k; 109 int k;
@@ -242,12 +242,16 @@ static int afc_client_copy_and_remove_crash_reports(afc_client_t afc, const char
242#else 242#else
243 mkdir(target_filename, 0755); 243 mkdir(target_filename, 0755);
244#endif 244#endif
245 res = afc_client_copy_and_remove_crash_reports(afc, source_filename, target_filename); 245 res = afc_client_copy_and_remove_crash_reports(afc, source_filename, target_filename, filename_filter);
246 246
247 /* remove directory from device */ 247 /* remove directory from device */
248 if (!keep_crash_reports) 248 if (!keep_crash_reports)
249 afc_remove_path(afc, source_filename); 249 afc_remove_path(afc, source_filename);
250 } else if (S_ISREG(stbuf.st_mode)) { 250 } else if (S_ISREG(stbuf.st_mode)) {
251 if (filename_filter != NULL && strstr(source_filename, filename_filter) == NULL) {
252 continue;
253 }
254
251 /* copy file to host */ 255 /* copy file to host */
252 afc_error = afc_file_open(afc, source_filename, AFC_FOPEN_RDONLY, &handle); 256 afc_error = afc_file_open(afc, source_filename, AFC_FOPEN_RDONLY, &handle);
253 if(afc_error != AFC_E_SUCCESS) { 257 if(afc_error != AFC_E_SUCCESS) {
@@ -324,6 +328,7 @@ static void print_usage(int argc, char **argv)
324 printf(" -e, --extract\t\textract raw crash report into separate '.crash' file\n"); 328 printf(" -e, --extract\t\textract raw crash report into separate '.crash' file\n");
325 printf(" -k, --keep\t\tcopy but do not remove crash reports from device\n"); 329 printf(" -k, --keep\t\tcopy but do not remove crash reports from device\n");
326 printf(" -d, --debug\t\tenable communication debugging\n"); 330 printf(" -d, --debug\t\tenable communication debugging\n");
331 printf(" -f, --filter NAME\tfilter crash reports by NAME (case sensitive)\n");
327 printf(" -h, --help\t\tprints usage information\n"); 332 printf(" -h, --help\t\tprints usage information\n");
328 printf(" -v, --version\t\tprints version information\n"); 333 printf(" -v, --version\t\tprints version information\n");
329 printf("\n"); 334 printf("\n");
@@ -344,6 +349,7 @@ int main(int argc, char* argv[])
344 int i; 349 int i;
345 const char* udid = NULL; 350 const char* udid = NULL;
346 int use_network = 0; 351 int use_network = 0;
352 const char* filename_filter = NULL;
347 353
348#ifndef WIN32 354#ifndef WIN32
349 signal(SIGPIPE, SIG_IGN); 355 signal(SIGPIPE, SIG_IGN);
@@ -367,6 +373,15 @@ int main(int argc, char* argv[])
367 use_network = 1; 373 use_network = 1;
368 continue; 374 continue;
369 } 375 }
376 else if (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--filter")) {
377 i++;
378 if (!argv[i] || !*argv[i]) {
379 print_usage(argc, argv);
380 return 0;
381 }
382 filename_filter = argv[i];
383 continue;
384 }
370 else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { 385 else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
371 print_usage(argc, argv); 386 print_usage(argc, argv);
372 return 0; 387 return 0;
@@ -492,7 +507,7 @@ int main(int argc, char* argv[])
492 } 507 }
493 508
494 /* recursively copy crash reports from the device to a local directory */ 509 /* recursively copy crash reports from the device to a local directory */
495 if (afc_client_copy_and_remove_crash_reports(afc, ".", target_directory) < 0) { 510 if (afc_client_copy_and_remove_crash_reports(afc, ".", target_directory, filename_filter) < 0) {
496 fprintf(stderr, "ERROR: Failed to get crash reports from device.\n"); 511 fprintf(stderr, "ERROR: Failed to get crash reports from device.\n");
497 afc_client_free(afc); 512 afc_client_free(afc);
498 idevice_free(device); 513 idevice_free(device);