summaryrefslogtreecommitdiffstats
path: root/tools/idevicecrashreport.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/idevicecrashreport.c')
-rw-r--r--tools/idevicecrashreport.c21
1 files changed, 18 insertions, 3 deletions
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)
return res;
}
-static int afc_client_copy_and_remove_crash_reports(afc_client_t afc, const char* device_directory, const char* host_directory)
+static int afc_client_copy_and_remove_crash_reports(afc_client_t afc, const char* device_directory, const char* host_directory, const char* filename_filter)
{
afc_error_t afc_error;
int k;
@@ -242,12 +242,16 @@ static int afc_client_copy_and_remove_crash_reports(afc_client_t afc, const char
#else
mkdir(target_filename, 0755);
#endif
- res = afc_client_copy_and_remove_crash_reports(afc, source_filename, target_filename);
+ res = afc_client_copy_and_remove_crash_reports(afc, source_filename, target_filename, filename_filter);
/* remove directory from device */
if (!keep_crash_reports)
afc_remove_path(afc, source_filename);
} else if (S_ISREG(stbuf.st_mode)) {
+ if (filename_filter != NULL && strstr(source_filename, filename_filter) == NULL) {
+ continue;
+ }
+
/* copy file to host */
afc_error = afc_file_open(afc, source_filename, AFC_FOPEN_RDONLY, &handle);
if(afc_error != AFC_E_SUCCESS) {
@@ -324,6 +328,7 @@ static void print_usage(int argc, char **argv)
printf(" -e, --extract\t\textract raw crash report into separate '.crash' file\n");
printf(" -k, --keep\t\tcopy but do not remove crash reports from device\n");
printf(" -d, --debug\t\tenable communication debugging\n");
+ printf(" -f, --filter NAME\tfilter crash reports by NAME (case sensitive)\n");
printf(" -h, --help\t\tprints usage information\n");
printf(" -v, --version\t\tprints version information\n");
printf("\n");
@@ -344,6 +349,7 @@ int main(int argc, char* argv[])
int i;
const char* udid = NULL;
int use_network = 0;
+ const char* filename_filter = NULL;
#ifndef WIN32
signal(SIGPIPE, SIG_IGN);
@@ -367,6 +373,15 @@ int main(int argc, char* argv[])
use_network = 1;
continue;
}
+ else if (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--filter")) {
+ i++;
+ if (!argv[i] || !*argv[i]) {
+ print_usage(argc, argv);
+ return 0;
+ }
+ filename_filter = argv[i];
+ continue;
+ }
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
print_usage(argc, argv);
return 0;
@@ -492,7 +507,7 @@ int main(int argc, char* argv[])
}
/* recursively copy crash reports from the device to a local directory */
- if (afc_client_copy_and_remove_crash_reports(afc, ".", target_directory) < 0) {
+ if (afc_client_copy_and_remove_crash_reports(afc, ".", target_directory, filename_filter) < 0) {
fprintf(stderr, "ERROR: Failed to get crash reports from device.\n");
afc_client_free(afc);
idevice_free(device);