For completeness.
* count.c (error_cmp): New function.
(set_sortby): Add sort keys for errors field.
* strace.1.in (.SH OPTIONS) <-S>: Document it.
* strace.c (usage): Likewise.
* tests/strace-S.test: Check it.
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
return (m < n) ? 1 : (m > n) ? -1 : 0;
}
+static int
+error_cmp(const void *a, const void *b)
+{
+ const unsigned int *a_int = a;
+ const unsigned int *b_int = b;
+ unsigned int m = counts[*a_int].errors;
+ unsigned int n = counts[*b_int].errors;
+
+ return (m < n) ? 1 : (m > n) ? -1 : 0;
+}
+
static int (*sortfun)(const void *, const void *);
void
{ time_cmp, "total_time" },
{ count_cmp, "calls" },
{ count_cmp, "count" },
+ { error_cmp, "error" },
+ { error_cmp, "errors" },
{ syscall_cmp, "name" },
{ syscall_cmp, "syscall" },
{ syscall_cmp, "syscall_name" },
option by the specified criterion. Legal values are
.BR time " (or " time_total " or " total_time ),
.BR calls " (or " count ),
+.BR errors " (or " error ),
.BR name " (or " syscall " or " syscall_name ),
and
.BR nothing " (or " none );
summary\n\
-C like -c but also print regular output\n\
-O overhead set overhead for tracing syscalls to OVERHEAD usecs\n\
- -S sortby sort syscall counts by: time, calls, name, nothing (default %s)\n\
+ -S sortby sort syscall counts by: time, calls, errors, name, nothing\n\
+ (default %s)\n\
-w summarise syscall latency (default is system time)\n\
\n\
Filtering:\n\
test_c "$s" '' \
'/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'([[:space:]]+[0-9]+)?'"$c"'$/\6/p'
done
+for s in error errors; do
+ test_c "$s" '-n -r' \
+ '/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'([[:space:]]+([0-9]+))?'"$c"'$/\6/p'
+done